Richard Thrippleton wrote:
Alexandre Hamez wrote:
prog : stat ;
stat returns [ foo f ] : 'BAZ' ;
WS : (' '|'\t'|'\n'|'\r')+
{$channel=HIDDEN;} ;
(foo is a C++ struct)
the generated C code is:
static foo
stat(pgParser ctx)
{
foo f = NULL;
...
}
It raises an error at compilation since foo cannot be affected a NULL
pointer.
Is there a way to specify that the 'f' variable in the 'stat' rules
should be initialized with a specific value?
This issue has been covered before, see
http://groups.google.com.ai/group/il-antlr-interest/browse_thread/thread/7732954d2c38a918
The quick summary is that non-primitive types as return types are not
officially supported, you'd have to return a pointer to foo.
When I encountered this issue myself, I hacked up the C code generation
template (C.stg) in the antlr tool to simply omit this initialisation of
return values in generated code; I cannot guarantee that this is the
"correct" solution, but it worked for me(tm).
Yeah - you cannot do this because then checks for the presence or
absence of things fail unless you explicitly initialize them or create
flags. There are other reasons what that cannot be a generic fix
unfortunately.
Jim
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address