Alexandre Hamez wrote:
Hello,

I've been using the C target for a few days. I haven't encounter any  
major problems, except this one:
if you take the following dummy grammar:
	
  
grammar g;
options { language = C; }
@parser::includes
{ #include "foo.hh" }

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?
No, you need to return pointers or references or things that otherwise can be NULL, or base types such as int etc. This is part of the ANTLR internals, but also the return for a rule is already a struct (depending on your codegen options). You can find lots of past posts on this one ;-)

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

Reply via email to