Skip to content

Commit

Permalink
Report errors using the error manager
Browse files Browse the repository at this point in the history
  • Loading branch information
romildo committed Oct 8, 2016
1 parent 911c1c2 commit a855739
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/main/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import parse.Lexer;
import parse.SymbolConstants;

import static error.ErrorManager.em;

// command line options
class DriverOptions {
@Parameter(description = "<source file>")
Expand Down Expand Up @@ -60,6 +62,8 @@ public static void main(String[] args) {
// do only lexical analyses
if (options.lexer)
lexicalAnalysis(input);

em.summary();
}
catch (IOException e) {
System.out.println(e.getMessage());
Expand Down
4 changes: 3 additions & 1 deletion src/main/jflex/lexer.jflex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package parse;

import static error.ErrorManager.em;

import java_cup.runtime.Symbol;
import java_cup.runtime.ComplexSymbolFactory.Location;
import java_cup.runtime.ComplexSymbolFactory;
Expand Down Expand Up @@ -54,4 +56,4 @@ import java_cup.runtime.ComplexSymbolFactory;
"(" { return tok(LPAREN); }
")" { return tok(RPAREN); }

. { System.out.printf("unexpected char |%s|\n", yytext()); }
. { em.error(Loc.loc(locLeft()), "unexpected char '%s'", yytext()); }

0 comments on commit a855739

Please sign in to comment.