Antlr4.Analysis.LeftRecursiveRuleTransformer.SetAltASTPointers C# (CSharp) Method

SetAltASTPointers() public method

public SetAltASTPointers ( LeftRecursiveRule r, RuleAST t ) : void
r Antlr4.Tool.LeftRecursiveRule
t Antlr4.Tool.Ast.RuleAST
return void
        public virtual void SetAltASTPointers(LeftRecursiveRule r, RuleAST t)
        {
            //System.Console.WriteLine("RULE: " + t.ToStringTree());
            BlockAST ruleBlk = (BlockAST)t.GetFirstChildWithType(ANTLRParser.BLOCK);
            AltAST mainAlt = (AltAST)ruleBlk.GetChild(0);
            BlockAST primaryBlk = (BlockAST)mainAlt.GetChild(0);
            BlockAST opsBlk = (BlockAST)mainAlt.GetChild(1).GetChild(0); // (* BLOCK ...)
            for (int i = 0; i < r.recPrimaryAlts.Count; i++)
            {
                LeftRecursiveRuleAltInfo altInfo = r.recPrimaryAlts[i];
                altInfo.altAST = (AltAST)primaryBlk.GetChild(i);
                altInfo.altAST.leftRecursiveAltInfo = altInfo;
                altInfo.originalAltAST.leftRecursiveAltInfo = altInfo;
                //altInfo.originalAltAST.Parent = altInfo.altAST.Parent;
                //System.Console.WriteLine(altInfo.altAST.ToStringTree());
            }
            for (int i = 0; i < r.recOpAlts.Count; i++)
            {
                LeftRecursiveRuleAltInfo altInfo = r.recOpAlts.GetElement(i);
                altInfo.altAST = (AltAST)opsBlk.GetChild(i);
                altInfo.altAST.leftRecursiveAltInfo = altInfo;
                altInfo.originalAltAST.leftRecursiveAltInfo = altInfo;
                //altInfo.originalAltAST.Parent = altInfo.altAST.Parent;
                //System.Console.WriteLine(altInfo.altAST.ToStringTree());
            }
        }
    }