[antlr-interest] Possible bug in Java grammar (all versions)?

William Bland wjb at abstractnonsense.com
Tue Mar 1 17:32:51 PST 2005

Unless I'm doing something particularly stupid (wouldn't be the first
time!), the following code seems to tickle a bug in the ANTLR parser
generated from every Java grammar that I could find:

=== Begin Java code ===
package com.foo;

public class Example {
    public Example() {
        System.out.println("ANTLR will not descend to this node in the
AST, unless the above call to super is commented out!");
=== End Java code ===

I added logging calls to each method in the generated
JavaTreeParser.java so I could see what was happening.  With the above
code, the parser appeared to fail to descend to the System.out.println
node of the AST - it only did so if I removed, or commented-out the call
to super().

Am I misunderstanding something, or is this a bug?  I tried using the
Java1.3, Java1.4 and both Java1.5 grammars from the ANTLR website, and I
am using ANTLR version 2.7.5.

Thanks for your help.
Best wishes,
It turns out that while it's easy to undo technical mistakes, it's not
as easy to undo personality disorders.        (Linus Torvalds)

More information about the antlr-interest mailing list