diff --git a/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java b/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java index f85eb418e..ab544e188 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java +++ b/runtime/Java/src/org/antlr/v4/runtime/BaseRecognizer.java @@ -118,7 +118,7 @@ public abstract class BaseRecognizer extends Recognizer { * somebody's children list. Contexts are then not candidates * for garbage collection. */ - public void setBuildParseTrees(boolean buildParseTrees) { + public void setBuildParseTree(boolean buildParseTrees) { this.buildParseTrees = buildParseTrees; } diff --git a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java index eaff004d3..79dba4c29 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java +++ b/runtime/Java/src/org/antlr/v4/runtime/DefaultANTLRErrorStrategy.java @@ -110,7 +110,7 @@ public class DefaultANTLRErrorStrategy implements ANTLRErrorStrategy { TokenStream tokens = (TokenStream)recognizer.getInputStream(); Token la = tokens.LT(1); // Return but don't end recovery. only do that upon valid token match - if ( expecting.contains(la.getType()) ) return; + if ( la.getType()==Token.EOF || expecting.contains(la.getType()) ) return; reportUnwantedToken(recognizer); consumeUntil(recognizer, expecting); } diff --git a/tool/playground/TestAA.java b/tool/playground/TestAA.java index 520769cc8..3cbf34fef 100644 --- a/tool/playground/TestAA.java +++ b/tool/playground/TestAA.java @@ -7,7 +7,7 @@ public class TestAA { AALexer t = new AALexer(new ANTLRFileStream(args[0])); CommonTokenStream tokens = new CommonTokenStream(t); AAParser p = new AAParser(tokens); - p.setBuildParseTrees(true); + p.setBuildParseTree(true); RuleContext ctx = p.prog(); //System.out.println("ctx="+ctx.toStringTree(p)); } diff --git a/tool/playground/TestT.java b/tool/playground/TestT.java index bab28f232..e51a234e0 100644 --- a/tool/playground/TestT.java +++ b/tool/playground/TestT.java @@ -1,4 +1,6 @@ -import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.ANTLRFileStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ParseTreeWalker; public class TestT { @@ -10,7 +12,7 @@ public class TestT { // System.out.println(tok); // } TParser p = new TParser(tokens); - p.setBuildParseTrees(true); + p.setBuildParseTree(true); TParser.sContext tree = p.s(); System.out.println(tree.toStringTree(p)); diff --git a/tool/playground/TestU.java b/tool/playground/TestU.java index aed059905..fae378f6d 100644 --- a/tool/playground/TestU.java +++ b/tool/playground/TestU.java @@ -1,12 +1,15 @@ -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.tree.*; +import org.antlr.v4.runtime.ANTLRFileStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ASTNodeStream; +import org.antlr.v4.runtime.tree.CommonASTNodeStream; +import org.antlr.v4.runtime.tree.Tree; public class TestU { public static void main(String[] args) throws Exception { ULexer t = new ULexer(new ANTLRFileStream(args[0])); CommonTokenStream tokens = new CommonTokenStream(t); UParser p = new UParser(tokens); - p.setBuildParseTrees(true); + p.setBuildParseTree(true); UParser.aContext ctx = p.a(); System.out.println(((Tree) ctx.tree).toStringTree()); diff --git a/tool/playground/TestW.java b/tool/playground/TestW.java index a2ad66075..677c94f3d 100644 --- a/tool/playground/TestW.java +++ b/tool/playground/TestW.java @@ -7,7 +7,7 @@ public class TestW { WLexer t = new WLexer(new ANTLRFileStream(args[0])); CommonTokenStream tokens = new CommonTokenStream(t); WParser p = new WParser(tokens); - p.setBuildParseTrees(true); + p.setBuildParseTree(true); RuleContext ctx = p.s(); //System.out.println("ctx="+ctx.toStringTree(p)); }