Пример #1
0
        private void HandleBlockInit(string blockTemplateName, Antlr3.Analysis.DFA dfa, ref Template code, out int altNum)
        {
            altNum = 0;
            blockNestingLevel++;

            if (state.backtracking == 0)
            {
                Template decision = null;
                if (dfa != null)
                {
                    code = templates.GetInstanceOf(blockTemplateName);
                    decision = generator.GenLookaheadDecision(recognizerST, dfa);
                    code.SetAttribute("decision", decision);
                    code.SetAttribute("decisionNumber", dfa.NfaStartStateDecisionNumber);
                    code.SetAttribute("maxK", dfa.MaxLookaheadDepth);
                    code.SetAttribute("maxAlt", dfa.NumberOfAlts);
                }
                else
                {
                    code = templates.GetInstanceOf(blockTemplateName + "SingleAlt");
                }
                code.SetAttribute("blockLevel", blockNestingLevel);
                code.SetAttribute("enclosingBlockLevel", blockNestingLevel - 1);
                altNum = 1;
                if (this.blockNestingLevel == RULE_BLOCK_NESTING_LEVEL)
                {
                    this.outerAltNum = 1;
                }
            }
        }
Пример #2
0
 private void HandleRuleInit(GrammarAST start, out string initAction, out GrammarAST block2, out Antlr3.Analysis.DFA dfa, out Rule ruleDescr, out string description)
 {
     initAction = null;
     // get the dfa for the BLOCK
     block2 = (GrammarAST)start.GetFirstChildWithType(BLOCK);
     dfa = block2.LookaheadDFA;
     // init blockNestingLevel so it's block level RULE_BLOCK_NESTING_LEVEL
     // for alts of rule
     blockNestingLevel = RULE_BLOCK_NESTING_LEVEL - 1;
     ruleDescr = grammar.GetRule(start.GetChild(0).Text);
     currentRuleName = start.GetChild(0).Text;
     description = string.Empty;
 }