From bca63c64aaee014cfbbdb95de8eb637480fe251e Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Sun, 23 Sep 2012 18:05:31 -0700 Subject: [PATCH] the test rig did not allow lexer only grammars; a regression. --- .../src/org/antlr/v4/runtime/misc/TestRig.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java b/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java index ae8ff1e3b..6d0d68ee6 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java +++ b/runtime/Java/src/org/antlr/v4/runtime/misc/TestRig.java @@ -154,13 +154,18 @@ public class TestRig { Constructor lexerCtor = lexerClass.getConstructor(CharStream.class); Lexer lexer = lexerCtor.newInstance((CharStream)null); - String parserName = grammarName+"Parser"; - Class parserClass = cl.loadClass(parserName); - if ( parserClass==null ) { - System.err.println("Can't load "+parserName); + + Class parserClass = null; + Parser parser = null; + if ( !startRuleName.equals(LEXER_START_RULE_NAME) ) { + String parserName = grammarName+"Parser"; + parserClass = cl.loadClass(parserName); + if ( parserClass==null ) { + System.err.println("Can't load "+parserName); + } + Constructor parserCtor = parserClass.getConstructor(TokenStream.class); + parser = parserCtor.newInstance((TokenStream)null); } - Constructor parserCtor = parserClass.getConstructor(TokenStream.class); - Parser parser = parserCtor.newInstance((TokenStream)null); if ( inputFiles.size()==0 ) { InputStream is = System.in;