Mercurial > pub > ImplabNet
annotate Implab/Parsing/EDFADefinition.cs @ 158:130781364799 v2
refactoring, code cleanup
author | cin |
---|---|
date | Thu, 18 Feb 2016 14:34:02 +0300 |
parents | 948c015a9011 |
children | 5802131432e4 |
rev | line source |
---|---|
55 | 1 using Implab; |
2 using System; | |
3 | |
4 namespace Implab.Parsing { | |
158 | 5 public class EDFADefinition<T> : DFADefinition 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 | |
158 | 12 public EDFADefinition(EnumAlphabet<T> alphabet) : base(alphabet.Count) { |
55 | 13 m_alphabet = alphabet; |
14 } | |
15 | |
157 | 16 public void DefineTransition(int s1, int s2, T input) { |
17 DefineTransition(s1, s2, m_alphabet.Translate(input)); | |
18 } | |
19 | |
55 | 20 public EDFADefinition<T> Optimize() { |
21 var optimized = new EDFADefinition<T>(new EnumAlphabet<T>()); | |
22 Optimize(optimized, m_alphabet, optimized.Alphabet); | |
23 | |
24 return optimized; | |
25 } | |
26 | |
27 public void PrintDFA() { | |
28 PrintDFA(m_alphabet); | |
29 } | |
30 } | |
31 } |