Parrot Perl6Grammar compiler and parsers #19

Add an action method for TOP

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

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

Results:

$ ./calc --target=past
> 3+4
found an integer 3
found an addop +
found an integer 4
found an expression 3+4
Copyright © 2009
http://www.pmichaud.com/2009/pres/