comparison Implab/Automaton/RegularExpressions/RegularDFADefinition.cs @ 165:e227e78d72e4 ref20160224

DFA refactoring
author cin
date Mon, 29 Feb 2016 02:02:17 +0300
parents ec35731ae299
children 54270c2f29f2
comparison
equal deleted inserted replaced
164:ec35731ae299 165:e227e78d72e4
2 2
3 namespace Implab.Automaton.RegularExpressions { 3 namespace Implab.Automaton.RegularExpressions {
4 public class RegularDFADefinition<TInput, TTag> : DFATransitionTable<TTag>, IDFATransitionTable<TTag> { 4 public class RegularDFADefinition<TInput, TTag> : DFATransitionTable<TTag>, IDFATransitionTable<TTag> {
5 5
6 readonly IAlphabet<TInput> m_alphabet; 6 readonly IAlphabet<TInput> m_alphabet;
7 readonly int m_initialState;
8 7
9 public RegularDFADefinition(IAlphabet<TInput> alphabet, int initialState) { 8 public RegularDFADefinition(IAlphabet<TInput> alphabet) {
10 Safe.ArgumentNotNull(alphabet, "aplhabet"); 9 Safe.ArgumentNotNull(alphabet, "aplhabet");
11 10
12 m_alphabet = alphabet; 11 m_alphabet = alphabet;
13 m_initialState = initialState;
14 } 12 }
15 13
16 14
17 public IAlphabet<TInput> InputAlphabet { 15 public IAlphabet<TInput> InputAlphabet {
18 get { 16 get {
28 } 26 }
29 27
30 /// <summary> 28 /// <summary>
31 /// Optimize the specified alphabet. 29 /// Optimize the specified alphabet.
32 /// </summary> 30 /// </summary>
31 /// <param name = "dfaTable"></param>
33 /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param> 32 /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param>
34 public RegularDFADefinition<TInput, TTag> Optimize(IAlphabetBuilder<TInput> alphabet) { 33 public void Optimize(IDFATableBuilder<TTag> dfaTable, IAlphabetBuilder<TInput> alphabet) {
35 Safe.ArgumentNotNull(alphabet, "alphabet"); 34 Safe.ArgumentNotNull(alphabet, "alphabet");
35 Safe.ArgumentNotNull(dfaTable, "dfaTable");
36 36
37 var optimalDFA = new RegularDFADefinition<TInput,TTag>(alphabet, m_initialState); 37 Optimize(dfaTable, InputAlphabet, alphabet, new DummyAlphabet(StateCount), new MapAlphabet<int>());
38
39 Optimize(optimalDFA, InputAlphabet, alphabet, new DummyAlphabet(StateCount), new MapAlphabet<int>());
40
41 } 38 }
42 39
43 40
44 } 41 }
45 } 42 }