Yacc Embedded Actions |
Rules in yacc may contain embedded actions:
list: item1 { do_item1($1); } item2 { do_item2($3); } item3
Note that the actions take a slot in the stack. As a result do_item2 must use $3 to reference item2. Internally this grammar is transformed by yacc into
the following:
list: item1 _rule01 item2 _rule02 item3
_rule01: { do_item1($0); }
_rule02: { do_item2($0); }