Пример #1
0
        public override Choice GetEBNFBlock(GrammarAST ebnfRoot, IList <CodeBlockForAlt> alts)
        {
            if (!g.tool.force_atn)
            {
                int decision;
                if (ebnfRoot.Type == ANTLRParser.POSITIVE_CLOSURE)
                {
                    decision = ((PlusLoopbackState)ebnfRoot.atnState).decision;
                }
                else if (ebnfRoot.Type == ANTLRParser.CLOSURE)
                {
                    decision = ((StarLoopEntryState)ebnfRoot.atnState).decision;
                }
                else
                {
                    decision = ((DecisionState)ebnfRoot.atnState).decision;
                }

                if (AnalysisPipeline.Disjoint(g.decisionLOOK[decision]))
                {
                    return(GetLL1EBNFBlock(ebnfRoot, alts));
                }
            }

            return(GetComplexEBNFBlock(ebnfRoot, alts));
        }
Пример #2
0
        public override Choice GetChoiceBlock(BlockAST blkAST, IList <CodeBlockForAlt> alts, GrammarAST labelAST)
        {
            int    decision = ((DecisionState)blkAST.atnState).decision;
            Choice c;

            if (!g.tool.force_atn && AnalysisPipeline.Disjoint(g.decisionLOOK[decision]))
            {
                c = GetLL1ChoiceBlock(blkAST, alts);
            }
            else
            {
                c = GetComplexChoiceBlock(blkAST, alts);
            }

            if (labelAST != null)
            { // for x=(...), define x or x_list
                string label = labelAST.Text;
                Decl   d     = GetTokenLabelDecl(label);
                c.label = d;
                GetCurrentRuleFunction().AddContextDecl(labelAST.GetAltLabel(), d);
                if (labelAST.Parent.Type == ANTLRParser.PLUS_ASSIGN)
                {
                    string        listLabel = GetTarget().GetListLabel(label);
                    TokenListDecl l         = new TokenListDecl(this, listLabel);
                    GetCurrentRuleFunction().AddContextDecl(labelAST.GetAltLabel(), l);
                }
            }

            return(c);
        }