Mercurial > pub > ImplabNet
comparison Implab/Automaton/RegularExpressions/RegularDFABuilder.cs @ 170:181119ef3b39 ref20160224
DFA refactoring, rx based dfa.
author | cin |
---|---|
date | Fri, 04 Mar 2016 01:56:31 +0300 |
parents | e227e78d72e4 |
children |
comparison
equal
deleted
inserted
replaced
169:54270c2f29f2 | 170:181119ef3b39 |
---|---|
120 m_lastpos = new HashSet<int>(new[] { m_idx }); | 120 m_lastpos = new HashSet<int>(new[] { m_idx }); |
121 Followpos(m_idx); | 121 Followpos(m_idx); |
122 m_ends.Add(m_idx, token.Tag); | 122 m_ends.Add(m_idx, token.Tag); |
123 } | 123 } |
124 | 124 |
125 public void BuildDFA(IDFATableBuilder<TTag> dfa) { | 125 public void BuildDFA(IDFATableBuilder dfa) { |
126 Safe.ArgumentNotNull(dfa,"dfa"); | 126 Safe.ArgumentNotNull(dfa,"dfa"); |
127 | 127 |
128 var states = new MapAlphabet<HashSet<int>>(new CustomEqualityComparer<HashSet<int>>( | 128 var states = new MapAlphabet<HashSet<int>>(new CustomEqualityComparer<HashSet<int>>( |
129 (x, y) => x.SetEquals(y), | 129 (x, y) => x.SetEquals(y), |
130 x => x.Sum(n => n.GetHashCode()) | 130 x => x.Sum(n => n.GetHashCode()) |
163 if (tags != null && tags.Length > 0) | 163 if (tags != null && tags.Length > 0) |
164 dfa.MarkFinalState(s2, tags); | 164 dfa.MarkFinalState(s2, tags); |
165 | 165 |
166 queue.Enqueue(next); | 166 queue.Enqueue(next); |
167 } | 167 } |
168 dfa.DefineTransition(s1, s2, a); | 168 dfa.Add(new AutomatonTransition(s1, s2, a)); |
169 } | 169 } |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 | 173 |