Ejemplo n.º 1
0
            private void HandleSubInput(int index)
            {
                var running  = true;
                var automaat = automates[index].automaat;

                while (running)
                {
                    Console.Clear();
                    Console.WriteLine($"Gekozen {automates[index].text}");
                    subsubtext.ToList().ForEach(s => Console.WriteLine(s));
                    int input = GetInput(subsubtext.Length);
                    switch (input)
                    {
                    case 0:
                        Graphviz.PrintGraph(automaat, "test");
                        break;

                    case 1:
                        var gram = RegGram <int> .NdfaToRegGram(automaat);

                        Console.WriteLine(gram.ToString());
                        Console.ReadLine();
                        break;

                    case 2:
                        running = false;
                        automates.Clear();
                        break;
                    }
                }
            }
Ejemplo n.º 2
0
        private static void GramToNdfaAndReverse()
        {
            char[] alphabet = { 'a', 'b' };
            var    ndfa     = new Automaat <int>(alphabet);

            ndfa.AddTransition(new Transition <int>(0, alphabet[0], 0));
            ndfa.AddTransition(new Transition <int>(0, alphabet[0], 1));
            ndfa.AddTransition(new Transition <int>(0, alphabet[1], 0));
            ndfa.AddTransition(new Transition <int>(0, alphabet[1], 3));

            ndfa.AddTransition(new Transition <int>(1, alphabet[0], 2));

            ndfa.AddTransition(new Transition <int>(2, alphabet[0]));
            ndfa.AddTransition(new Transition <int>(2, alphabet[1]));

            ndfa.AddTransition(new Transition <int>(3, alphabet[1], 4));

            ndfa.AddTransition(new Transition <int>(4, alphabet[0]));
            ndfa.AddTransition(new Transition <int>(4, alphabet[1]));

            ndfa.DefineAsStartState(0);

            ndfa.DefineAsFinalState(2);
            ndfa.DefineAsFinalState(4);

            Graphviz.PrintGraph(ndfa, "ndfaToGram");

            var gram = RegGram <int> .NdfaToRegGram(ndfa);

            Console.WriteLine(gram.ToString());
        }