Пример #1
0
        protected virtual void _CreateATN([NotNull] ICollection <Rule> rules)
        {
            CreateRuleStartAndStopATNStates();

            GrammarASTAdaptor adaptor = new GrammarASTAdaptor();

            foreach (Rule r in rules)
            {
                // find rule's block
                GrammarAST           blk   = (GrammarAST)r.ast.GetFirstChildWithType(ANTLRParser.BLOCK);
                CommonTreeNodeStream nodes = new CommonTreeNodeStream(adaptor, blk);
                ATNBuilder           b     = new ATNBuilder(nodes, this);
                try {
                    SetCurrentRuleName(r.name);
                    Handle h = b.ruleBlock(null);
                    Rule(r.ast, r.name, h);
                }
                catch (RecognitionException re) {
                    ErrorManager.FatalInternalError("bad grammar AST structure", re);
                }
            }
        }