Exemplo n.º 1
0
        private static string _transitionFunction = "{A-a-B};{B-a-C};{B-b-A};{C-c-A}"; //Transition functions: for example {A,a,B} means State A has a transition a to state B.

        #endregion Fields

        #region Methods

        public static void HandleInput()
        {
            if (Console.ReadKey(true).Key == ConsoleKey.Escape) {
                //Don't do anything
            }

            if(Console.ReadKey(true).Key == ConsoleKey.G){
                dfa = DFAFactory.BuildDefaultDFA(_alphabet, _states, _transitionFunction, _startingState);
                OperateDFA();
            }

            if (Console.ReadKey(true).Key == ConsoleKey.U) {
                //Query user for DFA parameters
                Console.WriteLine("Write DFA alphabet in form of symbol,symbol,symbol without spaces between symbols - for example a,b,c");
                string alphabet = Console.ReadLine();
                Console.WriteLine("Write states in form of State,State,State without spaces between state names - for example A,B,C");
                string states = Console.ReadLine();
                Console.WriteLine("Write transition function in form of {starting state-transition-goal state};{starting state-transition-goal state} - for example {A-a-B}");
                string transitionFunction = Console.ReadLine();
                Console.WriteLine("Write the name of the starting state");
                string startingState = Console.ReadLine();

                //Build default dfa
                dfa = DFAFactory.BuildDefaultDFA(alphabet, states,transitionFunction,startingState);
                OperateDFA();
            }
        }
Exemplo n.º 2
0
        private void CreateDFA()
        {
            _testTransitionsFromString = Utils.CreateTransitionsFromAlphabet(_alphabet);
            _testStatesFromString = Utils.CreateDefaultStatesFromString(_states);
            TryAddingTransitionsToState();
            _dfa = new DFA(_testTransitionsFromString, _testStatesFromString);

            Console.WriteLine("Created DFA!");
        }