Example "compiler", part 1 of 2
# parser grammar ABC::Grammar { rule TOP { <expr> } rule expr { <integer> <addop> <integer> }; token addop { '+' | '-' } token integer { \d+ } } # transform to ast class ABC::Actions { method TOP($/) { make PAST::Block.new( $<expr>.ast ); } method expr($/) { my $pirop := $<addop> eq '-' ?? 'sub' !! 'add'; make PAST::Op.new( :pirop($pirop), +$<integer>[0], +$<integer>[1]); } }