Sam Harwell wrote:

Maybe @scopeinit{...} is better?

 

My goal is to replace this:

 

attrScope

scope

{

        Dictionary<GrammarAST, GrammarAST> actions;

}

@init

{

        $attrScope::actions = new Dictionary<GrammarAST, GrammarAST>();

}

        :       ^( 'scope' name=ID attrScopeAction* attrs=ACTION )

                {

                        AttributeScope scope = grammar.defineGlobalScope($name.text,$attrs.token);

                        scope.isDynamicGlobalScope = true;

                        scope.addAttributes($attrs.text, ';');

                        foreach ( var action in $attrScope::actions )

                                scope.DefineNamedAction( action.Key, action.Value );

                }

        ;

 

With this:

 

attrScope

scope

@init // or @scopeinit?

{

        actions = new Dictionary<GrammarAST, GrammarAST>();

}

{

        Dictionary<GrammarAST, GrammarAST> actions;

}

I am not sure why this is of any advantage? What limitation are you trying to get around? Choosing where to initialize a global scope or something? This change will generate work for all other targets and the syntactic change potentially generates confusion, especially if it is left at @init. In C, I have some macros such as SCOPE_TOP(sname) for action code - perhaps I implemented these to get around some limitation that you are proposing a fix for? I no longer remember ;-)

Jim
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to