Parrot Perl6Grammar compiler and parsers #21

Subrule matches

regex TOP     { <integer> <addop> <integer> {*} }
regex integer { \d+ {*} }
regex addop   { [ '+' | '-' ] {*} }

method TOP($/)     {  say("found an expression ", $/); }

The captured components are the Match objects returned from the subrule

Since <integer> appears more than once in the regex, $/<integer> in the action method will be an Array of match objects (one for each match)

The same is true for any quantified capture

Copyright © 2009
http://www.pmichaud.com/2009/pres/