[antlr-interest] Apparent problem with dynamic scopes in C target

Daniel Jensen daniel.jensen at level3.com
Tue Mar 31 09:29:11 PDT 2009


Richard Thrippleton wrote:
> Daniel Jensen wrote:
>   
>> Hi folks,
>>
>>     
> <snip>
>   
>> extractFn scope ExprScope;
>> @init {
>>     if (exprScopeDepth++ == 0)
>>         $ExprScope::in_extract = 0;
>>     else
>>         $ExprScope::in_extract = $ExprScope[-1]::in_extract;
>> }
>>     
> I'm not sure if this is the cause of your bug, but the C code generated 
> by $ExprScope[-1]::in_extract in the current release will not be 
> reliable as it uses the underlying stack size to calculate the offset 
> (see http://www.antlr.org/pipermail/antlr-interest/2009-March/033760.html).
>
> Try the latest development build (linked in the reply to the above 
> message), see if this clears your problem up.
>   

Yes, this looks like the problem, but I think we need a new libantlr3c 
to fix it.  I used the jar file you referred to but, other than a couple 
of dates and version numbers in comments, the generated parser was the 
same as before.

> On another note, I will admit to being slightly baffled by 
> 'exprScopeDepth' - is it correct that it's only ever incremented?
>   

Er, yeah ... I'm sure I would have noticed that eventually. :-/  Just 
pretend that there are @after actions that decrement exprScopeDepth 
following the @init actions that increment it.

> Richard
>   

Thanks for your help, Richard.  Much appreciated.

Daniel


More information about the antlr-interest mailing list