private static IEnumerable<Node> ParseChances(Node parentNode, string text) { string[] chances = chanceRx.Split(text); if(chances.Length < 2) return ParseTries(parentNode, text); ChanceNode chanceNode = new ChanceNode(parentNode, new Atts("Type", "Even")); foreach(string cur in chances) { CaseNode caseNode = new CaseNode(chanceNode, null); chanceNode.AddChild(caseNode); caseNode.AddChildren(ParseSingle(caseNode, cur)); } return Enumerations.One<Node>(chanceNode); }
private static IEnumerable<Node> ParseTries(Node parentNode, string text) { string[] tries = tryRx.Split(text); if(tries.Length < 2) return ParseSingle(parentNode, text); TryNode tryNode = new TryNode(parentNode, null); foreach(string cur in tries) { CaseNode caseNode = new CaseNode(tryNode, null); tryNode.AddChild(caseNode); caseNode.AddChildren(ParseSingle(caseNode, cur)); } return Enumerations.One<Node>(tryNode); }