164
|
1 using System;
|
|
2
|
|
3 namespace Implab.Automaton.RegularExpressions {
|
|
4 public class RegularDFADefinition<TInput, TTag> : DFATransitionTable<TTag>, IDFATransitionTable<TTag> {
|
|
5
|
|
6 readonly IAlphabet<TInput> m_alphabet;
|
|
7
|
165
|
8 public RegularDFADefinition(IAlphabet<TInput> alphabet) {
|
164
|
9 Safe.ArgumentNotNull(alphabet, "aplhabet");
|
|
10
|
|
11 m_alphabet = alphabet;
|
|
12 }
|
|
13
|
|
14
|
|
15 public IAlphabet<TInput> InputAlphabet {
|
|
16 get {
|
|
17 return m_alphabet;
|
|
18 }
|
|
19 }
|
|
20
|
|
21 protected override DFAStateDescriptior<TTag>[] ConstructTransitionTable() {
|
|
22 if (InputAlphabet.Count != m_alphabet.Count)
|
|
23 throw new InvalidOperationException("The alphabet doesn't match the transition table");
|
|
24
|
|
25 return base.ConstructTransitionTable();
|
|
26 }
|
|
27
|
|
28 /// <summary>
|
|
29 /// Optimize the specified alphabet.
|
|
30 /// </summary>
|
165
|
31 /// <param name = "dfaTable"></param>
|
164
|
32 /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param>
|
165
|
33 public void Optimize(IDFATableBuilder<TTag> dfaTable, IAlphabetBuilder<TInput> alphabet) {
|
164
|
34 Safe.ArgumentNotNull(alphabet, "alphabet");
|
165
|
35 Safe.ArgumentNotNull(dfaTable, "dfaTable");
|
164
|
36
|
165
|
37 Optimize(dfaTable, InputAlphabet, alphabet, new DummyAlphabet(StateCount), new MapAlphabet<int>());
|
164
|
38 }
|
|
39
|
|
40
|
|
41 }
|
|
42 }
|
|
43
|