[antlr-interest] "type cannot be resolved or is not a field"

phil jones interstar at gmail.com
Mon Sep 12 15:28:26 PDT 2011


Hi everyone,

I don't know if this is a support list, so forgive me if I shouldn't
be asking this here. (If not here, where?)

I just downloaded and am trying to learn Antlr, starting with the
calculator example in the five minute guide. I've generated the Java
lexer / parser, but when I try to compile these I'm getting the error
:

"type cannot be resolved or is not a field"

The error occurs in the line " this.type = _type;"

in a generated block :

    // $ANTLR start PLUS
    public final void mPLUS() throws RecognitionException {
        try {
            int _type = PLUS;
            // SimpleCalc.g:3:6: ( '+' )
            // SimpleCalc.g:3:8: '+'
            {
            match('+');

            }

            this.type = _type;
        }
        finally {
        }
    }
    // $ANTLR end PLUS

That's in the class SimpleCalcLexer which extends Lexer. So can it be
that Lexer doesn't have a "type" attribute? Should it have one?

I generated the lexer code from the command line, but am now trying to
compile it in Processing. (I put the antlr3.3 jar in the Processing
libraries directory.)

cheers

phil jones


More information about the antlr-interest mailing list