public Automata <string> CreateAutomata() { char finalState = _lines.Last().First(); finalState++; string finalStateString = finalState.ToString(); Automata <string> m = new Automata <string>(); m.DefineAsStartState(_lines[0].First().ToString()); List <char> symbols = new List <char>(); foreach (string line in _lines) { string[] substrings = line.Split(' '); string fromState = substrings[0]; for (int i = 2; i < substrings.Length; i += 2) { string substring = substrings[i]; char symbol = substring.First(); if (symbol != '$' && !symbols.Contains(symbol)) { symbols.Add(symbol); } if (substring.Length > 1) { string toState = substring[1].ToString(); if (substring.Last() == '*') { m.DefineAsFinalState(toState); } m.AddTransition(new Transition <string>(fromState, symbol, toState)); } else { m.AddTransition(new Transition <string>(fromState, symbol, finalStateString)); if (!m.getEndStates.Contains(finalStateString)) { m.DefineAsFinalState(finalStateString); } } } } m.SetAlphabet(symbols.ToArray()); return(m); }