context si lex literal '!', 'a', ';\n' token id /'a'|'b'/ { input.push( make_token( trans_id_to input.pull(match_length) ) ) } token super_id // token foo // ignore ws / [ \n\t]+ / end trans_id_to: int def e1 [] { print( 'old_id = ' trans_id_to '\n' ) trans_id_to = typeid print( 'new_id = ' trans_id_to '\n' ) } def item1 msg: str [ e1 '!' 'a' super_id super_id 'a'] { lhs.msg = 'this is item1\n' } def e2 [] { print( 'old_id = ' trans_id_to '\n' ) trans_id_to = typeid print( 'new_id = ' trans_id_to '\n' ) } def item2 msg: str [ e2 '!' 'a' super_id super_id 'a'] { lhs.msg = 'this is item2\n' } def start [item1 ';\n'] | [item2 ';\n'] { match lhs [Item2:item2 ';\n'] print( Item2.msg ) } end si cons SuperId: si[] parse S: si::start(SuperId)[stdin] print_xml( S.tree ) print( '\n' )