[antlr-interest] Error in generated C code (struct referenced without being initialized)

Andy Grove andy.grove at codefutures.com
Tue Feb 3 09:01:04 PST 2009


Hi Jim,

I have further info on this now. Here's the relevant portion of grammar. The
"a1" is optional but is always referenced in the action. This works fine
when generating Java code from the grammar (the action gets passed a NULL
parameter for "a1"). The generated C code has a NULL check for a1.start just
like the generated Java code does, but because a1.start is never initialized
in C it blows up.

| e = expression
            ( a1 = alias1  )?
        { sse.addSelectItem($e.text, $a1.text); }

Would it be possible to modify the generator to initialize these variables
to sensible defaults e.g. NULL for compatibility with the Java generator?

Alternatively, how could I modify the grammar to check if a1 is NULL or not?

Thanks,

Andy.


On Tue, Feb 3, 2009 at 9:50 AM, Jim Idle <jimi at temporal-wave.com> wrote:

> I have never known the initialization code not to be initialized - can
> you provide a grammar sample that shows this? It is usually grammar
> samples rather than the generated code that i need to reproduce things :-)
>
> Jim
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090203/ad3eaaaa/attachment.html 


More information about the antlr-interest mailing list