SingaporeLinguist SingaporeLinguist - 4 months ago 33
Bash Question

ANTLR Warning: TestRig moved to org.antlr.v4.gui.TestRig

I have been trying to get ANTLR to work all day. I have used several websites including antlr.org, numerous StackOverflow queries and the textbook by Terence Parr. I am on a Windows 7 machine (work machine, can't change to Linux) but I have tried this on both CommandPrompt and Cygwin, with the same result.

No matter what I do, when it comes time to use the grun file, I always come up with the same error in the end:


Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Can't load Hello as lexer or parser


I have the most recent versions of the JRE and JDK on my computer, as well as the most recent version of cygwin.

I can run the batch files for grun and antlr4 from anywhere, so I'm strongly guessing my path is set correctly. I can run antlr4.bat with absolutely no issue. It creates every file the text book says I should see:

Hello.g4 HelloBaseListener.java HelloLexer.tokens HelloParser.java Hello.tokens HelloLexer.java HelloListener.java


I can run javac on those files and it generates various CLASS files:

HelloBaseListener.class HelloLexer.class HelloListener.class HelloParser$RContext.class HelloParser.class


But then, when I try to run grun on it, I get this:


Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Can't load Hello as lexer or parser


I've tried several combinations of commands to use the grun file, but the one it says to use in the book is:

grun.bat Hello r -tree


I've also changed the .bat file with grun several times, just to experiment, using different combinations in the books and on the sites, but I always come back to this:

java org.antlr.v4.runtime.misc.TestRig %*


That is what my boss told me to use, and it works for him.

Answer

Use this in your grun.bat command

java org.antlr.v4.gui.TestRig %*
Comments