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
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---