annotate Implab/Parsing/EDFADefinition.cs @ 160:5802131432e4 v2

fixed regression: race condition in Promise DFA refactoring
author cin
date Thu, 18 Feb 2016 19:38:54 +0300
parents 130781364799
children
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 {
158
130781364799 refactoring, code cleanup
cin
parents: 157
diff changeset
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
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
158
130781364799 refactoring, code cleanup
cin
parents: 157
diff changeset
12 public EDFADefinition(EnumAlphabet<T> alphabet) : base(alphabet.Count) {
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
13 m_alphabet = alphabet;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
14 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
15
157
cin
parents: 156
diff changeset
16 public void DefineTransition(int s1, int s2, T input) {
cin
parents: 156
diff changeset
17 DefineTransition(s1, s2, m_alphabet.Translate(input));
cin
parents: 156
diff changeset
18 }
cin
parents: 156
diff changeset
19
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
20 public EDFADefinition<T> Optimize() {
160
5802131432e4 fixed regression: race condition in Promise
cin
parents: 158
diff changeset
21
5802131432e4 fixed regression: race condition in Promise
cin
parents: 158
diff changeset
22 return (EDFADefinition<T>)Optimize(alphabet => new EDFADefinition<T>((EnumAlphabet<T>)alphabet), m_alphabet, new EnumAlphabet<T>());
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
23 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
24
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
25 public void PrintDFA() {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
26 PrintDFA(m_alphabet);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
27 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
28 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
29 }