options { STATIC = false; } PARSER_BEGIN(Exp_avaliator) import java.io.PrintStream ; class Exp_avaliator { public static void main( String[] args ) throws ParseException, TokenMgrError, NumberFormatException { while (true) { try { Exp_avaliator parser = new Exp_avaliator( System.in ); parser.Start( System.out ) ; } catch (Exception e) { System.out.println("Rejeitado!"); } } } } PARSER_END(Exp_avaliator) SKIP : { " " } SKIP : { "\n" | "\r" | "\r\n" } TOKEN : { < PLUS : "+" > } TOKEN : { < MINUS : "-" > } TOKEN : { < TIMES : "*" > } TOKEN : { < DIVIDE : "/" > } TOKEN : { < END : ";" > } TOKEN : { < OPEN_PAR : "(" > } TOKEN : { < CLOSE_PAR : ")" > } TOKEN : { < PREVIOUS : "$" > } TOKEN : { < NUMBER : | "." | "." | "." > } TOKEN : { < #DIGITS : (["0"-"9"])+ > } void Start(PrintStream printStream) throws NumberFormatException : {} { ( Exp() { System.out.println("Aceito!!"); } )* } void Exp() throws NumberFormatException : {} { Prim() ( ( | | | ) Prim() )* } void Prim() throws NumberFormatException : {} { | Exp() | Prim() }