[antlr-interest] Bug in ANTLR-3.1.2 with tree grammar wildcard list label x+= ?
Laurent Caillette
laurent.caillette at gmail.com
Fri Feb 27 16:07:56 PST 2009
Hi all,
I attempted to switch to ANTLR-3.1.2, and the Java code generated from
my grammar doesn't compile anymore.
I've something like this:
part
: ( mediumbreak | largebreak )?
( p += levelIntroducer
| p += paragraph
| p += blockQuote
| p += literal
| p += bigDashedListItem
| p += cellRowSequence
)
( largebreak (
p += levelIntroducer
| p += paragraph
| p += blockQuote
| p += literal
| p += bigDashedListItem
| p += cellRowSequence
) )*
( mediumbreak | largebreak )?
EOF
-> ^( PART $p+ )
;
Here is a piece of generated code:
switch (alt2) {
case 1 :
//
/Users/Shared/Novelang/src/antlr/Novelang.g:120:9: p+= levelIntroducer
{
pushFollow(FOLLOW_levelIntroducer_in_part485);
p=levelIntroducer();
And the compiler doesn't like generated code, it spits errors like this:
/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.
This happens consistently using ANTLRWorks-1.2.3 or antlr-3.1.2.jar directly.
In ANTLR-3.1.2 release notes there is something about the += operator:
<< Bug in code gen for tree grammar wildcard list label x+=. >>
Could my problem be related to this, or should I investigate some more?
Regards,
c.
P.S. The whole grammar can be found at :
http://github.com/caillette/novelang/raw/ef85822091680f3bca06ddc511386ec39fdb8b75/src/antlr/Novelang.g
More information about the antlr-interest
mailing list