I have a simple HelloWorld.g4
grammar (see it at the bottom). I am able to successfully generate the .py
files using this:
set CLASSPATH=.;antlr-complete.jar;%CLASSPATH%
java org.antlr.v4.Tool -Dlanguage=Python2 HelloWorld.g4
Now I would like to use the TestRig
with the -gui
flag to generate a parse tree GUI. I have the ANTRL Python runtime installed (antlr4-python2-runtime-4.5.tar.gz
). I can open a Python interpreter and type:
import antlr4
and the interpreter recognizes the antlr4
module.
When I run the TestRig
like this:
set CLASSPATH=.;antlr-complete.jar;%CLASSPATH%
java org.antlr.v4.gui.TestRig HelloWorld message -gui < input.txt
I get this error message:
Can't load HelloWorld as lexer or parser
From my investigations I have found several posts listing the same error message. However, in those cases they forgot to include period (.) in their classpath. But as you can see, I have included it in my classpath.
I'm out of ideas on how to get the TestRig
to work. Note: I have no problem getting the TestRig
to work with the same HelloWorld
grammar when the target language is Java.
Any help you can provide would be greatly appreciated.
HelloWorld.g4
grammar HelloWorld;
options { language=Python; }
message : GREETING NAME;
GREETING : 'Hello' ;
NAME : [a-zA-Z]+ ;
WS : [
]+ -> skip ;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…