Antlr3.Tool.Grammar.DefineNamedAction C# (CSharp) Method

DefineNamedAction() public method

public DefineNamedAction ( Antlr3.Tool.GrammarAST ampersandAST, string scope, Antlr3.Tool.GrammarAST nameAST, Antlr3.Tool.GrammarAST actionAST ) : void
ampersandAST Antlr3.Tool.GrammarAST
scope string
nameAST Antlr3.Tool.GrammarAST
actionAST Antlr3.Tool.GrammarAST
return void
        public virtual void DefineNamedAction( GrammarAST ampersandAST,
                                      string scope,
                                      GrammarAST nameAST,
                                      GrammarAST actionAST )
        {
            if ( scope == null )
            {
                scope = GetDefaultActionScope( type );
            }
            //[email protected]("@"+scope+"::"+nameAST.getText()+"{"+actionAST.getText()+"}");
            string actionName = nameAST.Text;
            IDictionary<string, object> scopeActions;
            Actions.TryGetValue(scope, out scopeActions);
            if ( scopeActions == null )
            {
                scopeActions = new Dictionary<string, object>();
                Actions[scope] = scopeActions;
            }

            object o;
            scopeActions.TryGetValue(actionName, out o);
            GrammarAST a = o as GrammarAST;
            if ( a != null )
            {
                ErrorManager.GrammarError(
                    ErrorManager.MSG_ACTION_REDEFINITION, this,
                    nameAST.Token, nameAST.Text );
            }
            else
            {
                scopeActions[actionName] = actionAST;
            }
            // propogate header (regardless of scope (lexer, parser, ...) ?
            if ( this == composite.RootGrammar && actionName.Equals( "header" ) )
            {
                IList<Grammar> allgrammars = composite.RootGrammar.GetDelegates();
                foreach ( Grammar @delegate in allgrammars )
                {
                    if (target.IsValidActionScope(@delegate.type, scope))
                    {
                        //System.out.println("propogate to "+delegate.name);
                        @delegate.DefineNamedAction(ampersandAST, scope, nameAST, actionAST);
                    }
                }
            }
        }
Grammar