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

Laurent Caillette laurent.caillette at gmail.com
Mon Oct 27 14:30:31 PDT 2008


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.


More information about the antlr-interest mailing list