The parts of the action method
method if_stmt($/) {
my $past := PAST::Op.new(
$( $<expression> ), # condition
$( $<statement> ), # eval if true
:pasttype('if')
);
make $past;
}
- $/ is the node representing the if_stmt just matched
- $past becomes the newly created PAST::Op node
- $<expression> is the parse tree of the expression
- $( $<expression> ) is the AST of the expression
- "make $past" sets the AST for the if_stmt node