[antlr-interest] Antlr-3.2: Expr.g example execution help
Mukkaysh Srivastav
srimks11 at gmail.com
Tue Dec 8 22:31:48 PST 2009
Hello,
I did install antlr-3.2 on Linux x86_64 as below -
I. Antlr-3.2 Installation:
1. mkdir antlr
2. Downloaded source code (antlr source distribution) from *
http://antlr.org/download.html* in above antlr folder/PATH.
3. Untarred the source distribution using “tar -zvxf
antlr-3.2.tar.gz” and did get -
antlr-3.2/BUILD.txt antlr-3.2/antlr3-maven-plugin antlr-3.2/antlrjar.xml antlr-3.2/antlrsources.xml antlr-3.2/gunit antlr-3.2/gunit-maven-plugin antlr-3.2/pom.xml antlr-3.2/runtime antlr-3.2/tool
4. mkdir antlr-toolchain
5. cd antlr-toolchain (copy antlr-3.2.jar here)
6. jar -xvf antlr-3.2.jar
ABOVE COMPLETES INSTALLATION.
II. Running a tutorial Expr.g & Test.java as posted in
http://www.antlr.org/wiki/display/ANTLR3/Expression+evaluator
1. In top folder of antlr as created above, I create a folder "mkdir
examples" and do copy Expr.g and Test.java here
2. Perform below -
- export
CLASSPATH=/home/mukkaysh/antlr/antlr-toolchain
- Copy the grammar example (Expr.g & Test.java) from
*http://www.antlr.org/wiki/display/ANTLR3/Expression+evaluator*
- Using command "java org.antlr.Tool Expr.g"
generates Lexer (.java), Parser (.java) & Tokens files.
- Using command "javac Test.java ExprLexer.java
ExprParser.java" generates class files. but with below message -
-----
[user]$ javac Test.java ExprLexer.java
ExprParser.java
Note: ExprParser.java uses unchecked or unsafe
operations.
Note: Recompile with -Xlint:unchecked for details.
-----
As, uses of -Xlint generates all warnings, did try as below -
[user]$ javac Test.java ExprLexer.java
ExprParser.java -Xlint
ExprParser.java:179: warning: [unchecked] unchecked
call to put(K,V) as a member of the raw type java.util.HashMap
memory.put((ID2!=null?ID2.getText():null), new
Integer(expr3));
^
1 warning
----
I believe this warnings are not so important, but when I do -
----
[user]$ ls
Expr.g ExprLexer.class ExprLexer.java ExprParser.class
ExprParser.java Expr.tokens Test.class Test.java
[user]$ java Test
Exception in thread "main" java.lang.NoClassDefFoundError:
Test
Caused by: java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native
Method)
at
java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
Could not find the main class: Test. Program will exit.
-----
I get above execution error messages.
I am totally newbie to ANTLR and Java. Any clue for above warnings and final
execution of Test file.
~BR
-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091209/ab864314/attachment.html
More information about the antlr-interest
mailing list