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

Loring Craymer lgcraymer at yahoo.com
Mon Oct 27 16:04:58 PDT 2008


Ter--

Just my 2 cents, but shouldn't duplicate imports be supported at the language level, as is true for Java, C#, and even C/C++ with the usual #ifdef wrapping?  It seems to me that leaving dependency management to the user limits the convenience of composition.

--Loring



----- Original Message ----
> From: Terence Parr <parrt at cs.usfca.edu>
> To: Laurent Caillette <laurent.caillette at gmail.com>
> Cc: antlr-interest Interest <antlr-interest at antlr.org>
> Sent: Monday, October 27, 2008 3:59:15 PM
> Subject: Re: [antlr-interest] Duplicate members when generating code with 2 import levels in Java with ANTLR-3.1.1
> 
> Hi, can you sign up for the wiki and make the changes yourself?
> Thanks!
> Ter
> On Oct 27, 2008, at 3:56 PM, Laurent Caillette wrote:
> 
> > Ok, thanks a lot. I was not fully aware of how imports were resolved.
> >
> > Terence, the sample I suggested is wrong, C should not import P1.
> > 
> http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars#CompositeGrammars-Legalimports
> >
> > I suggest to add a few words at the end of the introduction to explain
> > this behavior. Could be:
> > <<
> > [There is no need to copy any rules from the delegate grammars into
> > the root grammar.]
> > Because of this "whiteboard" approach, each grammar should be imported
> > only once. If B relies on rules in A, it should not import A if R
> > already imports B. Otherwise it would cause some duplicate members in
> > generated code.
> >>>
> >
> > Regards,
> >
> > c.
> >
> > http://novelang.sf.net
> >
> >
> > On Mon, Oct 27, 2008 at 10:34 PM, Terence Parr   
> > wrote:
> >> You are importing a grammar more than once into C.  probably not  
> >> what you
> >> want; the error is correct I guess.
> >
> >
> > On Mon, Oct 27, 2008 at 10:46 PM, Jim Idle   
> > wrote:
> >> You import P1 here and then in P2 you import P1 again, hence there  
> >> are two
> >> instances of P1 created and this is not allowed. Either do not  
> >> import P1 in
> >> P2, or just import P2 in C.
> >>
> >> Jim
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >
> 
> 
> 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