diff --git a/pom.xml b/pom.xml index a56fcb5..fe718e6 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,10 @@ + + SymbolConstants + true + diff --git a/src/main/java/main/Driver.java b/src/main/java/main/Driver.java index 736d66e..cb04c40 100644 --- a/src/main/java/main/Driver.java +++ b/src/main/java/main/Driver.java @@ -12,7 +12,7 @@ import com.beust.jcommander.ParameterException; import java_cup.runtime.Symbol; import parse.Lexer; -import parse.sym; +import parse.SymbolConstants; // command line options class DriverOptions { @@ -84,7 +84,7 @@ public static void lexicalAnalysis(Reader input) throws IOException { do { tok = lexer.next_token(); System.out.println(tok); - } while (tok.sym != sym.EOF); + } while (tok.sym != SymbolConstants.EOF); } } diff --git a/src/main/jflex/lexer.jflex b/src/main/jflex/lexer.jflex index 613f1d5..36a9147 100644 --- a/src/main/jflex/lexer.jflex +++ b/src/main/jflex/lexer.jflex @@ -7,19 +7,21 @@ import java_cup.runtime.Symbol; %public %final %class Lexer +%implements SymbolConstants +%cupsym SymbolConstants %cup %% [ \t\f\n\r]+ { /* skip */ } -[0-9]+ ("." [0-9]+)? { return new Symbol(sym.LITINT, yytext()); } +[0-9]+ ("." [0-9]+)? { return new Symbol(LITINT, yytext()); } -"+" { return new Symbol(sym.PLUS); } -"-" { return new Symbol(sym.MINUS); } -"*" { return new Symbol(sym.TIMES); } -"/" { return new Symbol(sym.DIV); } -"(" { return new Symbol(sym.LPAREN); } -")" { return new Symbol(sym.RPAREN); } +"+" { return new Symbol(PLUS); } +"-" { return new Symbol(MINUS); } +"*" { return new Symbol(TIMES); } +"/" { return new Symbol(DIV); } +"(" { return new Symbol(LPAREN); } +")" { return new Symbol(RPAREN); } . { System.out.printf("unexpected char |%s|\n", yytext()); }