Пример #1
0
        static void Test2()
        {
            RegularExpression a     = new Literal("A");
            RegularExpression d     = new Literal("D");
            RegularExpression n     = new Literal("N");
            RegularExpression e     = new Literal("E");
            RegularExpression r     = new Literal("R");
            RegularExpression o     = new Literal("O");
            RegularExpression t     = new Literal("T");
            RegularExpression comma = new Literal(",");

            //RegularExpression notComma = new Alternation(a, d, n, e, r, o, t);
            RegularExpression notComma     = new Literal("ADNEROT");
            RegularExpression notCommaStar = new Concatenation(notComma, new KleeneStar(notComma));
            RegularExpression and          = new Concatenation(a, n, d);
            RegularExpression near         = new Concatenation(n, e, a, r);
            RegularExpression not          = new Concatenation(n, o, t);
            RegularExpression or           = new Concatenation(o, r);

            RegularExpression blah = new Alternation(near, not, and, or, comma, notCommaStar);

            Nfa nfa = blah.MakeNfa(new Nfa.NameSource());

            Console.WriteLine(nfa);
            Console.WriteLine("-------------------------------");
            Dfa dfa = nfa.ToDfa();

            Console.WriteLine(dfa);
            dfa.WriteDot("lol.dot");
        }
Пример #2
0
        public static void BuildAndShow(String filename, RegularExpression r)
        {
            Nfa nfa = r.MakeNfa(new Nfa.NameSource());

            Console.WriteLine(nfa);
            Console.WriteLine("---");
            Dfa dfa = nfa.ToDfa();

            Console.WriteLine(dfa);
            Console.WriteLine("Writing DFA graph to file " + filename);
            dfa.WriteDot(filename);
            Console.WriteLine();
        }
Пример #3
0
        public static void BuildAndShow(String fileprefix, Regex r)
        {
            Nfa nfa = r.MkNfa(new Nfa.NameSource());

            Console.WriteLine(nfa);
            Console.WriteLine("Writing NFA graph to file");
            nfa.WriteDot(fileprefix + "nfa.dot");
            Console.WriteLine("---");
            Dfa dfa = nfa.ToDfa();

            Console.WriteLine(dfa);
            Console.WriteLine("Writing DFA graph to file");
            dfa.WriteDot(fileprefix + "dfa.dot");
            Console.WriteLine();
        }