diff Implab/Automaton/RegularExpressions/RegularDFA.cs @ 182:76e8f2ba12b8 ref20160224

pretty print DFA, the minimization is still buggy
author cin
date Thu, 24 Mar 2016 18:52:10 +0300
parents b2b6a6640aa3
children 4f82e0f161c3
line wrap: on
line diff
--- a/Implab/Automaton/RegularExpressions/RegularDFA.cs	Thu Mar 24 03:54:46 2016 +0300
+++ b/Implab/Automaton/RegularExpressions/RegularDFA.cs	Thu Mar 24 18:52:10 2016 +0300
@@ -66,6 +66,9 @@
             // skip all unclassified symbols
             foreach (var pair in alphaMap.Where(x => x.Value != 0))
                 alphabet.DefineClass(m_alphabet.GetSymbols(pair.Key), pair.Value);
+
+            var orig = ToString();
+            var opt = dfa.ToString();
             
             return dfa;
         }
@@ -78,6 +81,15 @@
             return FinalStates.GroupBy(x => m_tags[x], arrayComparer).Select(g => new HashSet<int>(g));
         }
 
+        public override string ToString() {
+            var states = new MapAlphabet<string>(false, null);
+
+            for (int i = 0; i < StateCount; i++)
+                states.DefineSymbol(string.Format("s{0}", i), i);
+
+            return string.Format("//[RegularDFA {1} x {2}]\n{0}", PrintDFA(InputAlphabet, states),StateCount, AlphabetSize);
+        }
+
     }
 }