Example #1
0
 private void GetListWords(List <Word> words)
 {
     ListWords.AddRange(words);
     ListWords = ListWords.Distinct(new WordComparer()).ToList();
     foreach (Word w in ListWords)
     {
         w.IsWordAccepted(ListStates, ListTransitions);
     }
 }
Example #2
0
        public void CreateTextFile()
        {
            ListWords = ListWords.Distinct(new WordComparer()).ToList();
            string content = "";

            content += $"# {Comment}" + Environment.NewLine + Environment.NewLine;
            content += $"alphabet: {String.Join("", ListAlphabets)}" + Environment.NewLine;
            content += $"stack: {String.Join("", ListStacks)}" + Environment.NewLine;
            content += $"states: {String.Join(",", ListStates)}" + Environment.NewLine;
            content += $"final: {String.Join(",", ListStates.FindAll(x => x.IsFinal))}" + Environment.NewLine + Environment.NewLine;
            content += $"transitions:" + Environment.NewLine;
            content += $"{String.Join(Environment.NewLine, ListTransitions)}" + Environment.NewLine;
            content += "end." + Environment.NewLine + Environment.NewLine;
            content += "dfa: ";
            if (IsDFA)
            {
                content += "y" + Environment.NewLine;
            }
            else
            {
                content += "n" + Environment.NewLine;
            }
            content += "finite: ";
            if (IsFinite)
            {
                content += "y" + Environment.NewLine;
            }
            else
            {
                content += "n" + Environment.NewLine;
            }
            content += Environment.NewLine;
            content += $"words:" + Environment.NewLine;
            foreach (Word word in ListWords)
            {
                if (word.IsAccepted)
                {
                    content += word.Words + ",y" + Environment.NewLine;
                }
                else
                {
                    content += word.Words + ",n" + Environment.NewLine;
                }
            }
            content += "end.";
            string file_name = "automaton_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";

            File.WriteAllText(file_name, content);
        }