[antlr-interest] [C Target] Multiple return parameters rule generation error.

Garry Iglesias garry.iglesias at gmail.com
Mon Aug 4 10:05:26 PDT 2008


Hi,

Sorry, I've already been reporting this... But it seems it's still there. So
I 'remind it' because it's important as a standard feature
of ANTLR (multiple returning parameters) that doesn't work for the C target.
I got a rule with return parameters :

myProblemRule returns [int i,int bIsRef]
   :  [...]
   ;

 myNoProblemRule returns [int i]
   :  [...]
   ;


When I use it :
myOtherRule
    :  [...]  good=myNoProblemRule  bad=myProblemRule
       {
             int ivar=$good.i;        -> This works...
             ivar=$bad.i;              -> This generates code that doesn't
compile...
             if ($bad.bIsRef)  {      -> This generates code that doesn't
compile...
             }
       }
    ;

Note "myBool" is just a typedef from an int...

So the fact is that ANTLR converts the 'if' into something like :
if (( result != NULL ? result.bIsRef : NULL )) {  [...]  }

Problem is that result is a local instantiated structure, and not a pointer
to a structure.

By the way, ANTLR is a very good tool.

Thanks.

Garry.

PS/ Sorry if my english is wrong as I'm french native.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080804/4986b288/attachment.html 


More information about the antlr-interest mailing list