[antlr-interest] Bug report; SCOPE_SIZE returning incorrect result in the C runtime

Richard Thrippleton richard.thrippleton at progress.com
Mon Mar 30 02:52:52 PDT 2009


I was finding that SCOPE_SIZE(somescope) would report a scope size of 
'1' when inside a dynamic scope (correct), '0' before entering that 
scope (correct), but then '1' after leaving that scope (incorrect).

The issue seems to be that the 'size' method on a stack returns the 
amount of memory allocated for that stack, not the number of items in 
the stack. My workaround was to modify C.stg
"#define SCOPE_SIZE(scope)   ctx->p<name>_##scope##Stack_limit"

(note that I've only verified this in 3.1.2, though it seems to be the 
same in 3.1.3 based on a brief skim of the source)

Richard


More information about the antlr-interest mailing list