[antlr-interest] C Target code generation of ANTLR 3.4 does not set ALL the rule variables to NULL

Jim Idle jimi at temporal-wave.com
Sat Oct 1 10:17:58 PDT 2011


It is by design, to prevent trying to assign NULL to things that are not
pointers. See endless emails about it from years ago ;)


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Adrian Pop
> Sent: Saturday, October 01, 2011 4:25 AM
> To: antlr-interest at antlr.org; Adrian Pop
> Subject: [antlr-interest] C Target code generation of ANTLR 3.4 does
> not set ALL the rule variables to NULL
>
> Hi all,
>
> It seems that the ANLTR 3.4 code generation for C target does not set
> ALL the rule variables to NULL.
> ANTLR 3.2 does set all of them to NULL.
>
> Example:
> type_specifier returns [void* ast] :
>     np=name_path
>     (lt=LESS ts=type_specifier_list gt=GREATER)? (as=array_subscripts)?
>       {
>         if (ts != NULL) {
> ....
>
> In ANTLR 3.4 only the variables: "lt" and "gt" are set to NULL at the
> beginning of the rule. In ANTLR 3.2 code generation all the variables
> "np", "lt", "ts", "gt", "as" are set to NULL at the rule start.
>
> This is rather annoying as suddenly things that worked fine with ANTLR
> 3.2 do not work anymore with ANTLR 3.4 (seg fault).
>
> Is this a bug or is like this by design and we will need to set the
> variables to NULL via @init or { scope } at the start of the rule?
>
> Cheers,
> Adrian Pop/
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list