[antlr-interest] Getting CMinus example to work

Mark van Assem mark at cs.vu.nl
Wed Nov 11 07:13:13 PST 2009


Hi,

I'm trying to get the CMinus example from the ANTLR reference book to 
work inside Eclipse (see [1,2]). I used ANTLRworks to generate java code 
for the lexer/parser and the tree walker. (This is all to get an idea 
about how to get my own grammar working.)

I imported the CMinusParser.java, CMinusLexer.java and CMinusWalker.java 
into Eclipse, and added the class TestCMinus.java, a test rig given in 
[3]. I run the code and enter the example input given in [4]. I then 
press CTLR-D/CTRL-Z to end the input file as normal in Eclipse [5], but 
the console does not react at all. I'm wondering whether there's a 
problem with the example or not. I am able to signal EOF in other programs.

I  also tried to compile the generated .java files on the command line, 
but failed:

javac -cp ./antlr-3.0.jar:./antlr-2.7.7.jar:./antlr-runtime-3.0.jar 
TestCMinus.java

gets me errors like "package org.antlr.runtime.tree does not exist". I 
tried the same thing with the antlrworks jar file, but that just starts 
ANTLRworks instead of compiling.

I'm obviously doing something stupid, but I've run out of options to try 
myself. Hope someone can help out this newbie...

Mark van Assem.


[1]http://media.pragprog.com/titles/tpantlr/code/trees/CMinus/CMinus.g
[2]http://media.pragprog.com/titles/tpantlr/code/trees/CMinus/CMinusWalker.g
[3]http://media.pragprog.com/titles/tpantlr/code/trees/CMinus/TestCMinus.java
[4]http://media.pragprog.com/titles/tpantlr/code/trees/CMinus/t.cm
[5]http://archive.eclipse.org/eclipse/downloads/drops/R-3.1-200506271435/eclipse-news-part1c.html
-- 
  Mark van Assem - Vrije Universiteit Amsterdam
            http://www.cs.vu.nl/~mark


More information about the antlr-interest mailing list