[antlr-interest] Java doesn't find class definition

Johannes Luber jaluber at gmx.de
Wed Apr 4 06:27:17 PDT 2007


mblp at mega.ist.utl.pt wrote:
> As for eclipse, all required classes should be on the project's build
> path - this includes jars also, as well as a JDK. You must've ment
> that eclipse doesn't run the Test class, no?

I've included the ANTLR-jars in the project properties already.
Interestingly Eclipse doesn't complain about other ANTLR exclusive stuff.

> As for "java Test", that only works if you are in your project's bin
> directory (the dir with the .class files), and you do not use jars,
> which of course you should use, if you are using antlr.
> 
> you should type "java -classpath
> path/to/build/dir;path/to/jar1.jar;path/to/jar2.jar;... Test
> the java command should know where are the .class files(wheter in a
> dir or in a jar) that it should search in order to run things; that's
> why you need to pass all referenced jars to classpath parameter.

I've tested it with my specific paths and it worked, until I entered ^Z.

"^Z
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
        ruleNestingLevel cannot be resolved
        ruleNestingLevel cannot be resolved
        The method emit(Token) in the type Lexer is not applicable for
the arguments (int, int, int, int, int, int)
        ruleNestingLevel cannot be resolved

        at ExprLexer.mID(ExprLexer.java:204)
        at ExprLexer.mTokens(ExprLexer.java:603)
        at org.antlr.runtime.Lexer.nextToken(Lexer.java:109)
        at
org.antlr.runtime.CommonTokenStream.fillBuffer(CommonTokenStream.java
:95)
        at
org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:238)
        at ExprParser.prog(ExprParser.java:59)
        at Test.main(Test.java:27)

I've searched the source for ANTLR for ruleNestingLevel. The only
references were in ActionTranslationLexer.java and in the target .stgs.
The class Lexer itself doesn't contain a definition, as the other files
do. Did I stumble over an ANTLR bug which hasn't been noticed by anyone
else? If yes, then Eclipse does work correctly.

Thanks again,
Johannes Luber


More information about the antlr-interest mailing list