Let's hope that a future Perl version unbreaks what broke for this module.
Regexp::Grammars has made my life a lot easier. I basically registered just to say thanks. My most recent use of this is in TPath, which RG made almost trivial to implement. Well, maybe not trivial, but at least an order of magnitude easier.
I gave 5 stars since I really liked the idea under this module. Additionally, "Damian Conway" name is enough for me to check this module but, honestly speaking, it takes time to learn. I think learning Perl 5.10 regex extensions priorly makes use of this module clearer for you. It also shows you how this module facilitates the complicated syntax of 5.10 regexes.
Documentation may include more complete grammar examples to immediately check them during learning.
It also prepares you for Perl6 who wants to learn Perl6 style grammar definition which is another advantage for me, because, at last, hopefully, somehow, ..., :) Perl6 will replace Perl5.
Without the background Perl6/regex knowledge, this module is difficult to understand from the documentation alone.
However I do remember it taking me a while to get to grip with PRD as well, so this isn't necessarily a universally valid criticism.
I was drawn to R::G by its promise of power and efficiency. So far it hasn't won me over, even though, once I started converting my PRD grammar, I found it easy enough.
Currently I'm finding it more resource hungry than PRD, and liable to run out of memory and crash on large inputs. I hope these problems will go away once I learn how to tweak the default behaviours. So, only 3's for now.
Altering part of my grammar saw large improvements, for reasons I can't quite fathom. One general point is that you should avoid adding unnecessary cloistering brackets to your regexp's as this kills performance. I'm still seeing out of memory problems on larger (1+ Mb) input files, with both cygwin and strawberry perls, where PRD works perfectly well (if somewhat slowly).
Provides everything that is missing in Regexp engine.
I've used Parse::RecDescent and Parse::Eyapp before,
but Regexp::Grammars is the new ultimate grammar king in Perl 5!
What I love in this module:
- syntax is similar to Perl 6
- hash match prevents grammar changes on new keys
- "require:" makes numeric range check easy
- context string available for fast debug
- "debug:" pragmas for advanced debugging
- easy aliasing of matched tokens
- balanced delimiters
- easy noncapture (amnesiac) syntax
- passing params to tokens
and many many more
Also there is "demo" section in package with nice examples that helped me may times to understand how to use features from this module.
Parse::RecDescent is dead. Long live Regexp::Grammars!
As Damian himself has said/presented, RG is the successor for the popular PRD.
The docs of RG is not as complete (yet) as PRD's.
The PRD grammar syntax is also nicer/cleaner (due to RG having some restrictions because you are writing your grammar inside a regex).
RG doesn't (yet) have some of the features of PRD, like <leftop> and <rightop>. But it does have most of the features, and add a few of its own.
RG performs significantly faster than PRD.
In general, whenever you consider PRD to be a good candidate of tool to solve your problem, consider using RG.
But you need Perl 5.10+ to use RG, as it depends on regex features not found in older Perl.
1 hidden unhelpful review