[antlr-interest] Using global and dynamic scopes together - is it possible?
Jim Idle
jimi at temporal-wave.com
Tue Feb 22 11:15:00 PST 2011
grammar t;
scope GlobalOne {
int c;
}
rulename
scope
{
bool localFlag;
}
scope GlobalOne;
@init
{
fred = 1;
}
: C ;
C : 'C';
Globals come after locals but before @init.
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Iron Bug
> Sent: Tuesday, February 22, 2011 11:02 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Using global and dynamic scopes together - is
> it possible?
>
> 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
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
More information about the antlr-interest
mailing list