Don't ask to ask, just ask | |
PerlMonks |
Re: Parse::RecDescent: how does <matchrule:> work?by 7stud (Deacon) |
on Feb 07, 2013 at 19:07 UTC ( [id://1017715]=note: print w/replies, xml ) | Need Help?? |
Yes, this is part of a larger grammar I'm working on, but I don't think posting the whole thing would be helpful. I would love to have you take a look at the complete grammar when I'm done. My current problem: when I incorporate the solution above into one of my rules, I can't get the blasted rule to return the entire match to other rules without causing the error: Jiminy Christmas. It looks like an action appearing in the middle of a rule inserts the return value of the action as an additional entry in @item! The inserted value *immediately follows* the current subrule's match:
The output shows that in the brace_block rule, the match for the subrule lbrace(1..), i.e. $item[1], is an array containing the matching braces. That is as expected. However, immediately following that match is the closing brace returned by the action that follows the lbrace(1..) rule. As a result, the matches for the other subrules are at indexes one higher than where they normally would be at. So the last line in the last action, which attempts to return all the matching text for the brace_clause rule, i.e.
needs to be changed to:
The same grammar can be used for parsing the three line block of text: { hello } {{ hello }} {{{ hello }}}
In Section
Seekers of Perl Wisdom
|
|