55
|
1 using Implab;
|
|
2 using System;
|
|
3 using System.Collections.Generic;
|
|
4 using System.Linq;
|
|
5 using System.Text;
|
|
6 using System.Threading.Tasks;
|
|
7
|
|
8 namespace Implab.Parsing {
|
|
9 public class EDFADefinition<T> : DFADefinitionBase where T : struct, IConvertible {
|
|
10 EnumAlphabet<T> m_alphabet;
|
|
11
|
|
12 public EnumAlphabet<T> Alphabet {
|
|
13 get { return m_alphabet; }
|
|
14 }
|
|
15
|
|
16 public EDFADefinition(EnumAlphabet<T> alphabet)
|
|
17 : base() {
|
|
18 Safe.ArgumentNotNull(alphabet, "alphabet");
|
|
19 m_alphabet = alphabet;
|
|
20 }
|
|
21
|
|
22 public override int AlphabetSize {
|
|
23 get { return m_alphabet.Count; }
|
|
24 }
|
|
25
|
|
26 public EDFADefinition<T> Optimize() {
|
|
27 var optimized = new EDFADefinition<T>(new EnumAlphabet<T>());
|
|
28 Optimize(optimized, m_alphabet, optimized.Alphabet);
|
|
29
|
|
30 return optimized;
|
|
31 }
|
|
32
|
|
33 public void PrintDFA() {
|
|
34 PrintDFA(m_alphabet);
|
|
35 }
|
|
36 }
|
|
37 }
|