options { STATIC = false; } PARSER_BEGIN(Parser) import java.io.*; import java.awt.event.*; class Parser { private ActionListener listener; public void setActionListener(ActionListener a){ listener = a; } private void output(int value){ listener.actionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, String.valueOf(value))); } } PARSER_END(Parser) TOKEN : { | | {num = Integer.parseInt(token.image); output(num); } ( token= {num += Integer.parseInt(token.image); output(num); } )* )* }