Mercurial > pub > ImplabNet
annotate Implab/Parsing/EDFADefinition.cs @ 157:948c015a9011 v2
sync
author | cin |
---|---|
date | Thu, 18 Feb 2016 11:03:47 +0300 |
parents | 97fbbf816844 |
children | 130781364799 |
rev | line source |
---|---|
55 | 1 using Implab; |
2 using System; | |
3 | |
4 namespace Implab.Parsing { | |
5 public class EDFADefinition<T> : DFADefinitionBase where T : struct, IConvertible { | |
156
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
55
diff
changeset
|
6 readonly EnumAlphabet<T> m_alphabet; |
55 | 7 |
8 public EnumAlphabet<T> Alphabet { | |
9 get { return m_alphabet; } | |
10 } | |
11 | |
156
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
55
diff
changeset
|
12 public EDFADefinition(EnumAlphabet<T> alphabet) { |
55 | 13 Safe.ArgumentNotNull(alphabet, "alphabet"); |
14 m_alphabet = alphabet; | |
15 } | |
16 | |
17 public override int AlphabetSize { | |
18 get { return m_alphabet.Count; } | |
19 } | |
20 | |
157 | 21 public void DefineTransition(int s1, int s2, T input) { |
22 DefineTransition(s1, s2, m_alphabet.Translate(input)); | |
23 } | |
24 | |
55 | 25 public EDFADefinition<T> Optimize() { |
26 var optimized = new EDFADefinition<T>(new EnumAlphabet<T>()); | |
27 Optimize(optimized, m_alphabet, optimized.Alphabet); | |
28 | |
29 return optimized; | |
30 } | |
31 | |
32 public void PrintDFA() { | |
33 PrintDFA(m_alphabet); | |
34 } | |
35 } | |
36 } |