I have a separated parser and lexer grammar and want to run org.antlr.v4.gui.TestRig
to debug/test my grammar.
My lexer grammar start with:
lexer grammar TestLexer;
IDS: [a-zA-Z];
WS: [ \t];
NL: [\r?\n];
...
and my parser grammar start with:
parser grammar TestParser;
options { tokenVocab=TestLexer; }
testRule: WS* IDS+ NL;
...
My classpath env variable points to complete antlr.jar
and current directory.
antlr
is an alias tojava org.antlr.v4.Tool
grun
is an alias tojava org.antlr.v4.gui.TestRig
.
When I run antlr TestParser.g4 && javac *.java
the parser code gets generated and compiled.
When I run grun TestParser testRule -gui
I get the error:
Exception in thread "main" java.lang.ClassCastException: class TestParser
at java.lang.Class.asSubclass(Class.java:3404)
at org.antlr.v4.gui.TestRig.process(TestRig.java:135)
at org.antlr.v4.gui.TestRig.main(TestRig.java:119)
And when I run grun Test testRule -gui
I get the error:
Can't load Test as lexer or parser
I don't have any problems when using a combined grammar.
What's missing in order to run TestRig
?