Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

It is possible to use both global and local (rule-level) scopes together in ANTLR v3 but you have to get the order right: global scopes come after local scope but before @init.

grammar Foo;

scope GlobalOne {
    int c;
}

myrule
scope { 
    bool localFlag; 
}
scope GlobalOne;
@init {
    /* your stuff here */ 
}
    : case1
    | case2
    ;

(Adapted from mailing list post by Jim Idle)

  • No labels