Antlr4.Analysis.LeftRecursiveRuleAnalyzer.BinaryAlt C# (CSharp) Method

BinaryAlt() public method

public BinaryAlt ( AltAST originalAltTree, int alt ) : void
originalAltTree AltAST
alt int
return void
        public override void BinaryAlt(AltAST originalAltTree, int alt)
        {
            AltAST altTree = (AltAST)originalAltTree.DupTree();
            string altLabel = altTree.altLabel != null ? altTree.altLabel.Text : null;

            string label = null;
            bool isListLabel = false;
            GrammarAST lrlabel = StripLeftRecursion(altTree);
            if (lrlabel != null)
            {
                label = lrlabel.Text;
                isListLabel = lrlabel.Parent.Type == PLUS_ASSIGN;
                leftRecursiveRuleRefLabels.Add(Tuple.Create(lrlabel, altLabel));
            }

            StripAltLabel(altTree);

            // rewrite e to be e_[rec_arg]
            int nextPrec = NextPrecedence(alt);
            altTree = AddPrecedenceArgToRules(altTree, nextPrec);

            StripAltLabel(altTree);
            string altText = Text(altTree);
            altText = altText.Trim();
            LeftRecursiveRuleAltInfo a =
                new LeftRecursiveRuleAltInfo(alt, altText, label, altLabel, isListLabel, originalAltTree);
            a.nextPrec = nextPrec;
            binaryAlts[alt] = a;
            //System.out.println("binaryAlt " + alt + ": " + altText + ", rewrite=" + rewriteText);
        }