[antlr-interest] Apparent bug in antlr 3.1.1

Bill Cox bill at qswtools.com
Wed Dec 17 15:56:21 PST 2008


Hi Folks,

Working through the exercises in section 3.2 of TDAR, I get the following error,
compiling ExprParser.java:

 java org.antlr.Tool Expr.g
ANTLR Parser Generator  Version 3.1.1
javac ExprTest.java ExprLexer.java ExprParser.java
ExprParser.java:417: cannot find symbol
symbol  : method expr6()
location: class ExprParser
                     value = expr6();
                             ^
Note: ExprParser.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
make: *** [ETest.class] Error 1

By changing the java file as shown in the following diff, I was able
to build and run the example parser.

thoris:~/src/antlr bill$ diff ExprParser.java ExprParser.java.patched
1c1
< // $ANTLR 3.1.1 Expr.g 2008-12-17 15:43:40
---
> // $ANTLR 3.1.1 Expr.g 2008-12-17 15:35:34
417c417
<                      value = expr6();
---
> 		    value = expr6;  // removed parens before semicolon
461c461
< }
\ No newline at end of file
---
> }

It looks as if antlr 3.1.1 is making a method call where it should be
making a scalar variable reference to expr6, which is declared and assigned-to
in these lines:

>fgrep expr6 ExprParser.java
        int expr6 = 0;
                    expr6=expr();
                     value = expr6();

I looked on altlr.org for the machine-readable Expr.g file to check my
data-entry, and I didn't find it.

CAVEAT: I'm learning java and antlr at the same time here, and could
be wildly off base.

Comments?

Regards,
Bill


More information about the antlr-interest mailing list