private static Rule Parse(string rule) { var math = RuleRegex.Match(rule); if (!math.Success) { throw new InvalidOperationException($"Правило '{rule}' имеет неверный формат"); } var left = new NonTerminal(math.Groups["NonTerm"].Value.Single()); var right = math.Groups["Right"].Value.Select(s => char.IsUpper(s) ? (Symbol) new NonTerminal(s) : new Terminal(s)).ToArray(); return(new Rule(left, right)); }
public TicketRule(string line) { var match = RuleRegex.Match(line); if (!match.Success) { throw new Exception("No match for rule."); } Name = match.Groups[1].Value; ValidRanges.Add(new Range() { MinValue = int.Parse(match.Groups[2].Value), MaxValue = int.Parse(match.Groups[3].Value), }); ValidRanges.Add(new Range() { MinValue = int.Parse(match.Groups[4].Value), MaxValue = int.Parse(match.Groups[5].Value), }); }