[antlr-interest] C target : default initialization to NULL
Alexandre Hamez
alexandre.hamez at gmail.com
Wed Apr 29 02:50:04 PDT 2009
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?
Thanks,
----------
Alexandre Hamez
alexandre.hamez at gmail.com
More information about the antlr-interest
mailing list