I've been trying to get a global <skip> directive- before all rule definitions- to work, and it seems it must not be quoted or have any spaces. It seems to run counter to the Parse::RecDescent documantation. Following is code, I would expect each variant to parse, but only the first 2 are OK, and the last crashes with "Internal error in generated parser code!". Is that intended, or should I file a bug report?
-y #!/usr/bin/env perl use warnings; use strict; use Parse::RecDescent; $::RD_WARN=1; my $plain_grammar='words : (/\w+/)(s) /\Z/'; sub try_grammar { my ($name, $trace, $definition)=@_; print $name,": $definition = "; print $::RD_HINT=$::RD_TRACE=$trace if defined $trace; my $grammar = Parse::RecDescent->new("$definition\n$plain_grammar"); print defined $grammar->words("Please work") ? "OK" : "Didn't parse"; print "\n"; undef $::RD_HINT,$::RD_TRACE; } try_grammar('no skip directive',undef,''); try_grammar('bare skip',undef,"<skip:\\s*>"); try_grammar('bare skip, with a preceeding space',undef,"<skip: \\s*>"); try_grammar('bare skip, plus sign',undef,"<skip:\\s+>"); try_grammar('qr skip',undef,"<skip: qr/\\s*/>"); try_grammar('apostrophe skip',1,"<skip: '\\s*'>");