public PlusBlockAST(PlusBlockAST node) : base(node) { _greedy = node._greedy; }
protected virtual GrammarAST ExpandOptionalQuantifiersForAlt(GrammarAST alt) { if (alt.ChildCount == 0) { return null; } if (alt.GetChild(0).Type == ANTLRParser.OPTIONAL) { GrammarAST root = (GrammarAST)adaptor.Nil(); GrammarAST alt2 = alt.DupTree(); alt2.DeleteChild(0); if (alt2.ChildCount == 0) { adaptor.AddChild(alt2, adaptor.Create(ANTLRParser.EPSILON, "EPSILON")); } alt.SetChild(0, alt.GetChild(0).GetChild(0)); if (alt.GetChild(0).Type == ANTLRParser.BLOCK && alt.GetChild(0).ChildCount == 1 && alt.GetChild(0).GetChild(0).Type == ANTLRParser.ALT) { GrammarAST list = (GrammarAST)adaptor.Nil(); foreach (object tree in ((GrammarAST)alt.GetChild(0).GetChild(0)).Children) { adaptor.AddChild(list, tree); } adaptor.ReplaceChildren(alt, 0, 0, list); } adaptor.AddChild(root, alt); adaptor.AddChild(root, alt2); return root; } else if (alt.GetChild(0).Type == ANTLRParser.CLOSURE) { GrammarAST root = (GrammarAST)adaptor.Nil(); GrammarAST alt2 = alt.DupTree(); alt2.DeleteChild(0); if (alt2.ChildCount == 0) { adaptor.AddChild(alt2, adaptor.Create(ANTLRParser.EPSILON, "EPSILON")); } PlusBlockAST plusBlockAST = new PlusBlockAST(ANTLRParser.POSITIVE_CLOSURE, adaptor.CreateToken(ANTLRParser.POSITIVE_CLOSURE, "+"), null); for (int i = 0; i < alt.GetChild(0).ChildCount; i++) { plusBlockAST.AddChild(alt.GetChild(0).GetChild(i)); } alt.SetChild(0, plusBlockAST); adaptor.AddChild(root, alt); adaptor.AddChild(root, alt2); return root; } return alt; }