annotate Implab/Parsing/EDFADefinition.cs @ 156:97fbbf816844 v2

Promises: SignalXXX methods merged into SignalHandler method. Components: RunnableComponent In progress
author cin
date Mon, 15 Feb 2016 04:22:15 +0300
parents c0bf853aa04f
children 948c015a9011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
1 using Implab;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
2 using System;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
3
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
4 namespace Implab.Parsing {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
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
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
7
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
8 public EnumAlphabet<T> Alphabet {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
9 get { return m_alphabet; }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
10 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
11
156
97fbbf816844 Promises: SignalXXX methods merged into SignalHandler method.
cin
parents: 55
diff changeset
12 public EDFADefinition(EnumAlphabet<T> alphabet) {
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
13 Safe.ArgumentNotNull(alphabet, "alphabet");
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
14 m_alphabet = alphabet;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
15 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
16
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
17 public override int AlphabetSize {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
18 get { return m_alphabet.Count; }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
19 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
20
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
21 public EDFADefinition<T> Optimize() {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
22 var optimized = new EDFADefinition<T>(new EnumAlphabet<T>());
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
23 Optimize(optimized, m_alphabet, optimized.Alphabet);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
24
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
25 return optimized;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
26 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
27
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
28 public void PrintDFA() {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
29 PrintDFA(m_alphabet);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
30 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
31 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
32 }