162
|
1 using Implab;
|
|
2 using System;
|
|
3
|
|
4 namespace Implab.Parsing {
|
|
5 public class EDFADefinition<T> : DFADefinition where T : struct, IConvertible {
|
|
6 readonly EnumAlphabet<T> m_alphabet;
|
|
7
|
|
8 public EnumAlphabet<T> Alphabet {
|
|
9 get { return m_alphabet; }
|
|
10 }
|
|
11
|
|
12 public EDFADefinition(EnumAlphabet<T> alphabet) : base(alphabet.Count) {
|
|
13 m_alphabet = alphabet;
|
|
14 }
|
|
15
|
|
16 public void DefineTransition(int s1, int s2, T input) {
|
|
17 DefineTransition(s1, s2, m_alphabet.Translate(input));
|
|
18 }
|
|
19
|
|
20 public EDFADefinition<T> Optimize() {
|
|
21
|
|
22 return (EDFADefinition<T>)Optimize(alphabet => new EDFADefinition<T>((EnumAlphabet<T>)alphabet), m_alphabet, new EnumAlphabet<T>());
|
|
23 }
|
|
24
|
|
25 public void PrintDFA() {
|
|
26 PrintDFA(m_alphabet);
|
|
27 }
|
|
28 }
|
|
29 }
|