コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        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));
            }
        }