public GREP(string regexp, string[] lines) { var regexp1 = string.Format($"(.*{regexp}.*)"); _lines = lines; _nfa = new NFA(regexp1); }
public void Run() { var regs = new List<string[]> { new[] {"((A*B|AC)D)", "AAAABD"}, new[] {"((A*B|AC)D)", "AAAAC"}, new[] {"((a|(bc)*d)*)", "abcbcd"}, new[] { "((a|(bc)*d)*)", "abcbcbcdaaaabcbcdaaaddd" } }; foreach (var reg in regs) { var regexp = reg[0]; var txt = reg[1]; if (txt.Contains("|")) { throw new ArgumentException("| character in text is not supported"); } var nfa = new NFA(regexp); Console.WriteLine($"{regexp} : {txt}"); Console.WriteLine(nfa.Recognizes(txt)); Console.WriteLine("---------------------------------------------"); } Console.ReadLine(); }