Antlr4.Codegen.OutputModelController.BuildNormalRuleFunction C# (CSharp) Method

BuildNormalRuleFunction() public method

public BuildNormalRuleFunction ( Rule r, RuleFunction function ) : void
r Antlr4.Tool.Rule
function Antlr4.Codegen.Model.RuleFunction
return void
        public virtual void BuildNormalRuleFunction(Rule r, RuleFunction function)
        {
            CodeGenerator gen = @delegate.GetGenerator();
            // TRIGGER factory functions for rule alts, elements
            GrammarASTAdaptor adaptor = new GrammarASTAdaptor(r.ast.Token.InputStream);
            GrammarAST blk = (GrammarAST)r.ast.GetFirstChildWithType(ANTLRParser.BLOCK);
            CommonTreeNodeStream nodes = new CommonTreeNodeStream(adaptor, blk);
            walker = new SourceGenTriggers(nodes, this);
            try
            {
                // walk AST of rule alts/elements
                function.code = DefaultOutputModelFactory.List(walker.block(null, null));
                function.hasLookaheadBlock = walker.hasLookaheadBlock;
            }
            catch (Antlr.Runtime.RecognitionException e)
            {
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine(e.StackTrace);
            }

            function.ctxType = @delegate.GetTarget().GetRuleFunctionContextStructName(function);

            function.postamble = RulePostamble(function, r);
        }