[antlr-interest] Bug in ANTLR-3.1.2 with tree grammar wildcard list label x+= ?
Gary R. Van Sickle
g.r.vansickle at att.net
Fri Feb 27 23:40:13 PST 2009
> From: Gavin Lambert
> Sent: Friday, February 27, 2009 6:17 PM
> To: Laurent Caillette; antlr-interest
> Subject: Re: [antlr-interest] Bug in ANTLR-3.1.2 with tree
> grammar wildcard list label x+= ?
>
> At 13:07 28/02/2009, Laurent Caillette wrote:
> >part
> > : ( mediumbreak | largebreak )?
> >
> > ( p += levelIntroducer
> > | p += paragraph
> > | p += blockQuote
> > | p += literal
> > | p += bigDashedListItem
> > | p += cellRowSequence
> > )
> [...]
> >/Users/Shared/Scratch/Novelang/antlrworks/java/NovelangParser.java:
> >754:
> >incompatible types
> >found : NovelangParser.levelIntroducer_return
> >required: NovelangParser.cellRowSequence_return
> > p=levelIntroducer();
> > ^
> >
> >It seems that p has taken the type of the first rule
> >(levelIntroducer). Then attempting to set the result of
> >cellRowSequence doesn't work.
>
> I'm surprised that you managed to get it to work as long as
> you did -- that's been on my list of "don't do that" for most of v3.
>
> You can fix it by creating a subrule:
>
> content
> : levelIntroducer
> | paragraph
> | blockQuote
> | literal
> | bigDashedListItem
> | cellRowSequence
> ;
>
> And then use p+=content in your original rule.
Bug or feature though? It seems inconsistent for what appear to be two
semantically equivalent constructs to be totally fine in the one case and a
silent failure in the other.
--
Gary R. Van Sickle
More information about the antlr-interest
mailing list