calc example -- src/pct/actions.pm
class Calc::Grammar::Actions;
method TOP($/) {
my $past := PAST::Op.new( :name('say'), $<statement>.ast );
make PAST::Block.new( $past, :hll('Calc') );
}
method statement($/) {
make PAST::Op.new( $<term>[0].ast,
$<term>[1].ast,
:pirop( $<addop> eq '+' ?? 'add' !! 'sub' )
);
}
method term($/) {
make PAST::Val.new( :value(+$/), :returns('Integer') );
}