This is the first time I use Antlr4 and I have a question regarding to the test rig. I've finished the installation process and try out the sample given in both Antlr4 main site and the github page. Here's what I've done:
Installation:
/usr/local/lib$ sudo curl -O https://www.antlr.org/download/antlr-4.7.1-complete.jar
/usr/local/lib$ export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH"
/usr/local/lib$ alias grun='java org.antlr.v4.gui.TestRig'
I ran only antlr4 and grun to see if everything is installed properly:
$ antler4
ANTLR Parser Generator Version 4.7.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
.
.
$ grun
java org.antlr.v4.gui.TestRig GrammarName startRuleName
[-tokens] [-tree] [-gui] [-ps file.ps] [-encoding encodingname]
.
.
So went ahead and created an example Hello.g4
in /tmp
which looks like this
/// Define a grammar called Hello
grammar Hello;
r : 'hello' ID ; // match keyword hello followed by an identifier
ID : [a-z]+ ; // match lower-case identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
and ran:
$ antlr4 Hello.g4
$ javac Hello*.java
According to the example, it should at least return a gui of a tree and some output when I do grun Hello r -tree
However, when I did that, nothing happened. Just blinking cursor as if it's computing something. Kinda like this
/tmp/Hello$ grun Hello r -tree
|
Is something wrong with the Hello.g4 code or am I missing something during the installation or grun
just takes very long to finish compiling? I've also tried with several examples from the Antlr4 page, still got the same thing.
thank you for any response in advance.