[antlr-interest] Q: Multiple global dynamic attribute scopes

Masashi Fujita objectxtreme+antlr at gmail.com
Wed Jul 23 10:51:47 PDT 2008


Hi!

Placing multiple global dynamic attribute scopes to a rule is allowed
or not ?  I've tried following grammar:

{{{

grammar ScopeTest ;

scope Scope1 {
    int	field_ ;
}
scope Scope2 {
    int	field_ ;
}

rule
    scope {
        int	s_ ;
    }
    scope Scope1 ;
    scope Scope2 ;
    : subrule
    ;

subrule
    : ID
    ;

ID
    : 'a'..'z' | 'A'..'Z'
    ;
}}}

ANTLR 3.1b2 generates codes without errors, but seems to forget
pushing "Scope1". Generated code fragment is following:

{{{
    public final void rule() throws RecognitionException {
        Scope2_stack.push(new Scope2_scope());
        rule_stack.push(new rule_scope());
        try {
}}}

Regards.


More information about the antlr-interest mailing list