Skip to content

Commit

Permalink
Fixes #1188
Browse files Browse the repository at this point in the history
  • Loading branch information
parrt committed Nov 22, 2016
1 parent d09276d commit dc2c9b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@

public class TestToolSyntaxErrors extends BaseJavaToolTest {
static String[] A = {
// INPUT
"grammar A;\n" +
"",
// YIELDS
"error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",
// INPUT
"grammar A;\n" +
"",
// YIELDS
"error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",

"lexer grammar A;\n" +
"",
"error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",

"A;",
"error(" + ErrorType.SYNTAX_ERROR.code + "): A.g4:1:0: syntax error: 'A' came as a complete surprise to me\n",
Expand Down
4 changes: 3 additions & 1 deletion tool/src/org/antlr/v4/semantics/SemanticPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ public void process() {
ruleCollector.process(g.ast);

// DO BASIC / EASY SEMANTIC CHECKS
int prevErrors = g.tool.errMgr.getNumErrors();
BasicSemanticChecks basics = new BasicSemanticChecks(g, ruleCollector);
basics.process();
if ( g.tool.errMgr.getNumErrors()>prevErrors ) return;

// TRANSFORM LEFT-RECURSIVE RULES
int prevErrors = g.tool.errMgr.getNumErrors();
prevErrors = g.tool.errMgr.getNumErrors();
LeftRecursiveRuleTransformer lrtrans =
new LeftRecursiveRuleTransformer(g.ast, ruleCollector.rules.values(), g);
lrtrans.translateLeftRecursiveRules();
Expand Down

0 comments on commit dc2c9b0

Please sign in to comment.