princepawn has asked for the wisdom of the Perl Monks concerning the following question:

I have a situation with the following grammar:
my $parse = Parse::RecDescent->new(<<'EndGrammar'); rebol : block { dump_item('block', \@item) } | scalar { dump_item('scalar', \@item) } block : '[' block_stuff(s?) ']' block_stuff : scalar scalar : <skip:''> '%' file file : /w+/ EndGrammar
My grammar matches a filename, ie:
%reb.html
just fine. However, it does not match a filename within a block, ie:
[ %reb.html ]
and I know exactly why after tracing the grammar.

It is trying the

<skip:''> '%' file
production with the input text
" %reb.html"
note the space in the input text.

The reason this distresses me is that I have not changed the universal token separator from

/\s*/
Yet it did not gobble up the white space between the '[' terminal and the  <skip:''>'%' file production

Replies are listed 'Best First'.
Re: The skip directive in Parse::RecDescent
by merlyn (Sage) on Oct 31, 2000 at 19:02 UTC
    That's the expected behavior. The outer prefix is in effect until changed, but you changed it early in the rule, so the previous "whitespace skip" is effectively gone by the time you hunt for '%'.

    To get what you want, you want:

    '%' <skip:''> file
    in your rule.

    -- Randal L. Schwartz, Perl hacker