I recently decided to look at Perl, and when faced with Perl 5 vs 6, I went with 5 due to its maturity and vast support.
However, one of the features of Perl 6 which really intrigued me was the grammar
keyword, allowing one to define a language grammar which can be used to parse complex text. In other languages either an external library or a manual parsing implementation is usually needed for this.
Now that I've settled on Perl 5, is there any rough equivalent to Perl 6's grammar
keyword in Perl 5 (or other functionality for building grammars), built-in or otherwise?
Though I haven't used it much myself, I believe that the Acmeist software Pegex is close to Perl 6 Grammars.
There's no core support, but you can have a look at Parse::RecDescent, Marpa::R2, Regexp::Grammars, or for simpler tasks, just use (DEFINE)
in a regex (see perlre).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With