[antlr-interest] Bug in dynamic scopes in C target

Kay Röpke kroepke at classdump.org
Sat Mar 28 10:32:46 PDT 2009


Hi Jim!

I've noticed that the a rule like this will crash when targetting C  
(ANTLR 3.1.3):

rule
@scope { int foo; }
@after { $rule::foo = 1; }
: 'bar';

It's ok with Java and is due to the order of clean up performed at  
rule exit (the @after action will deref the freed scope top).
See the templates rule(), ruleCleanUp() and scopeClean() in C.stg.

It's probably very simple to fix by making ruleCleanUp() not call  
scopeClean() directly, but only do it after the @after action is done.
That is what Java.stg does.

I'll work around it for the time being by tweaking the template :)

cheers,
-k

P.S.: I haven't checked any other targets, so the other authors might  
want to check with theirs :)


More information about the antlr-interest mailing list