[antlr-interest] Using global and dynamic scopes together - is it possible?

Iron Bug death.iron.bug at gmail.com
Tue Feb 22 11:02:20 PST 2011


Greetings.
I've been using ANTLR with C interface for a long time and it was ok,
but today I bumped into a problem:
I use global scope for certain rules and I sometimes use dynamic scopes
for minor local variables. And in one rule it happened the different
scopes have met each other. 
Something like:

rulename
scope GlobalOne;		
scope
{
	bool localFlag;
}
@init
{
	$GlobalOne::globalVariable = ....;
	...
	$rulename::localFlag = true;
}

And ANTLR does not eat that. Well, I'm not sure it's possible even.
Maybe I should use some different syntax? I tried some variants that
seemed reasonable to me, but failed. 
I don't know whether it is a problem of ANTLR itself or of the C
interface realization.
Can I use both variants of scopes in one rule?

I use ANTLR 3.3 with the latest shapshot version of the C interface
(libantlr3c-3.3-SNAPSHOT).

Just in case, the errors generated are like:

unexpected token: bool localFlag;

syntax error: expecting SEMI, found '@'

unknown dynamic scope: rulename



More information about the antlr-interest mailing list