/// <summary> /// Gets result of execution of the FA on the string /// </summary> /// <param name="input">Input string</param> /// <returns>Execution result</returns> public ResultEnum Execute(string input) { var errors = FAAnalyzer.GetErrors(Graph); if (errors.Count > 0) { throw new InvalidOperationException(errors.Aggregate("", (folder, error) => folder + error + "\n")); } var FA = FiniteAutomata.ConvertGraphToAutomata(Graph.Edges.ToList(), Graph.Vertices.ToList()); return(FA.DoAllTransitions(input) ? ResultEnum.Passed : ResultEnum.Failed); }
/// <summary> /// Gets FA model which executes input string step by step /// </summary> /// <param name="input">Input string</param> /// <returns>FA with specified graph and string</returns> public FiniteAutomata StartDebug(string input) { var errors = FAAnalyzer.GetErrors(Graph); if (errors.Count > 0) { throw new InvalidOperationException(errors.Aggregate("", (folder, error) => folder + error + "\n")); } var FA = FiniteAutomata.ConvertGraphToAutomata(Graph.Edges.ToList(), Graph.Vertices.ToList()); FA.SetString(input); return(FA); }
private static void RequireValidNfa(BidirectionalGraph <NodeViewModel, EdgeViewModel> nfaGraph) { var errors = FAAnalyzer.GetErrors(nfaGraph); if (FAAnalyzer.GetType(nfaGraph) == FATypeEnum.DFA) { errors.Add(Lang.alreadyDeterministic); } if (errors.Count > 0) { throw new InvalidOperationException(String.Join("\n", errors)); } }