[antlr-interest] Duplicate members when generating code with 2 import levels in Java with ANTLR-3.1.1

Terence Parr parrt at cs.usfca.edu
Mon Oct 27 14:34:08 PDT 2008


You are importing a grammar more than once into C.  probably not what  
you want; the error is correct I guess.
Ter
On Oct 27, 2008, at 2:30 PM, Laurent Caillette wrote:

> Hi all,
>
> Here is a composite grammar C which imports parser P2 which imports  
> parser P1:
>
> - - - - - - - - - - - - - - - - - -
> lexer grammar L ;
>
> LETTER : 'a'..'z' ;
> SPACE : ' ' ;
>
> - - - - - - - - - - - - - - - - - -
> parser grammer P1 ;
>
> letter : LETTER ;
> spaces : SPACE+ ;
>
> - - - - - - - - - - - - - - - - - -
> parser grammer P2 ;
> import P1 ;
>
> letters : letter+ ;
>
> - - - - - - - - - - - - - - - - - -
> grammar C ;
> import L, P1, P2 ;
>
> stuff : ( letters spaces )+ ;
>
> - - - - - - - - - - - - - - - - - -
>
>
> Generating code with ANTLR-3.1.1 I get this in CParser.java:
>
>    // delegates
>    public C_P1 gP1;
>    public C_P2_P1 gP1;
>    public C_P2 gP2;
>
> Ooops ! gP1 appears twice and causes compilation errors.
>
> Regards,
>
> c.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



More information about the antlr-interest mailing list