Perl: the Markov chain saw | |
PerlMonks |
Re^3: First steps with Marpa::R2 and BNFby GrandFather (Saint) |
on Jan 16, 2021 at 03:44 UTC ( [id://11126988]=note: print w/replies, xml ) | Need Help?? |
Perhaps a full example will help:
Note the :default ::= action => ::first. Actually we can omit the default line altogether and then change the Dice_Expression line to:
with the same result. The action determines what is passed up to the next level. If there is no action and no explicit default action undef is passed back up (although that isn't what the documentation seems to say). The default action is used where there is no explicit action. Perhaps the key thing to understand is that the called sub gets a parameter in its argument list for each RHS primary (see RHS alternatives) unless the primary is hidden. RHS values are either constant strings or the LHS for a G1 rule, or a L0 symbol.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
In Section
Seekers of Perl Wisdom
|
|