public static void DisplayPattern(string pattern) { var result = PatternParsers.Regex(new ArrayConsList <char>(pattern)); Console.WriteLine("Pattern:\n {0}", pattern.ShowVerbatim()); Console.WriteLine("Parsed:"); Console.WriteLine(result.Tree.FormatAsTree(1)); if (!result.Rest.IsEmpty) { Console.WriteLine("Rest:\n {0}", result.Rest.AsEnumerable().AsString().ShowVerbatim()); } Console.Write("\n"); }
public RootNode(string regex) { var result = PatternParsers.Regex(new ArrayConsList <char>(regex)); if (result.Rest.IsEmpty) { InputPattern = result.Tree; } else { throw new ArgumentException(string.Format("RegexParse could not understand part of the regex pattern: {0}.", result.Rest), "regex."); } Type = TreeNodeType.Root; IsModified = false; OriginalRegex = regex; RootGroup = new GroupNode(); RootGroup.FromPattern(InputPattern); }
private static CharClassPattern parseCharClass(string pattern) { return((CharClassPattern)PatternParsers.CharClass(new ArrayConsList <char>(pattern)).Tree); }