[antlr-interest] Dynamic scopes with C backend

Jim Idle jimi at temporal-wave.com
Mon Feb 25 08:27:57 PST 2008


Yes - the after section isn't quite working correctly in conjunction 
with scopes. However, you dont really need to use the @after section 
to be honest, it is just a semi-convenience. Just enclose your main alts 
as ( ) and issue an action after it. I have it on my list of 3.1 things 
to fix.

Jim




> -----Original Message-----
> From: Dan S. [mailto:compilers at gmail.com]
> Sent: Monday, February 25, 2008 2:24 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Dynamic scopes with C backend
> 
> I have a rule which looks like the following:
> 
> rule
> scope {
>     char *foo;
> }
> @init {
>     $rule::foo = 0;
> }
> @after {
>     if ($rule::foo) free($rule::foo);
> }
> ...
> 
> This code segfaults because the scope is popped before the @after
> section is executed. The ANTLR Reference books seems to indicate that
> it is valid to reference scope variables in an @after section (example
> on page 140), so this looks like a bug.
> 
> Also, I'm sorry if this issue was addressed already, but I don't know
> if there is an easy way to search all the mailing list archives. The
> archives page has all the messages grouped by month and I'm not going
> to do a search month by month.
> 
> Dan.




More information about the antlr-interest mailing list