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: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Iron Bug
> Sent: Tuesday, February 22, 2011 11:02 AM
> To: [email protected]
> 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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to