[antlr-interest] java grammar problems

Ray Waldin ray at waldin.net
Fri Sep 26 16:36:11 PDT 2003


Charles Zhang wrote:

>The interfaceBlock rule of the java.tree.g does not
>contain a typedefinition. It shouldn't anyways. It
>should just contain a interfaceDefinition.
>

Hi Charles,

According to 
http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html#236431 
an interface can contain both interface and class declarations, as in:

interface foo {
    class bar { }
    interface baz { }
}

>But I'm not
>a grammar expert and scared of making changes. Could
>you show me how to solve this problem? 
>  
>

To fix the java.tree.g grammar, just add typeDefinition to the 
interfaceBlock production so it looks like this:

interfaceBlock
    :    #(    OBJBLOCK
            (    methodDecl
            |    variableDef
            |    typeDefinition
            )*
        )
    ;

Hope that helps.

- Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20030926/8d0cceea/attachment.html


More information about the antlr-interest mailing list