Richard Thrippleton wrote:
> When I have a rule of the form
>
> "rule returns [std::vector<int> foo]
> ..."
>
> the generated code for that rule will start with
>
> "std::vector<int> foo = NULL;"
>
> which will (obviously) not compile. I've modified the relevant .stg to 
> prevent it generating initialisation code for return values (declaration 
> only), and not encountered any issues in my grammars thus far.
>   
Yeah - you can't really do that I think. ANTLR does not support very 
complex return type declarations and you are probably just "getting away 
with that". I believe I looked in to not initializing return variables 
and there is some reason that you cannot just disable that 
initialization, but it may just be the behavioral requirements of the 
return value for the rule reference. I do know that sometimes the 
complex declarations will fail though and it is better to use a typedef 
type. We could do with the ability to not initialize things that we 
don't know about really.

A better approach would be to return a pointer rather than the vector, 
or to pass in the reference as a parameter to the rule.

Jim

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to