Pegex Grammar Parser for YAML
Perl Shell Makefile Perl 6
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



YAML::Pegex - YAML Parser using Pegex

yaml-pegex-pm yaml-pegex-pm


my $data = YAML::Pegex->new->parse($input);


YAML::Pegex is a YAML parser written in Pegex.

This module is not intended to be used in the real world. The code of YAML::Pegex is intended to replace the Pure Perl YAML modules: and YAML::Tiny.

Let me explain.

Pegex is a parsing framework with the following benefits:

  • Clean, crisp, and working grammars define languages.

    See for the current YAML::Pegex grammar.

    This means that almost anyone can identify and fix bugs in the language.

  • Pegex is fast.

    For pure Perl parsing, Pegex has been tuned to be very fast. Only benchmarks can speak accurately to speed, but trust me it's crazy fast so far, and can be made faster with a libpegex.

    Pegex preoptimizes its grammars before a parse. Many of these optimizations are done before the grammar goes to CPAN, so no require penalties for those optimizations.

    I'm confident that YAML::Pegex will out perform YAML::Tiny.

  • Pegex is multi language.

    The same grammar can be used for JavaScript, Python, Ruby, PHP, Java and so on.

    This is the key to making YAML (a fairly complex serialization language) be truly cross-language as it was intended.

The idea for YAML::Pegex is to build it up test by test. Once it passes all the YAML::* tests it can replace the pure Perl YAML modules.

This is only the parser, but that's the hardest part by far. YAML::Tiny and can still be different. will build a full stack which can do many amazing operations that have not been done with YAML in Perl yet. (Python and other languages have these things.) YAML::Tiny will just load yaml straight to Perl as quickly as possible.

After that we can possibly replace YAML::XS by writing libpegex. I have no idea how they would compare speedwise, but the other benefits would apply.


Ingy döt Net <>

Copyright and License

Copyright 2014. Ingy döt Net.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.