The Parse::RecDescent documentation states
If a quote-delimited string or a Perl regex appears in a production, the parser attempts to match that string or pattern at that point in the text.
I thought I had found a bug in this: when I tried to use /\d/ to match a digit, I got a warning when the parser was created and the parser failed to work. /[0-9]/ seemed to work adequately, but then it would seem that Parse::RecDescent implements only its own subset regex language rather than using perl's.
While trying to post about the issue here, I decided to develop a minimalist program to demonstrate the problem ... and in doing so discovered that the bug was not in Parse::RecDescent at all, but in my own coding. Spot the error in the following:
use Parse::RecDescent; my $grammar = <<"EOF"; digit : /\d/ EOF my $parser = Parse::RecDescent->new($grammar); my $r; $r = $parser->digit("7"); print "[$r]\n";
Turns out the problem is those double-quotation marks around my EOF. That causes perl in constructing the string to try to interpret the \d, which of course does not work! The warning I was getting was not P::RD, but perl warning me I'd made a string it couldn't completely handle (unrecognized escape sequence). Then of course the parser failed, because it had an empty rule in it.
The moral of the story is when you can't get someone to stand over your shoulder and expose how you're coding like an idiot, post it to use.perl instead so you can spot it yourself in the process.