Mercurial > pub > ImplabNet
comparison 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 |
comparison
equal
deleted
inserted
replaced
181:b2b6a6640aa3 | 182:76e8f2ba12b8 |
---|---|
64 | 64 |
65 // make the alphabet for the new DFA | 65 // make the alphabet for the new DFA |
66 // skip all unclassified symbols | 66 // skip all unclassified symbols |
67 foreach (var pair in alphaMap.Where(x => x.Value != 0)) | 67 foreach (var pair in alphaMap.Where(x => x.Value != 0)) |
68 alphabet.DefineClass(m_alphabet.GetSymbols(pair.Key), pair.Value); | 68 alphabet.DefineClass(m_alphabet.GetSymbols(pair.Key), pair.Value); |
69 | |
70 var orig = ToString(); | |
71 var opt = dfa.ToString(); | |
69 | 72 |
70 return dfa; | 73 return dfa; |
71 } | 74 } |
72 | 75 |
73 protected override IEnumerable<HashSet<int>> GroupFinalStates() { | 76 protected override IEnumerable<HashSet<int>> GroupFinalStates() { |
76 x => x.Sum(it => x.GetHashCode()) | 79 x => x.Sum(it => x.GetHashCode()) |
77 ); | 80 ); |
78 return FinalStates.GroupBy(x => m_tags[x], arrayComparer).Select(g => new HashSet<int>(g)); | 81 return FinalStates.GroupBy(x => m_tags[x], arrayComparer).Select(g => new HashSet<int>(g)); |
79 } | 82 } |
80 | 83 |
84 public override string ToString() { | |
85 var states = new MapAlphabet<string>(false, null); | |
86 | |
87 for (int i = 0; i < StateCount; i++) | |
88 states.DefineSymbol(string.Format("s{0}", i), i); | |
89 | |
90 return string.Format("//[RegularDFA {1} x {2}]\n{0}", PrintDFA(InputAlphabet, states),StateCount, AlphabetSize); | |
91 } | |
92 | |
81 } | 93 } |
82 } | 94 } |
83 | 95 |