Saturday, April 7, 2018


Source code:

(I am using GIT bash)
on Windows:
export CLASSPATH=/d/pierre/downloads/antlr/antlr-4.0-complete.jar:.
alias antlr="java -jar /d/pierre/downloads/antlr/antlr-4.0-complete.jar"
alias grun='java org.antlr.v4.runtime.misc.TestRig'

on Linux
export CLASSPATH=/home/centos/antlr/antlr-4.0-complete.jar:.
alias grun='java -cp /home/centos/antlr/antlr-4.0-complete.jar:. org.antlr.v4.runtime.misc.TestRig'

grun Hello r -tokens

I could not find which EOF key to press on Windows (it's CTRL-D in Linux).

If more people knew how to write a grammar and a parser, we probably would not be wasting so much of our life manually sorting horrendous Maven pom.xml files, or hacking HTML pages embedded with all sort of obscure hocus-pocus additions, or even typing unreadable GIT commands to undo a commit.

But we don't want to be monkeys, we want to learn the fundamentals of our profession : elaborate languages to explain, in a clear concise and unambiguous way, what we expect from a computing machine.


If you get
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at org.antlr.v4.runtime.misc.TestRig.process(
at org.antlr.v4.runtime.misc.TestRig.main(

check this:

public Class<?>  [More ...] loadClass(String name, boolean resolve)
throws ClassNotFoundException
int i = name.lastIndexOf('.');
if (i != -1) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPackageAccess(name.substring(0, i));

and this

try {
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class);

At this point I am pretty hopeless.... just ignore this issue, when you run grun with parameters, it works.


No comments: