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); }
public override void SuffixAlt(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); string altText = Text(altTree); altText = altText.Trim(); LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, label, altLabel, isListLabel, originalAltTree); suffixAlts[alt] = a; // System.out.println("suffixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public override void OtherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.DupTree(); StripAltLabel(altTree); string altText = Text(altTree); string altLabel = altTree.altLabel != null ? altTree.altLabel.Text : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.Add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public override void PrefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.DupTree(); StripAltLabel(altTree); int nextPrec = Precedence(alt); // rewrite e to be e_[prec] altTree = AddPrecedenceArgToRules(altTree, nextPrec); string altText = Text(altTree); altText = altText.Trim(); string altLabel = altTree.altLabel != null ? altTree.altLabel.Text : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.Add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public override void OtherAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.DupTree(); StripAltLabel(altTree); string altText = Text(altTree); string altLabel = altTree.altLabel != null ? altTree.altLabel.Text : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); // We keep other alts with prefix alts since they are all added to the start of the generated rule, and // we want to retain any prior ordering between them prefixAndOtherAlts.Add(a); // System.out.println("otherAlt " + alt + ": " + altText); }
public override void SuffixAlt(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); string altText = Text(altTree); altText = altText.Trim(); LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, label, altLabel, isListLabel, originalAltTree); suffixAlts[alt] = a; // System.out.println("suffixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
public override void PrefixAlt(AltAST originalAltTree, int alt) { AltAST altTree = (AltAST)originalAltTree.DupTree(); StripAltLabel(altTree); int nextPrec = Precedence(alt); // rewrite e to be e_[prec] altTree = AddPrecedenceArgToRules(altTree, nextPrec); string altText = Text(altTree); altText = altText.Trim(); string altLabel = altTree.altLabel != null ? altTree.altLabel.Text : null; LeftRecursiveRuleAltInfo a = new LeftRecursiveRuleAltInfo(alt, altText, null, altLabel, false, originalAltTree); a.nextPrec = nextPrec; prefixAndOtherAlts.Add(a); //System.out.println("prefixAlt " + alt + ": " + altText + ", rewrite=" + rewriteText); }
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); }