[antlr-interest] hello, antlr on Ubuntu

Dan Kegel dank at kegel.com
Thu Dec 17 03:49:52 PST 2009

I was trying to do the commandline example from
and noticed it's slightly out of date; the line

HashMap memory = new HashMap();

needs to read

HashMap<String,Integer> memory = new HashMap<String,Integer>();

for recent java, else you get the error

ExprParser.java:163: warning: [unchecked] unchecked call to put(K,V)
as a member of the raw type java.util.HashMap
                    memory.put(ID2.getText(), new Integer(expr3));

Also, the user has to figure out the classpath himself (though I guess
that's normal for java development).
For reference, here are the complete list of steps needed to try out
that example on Ubuntu Jaunty:

Copy and paste the grammar and test program from
into Expr.g and Test.java, and modify Expr.g as described above

$ sudo apt-get install antlr3 openjdk-6-jdk
$ antlr3 Expr.g
$ javac -cp .:/usr/share/java/antlr3-3.0.1+dfsg.jar Test.java
ExprLexer.java ExprParser.java
$ java  -cp .:/usr/share/java/antlr3-3.0.1+dfsg.jar Test

Works like a charm.

More information about the antlr-interest mailing list