@@ -0,0 +1,23 | |||||
|
1 | using System; | |||
|
2 | ||||
|
3 | namespace Implab.Automaton.RegularExpressions { | |||
|
4 | public struct DFAStateDescriptorT<T> { | |||
|
5 | public readonly bool final; | |||
|
6 | ||||
|
7 | public readonly int[] transitions; | |||
|
8 | ||||
|
9 | public readonly T[] tags; | |||
|
10 | ||||
|
11 | public DFAStateDescriptorT(int size, bool final, T[] tags) { | |||
|
12 | Safe.ArgumentAssert(size >= 0, "size"); | |||
|
13 | this.final = final; | |||
|
14 | this.tags = tags; | |||
|
15 | ||||
|
16 | transitions = new int[size]; | |||
|
17 | ||||
|
18 | for (int i = 0; i < size; i++) | |||
|
19 | transitions[i] = DFAConst.UNREACHABLE_STATE; | |||
|
20 | } | |||
|
21 | } | |||
|
22 | } | |||
|
23 |
@@ -1,280 +1,291 | |||||
1 | using Implab; |
|
1 | using Implab; | |
2 | using System; |
|
2 | using System; | |
3 | using System.Collections.Generic; |
|
3 | using System.Collections.Generic; | |
4 | using System.Linq; |
|
4 | using System.Linq; | |
5 |
|
5 | |||
6 | namespace Implab.Automaton { |
|
6 | namespace Implab.Automaton { | |
7 | public class DFATable : IDFATableBuilder { |
|
7 | public class DFATable : IDFATableBuilder { | |
8 | DFAStateDescriptior[] m_dfaTable; |
|
|||
9 |
|
||||
10 | int m_stateCount; |
|
8 | int m_stateCount; | |
11 | int m_symbolCount; |
|
9 | int m_symbolCount; | |
12 | int m_initialState; |
|
10 | int m_initialState; | |
13 |
|
11 | |||
14 | readonly HashSet<int> m_finalStates = new HashSet<int>(); |
|
12 | readonly HashSet<int> m_finalStates = new HashSet<int>(); | |
15 | readonly HashSet<AutomatonTransition> m_transitions = new HashSet<AutomatonTransition>(); |
|
13 | readonly HashSet<AutomatonTransition> m_transitions = new HashSet<AutomatonTransition>(); | |
16 |
|
14 | |||
17 | void AssertNotReadOnly() { |
|
|||
18 | if (m_dfaTable != null) |
|
|||
19 | throw new InvalidOperationException("The object is readonly"); |
|
|||
20 | } |
|
|||
21 |
|
||||
22 |
|
15 | |||
23 | #region IDFADefinition implementation |
|
16 | #region IDFADefinition implementation | |
24 |
|
17 | |||
25 | public DFAStateDescriptior[] GetTransitionTable() { |
|
|||
26 | if (m_dfaTable == null) { |
|
|||
27 | if (m_stateCount <= 0) |
|
|||
28 | throw new InvalidOperationException("Invalid automaton definition: states count = {0}", m_stateCount); |
|
|||
29 | if (m_symbolCount <= 0) |
|
|||
30 | throw new InvalidOperationException("Invalid automaton definition: symbols count = {0}", m_symbolCount); |
|
|||
31 |
|
||||
32 | m_dfaTable = ConstructTransitionTable(); |
|
|||
33 | } |
|
|||
34 | return m_dfaTable; |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | public bool IsFinalState(int s) { |
|
18 | public bool IsFinalState(int s) { | |
38 | Safe.ArgumentInRange(s, 0, m_stateCount, "s"); |
|
19 | Safe.ArgumentInRange(s, 0, m_stateCount, "s"); | |
39 |
|
20 | |||
40 |
return |
|
21 | return m_finalStates.Contains(s); | |
41 | } |
|
22 | } | |
42 |
|
23 | |||
43 | public IEnumerable<int> FinalStates { |
|
24 | public IEnumerable<int> FinalStates { | |
44 | get { |
|
25 | get { | |
45 | return m_finalStates; |
|
26 | return m_finalStates; | |
46 | } |
|
27 | } | |
47 | } |
|
28 | } | |
48 |
|
29 | |||
49 | public int StateCount { |
|
30 | public int StateCount { | |
50 | get { return m_stateCount; } |
|
31 | get { return m_stateCount; } | |
51 | } |
|
32 | } | |
52 |
|
33 | |||
53 | public int AlphabetSize { |
|
34 | public int AlphabetSize { | |
54 | get { return m_symbolCount; } |
|
35 | get { return m_symbolCount; } | |
55 | } |
|
36 | } | |
56 |
|
37 | |||
57 | public int InitialState { |
|
38 | public int InitialState { | |
58 | get { return m_initialState; } |
|
39 | get { return m_initialState; } | |
59 | } |
|
40 | } | |
60 |
|
41 | |||
61 | #endregion |
|
42 | #endregion | |
62 |
|
43 | |||
63 | protected virtual DFAStateDescriptior[] ConstructTransitionTable() { |
|
|||
64 | var dfaTable = new DFAStateDescriptior[m_stateCount]; |
|
|||
65 |
|
||||
66 |
|
||||
67 | foreach (var t in m_transitions) { |
|
|||
68 | if (dfaTable[t.s1].transitions == null) |
|
|||
69 | dfaTable[t.s1] = new DFAStateDescriptior(m_symbolCount, m_finalStates.Contains(t.s1)); |
|
|||
70 |
|
||||
71 | dfaTable[t.s1].transitions[t.edge] = t.s2; |
|
|||
72 | } |
|
|||
73 |
|
||||
74 | foreach (var s in m_finalStates) |
|
|||
75 | if (!dfaTable[s].final) |
|
|||
76 | m_dfaTable[s] = new DFAStateDescriptior(m_symbolCount, true); |
|
|||
77 |
|
||||
78 | } |
|
|||
79 |
|
||||
80 | public void SetInitialState(int s) { |
|
44 | public void SetInitialState(int s) { | |
81 | Safe.ArgumentAssert(s >= 0, "s"); |
|
45 | Safe.ArgumentAssert(s >= 0, "s"); | |
82 | m_initialState = s; |
|
46 | m_initialState = s; | |
83 | } |
|
47 | } | |
84 |
|
48 | |||
85 | public void MarkFinalState(int state) { |
|
49 | public void MarkFinalState(int state) { | |
86 | AssertNotReadOnly(); |
|
|||
87 | m_finalStates.Add(state); |
|
50 | m_finalStates.Add(state); | |
88 | } |
|
51 | } | |
89 |
|
52 | |||
90 | public void Add(AutomatonTransition item) { |
|
53 | public void Add(AutomatonTransition item) { | |
91 | AssertNotReadOnly(); |
|
|||
92 | Safe.ArgumentAssert(item.s1 >= 0, "item"); |
|
54 | Safe.ArgumentAssert(item.s1 >= 0, "item"); | |
93 | Safe.ArgumentAssert(item.s2 >= 0, "item"); |
|
55 | Safe.ArgumentAssert(item.s2 >= 0, "item"); | |
94 | Safe.ArgumentAssert(item.edge >= 0, "item"); |
|
56 | Safe.ArgumentAssert(item.edge >= 0, "item"); | |
95 |
|
57 | |||
96 | m_stateCount = Math.Max(m_stateCount, Math.Max(item.s1, item.s2) + 1); |
|
58 | m_stateCount = Math.Max(m_stateCount, Math.Max(item.s1, item.s2) + 1); | |
97 | m_symbolCount = Math.Max(m_symbolCount, item.edge); |
|
59 | m_symbolCount = Math.Max(m_symbolCount, item.edge); | |
98 |
|
60 | |||
99 | m_transitions.Add(item); |
|
61 | m_transitions.Add(item); | |
100 | } |
|
62 | } | |
101 |
|
63 | |||
102 | public void Clear() { |
|
64 | public void Clear() { | |
103 | AssertNotReadOnly(); |
|
|||
104 |
|
||||
105 | m_stateCount = 0; |
|
65 | m_stateCount = 0; | |
106 | m_symbolCount = 0; |
|
66 | m_symbolCount = 0; | |
107 | m_finalStates.Clear(); |
|
67 | m_finalStates.Clear(); | |
108 | m_transitions.Clear(); |
|
68 | m_transitions.Clear(); | |
109 | } |
|
69 | } | |
110 |
|
70 | |||
111 | public bool Contains(AutomatonTransition item) { |
|
71 | public bool Contains(AutomatonTransition item) { | |
112 | return m_transitions.Contains(item); |
|
72 | return m_transitions.Contains(item); | |
113 | } |
|
73 | } | |
114 |
|
74 | |||
115 | public void CopyTo(AutomatonTransition[] array, int arrayIndex) { |
|
75 | public void CopyTo(AutomatonTransition[] array, int arrayIndex) { | |
116 | m_transitions.CopyTo(array, arrayIndex); |
|
76 | m_transitions.CopyTo(array, arrayIndex); | |
117 | } |
|
77 | } | |
118 |
|
78 | |||
119 | public bool Remove(AutomatonTransition item) { |
|
79 | public bool Remove(AutomatonTransition item) { | |
120 | AssertNotReadOnly(); |
|
|||
121 | m_transitions.Remove(item); |
|
80 | m_transitions.Remove(item); | |
122 | } |
|
81 | } | |
123 |
|
82 | |||
124 | public int Count { |
|
83 | public int Count { | |
125 | get { |
|
84 | get { | |
126 | return m_transitions.Count; |
|
85 | return m_transitions.Count; | |
127 | } |
|
86 | } | |
128 | } |
|
87 | } | |
129 |
|
88 | |||
130 | public bool IsReadOnly { |
|
89 | public bool IsReadOnly { | |
131 | get { |
|
90 | get { | |
132 |
return |
|
91 | return false; | |
133 | } |
|
92 | } | |
134 | } |
|
93 | } | |
135 |
|
94 | |||
136 | public IEnumerator<AutomatonTransition> GetEnumerator() { |
|
95 | public IEnumerator<AutomatonTransition> GetEnumerator() { | |
137 | return m_transitions.GetEnumerator(); |
|
96 | return m_transitions.GetEnumerator(); | |
138 | } |
|
97 | } | |
139 |
|
98 | |||
140 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { |
|
99 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { | |
141 | return GetEnumerator(); |
|
100 | return GetEnumerator(); | |
142 | } |
|
101 | } | |
143 |
|
102 | |||
144 | /// <summary>Π€ΠΎΡΠΌΠΈΡΡΠ΅Ρ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ ΠΏΠ΅ΡΠ΅Π΄ Π½Π°ΡΠ°Π»ΠΎΠΌ ΡΠ°Π±ΠΎΡΡ Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° ΠΌΠΈΠ½ΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ.</summary> |
|
103 | /// <summary>Π€ΠΎΡΠΌΠΈΡΡΠ΅Ρ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ ΠΏΠ΅ΡΠ΅Π΄ Π½Π°ΡΠ°Π»ΠΎΠΌ ΡΠ°Π±ΠΎΡΡ Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° ΠΌΠΈΠ½ΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ.</summary> | |
145 | /// <remarks> |
|
104 | /// <remarks> | |
146 | /// Π ΠΏΡΠΎΡΠ΅ΡΡΠ΅ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΡ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ Π°Π²ΡΠΎΠΌΠ°ΡΠ° ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ°Π·Π΄Π΅Π»ΠΈΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ, |
|
105 | /// Π ΠΏΡΠΎΡΠ΅ΡΡΠ΅ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΡ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ Π°Π²ΡΠΎΠΌΠ°ΡΠ° ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ°Π·Π΄Π΅Π»ΠΈΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ, | |
147 | /// Π½Π° Π΄Π²Π° ΠΏΠΎΠ΄ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° - ΠΊΠΎΠ½Π΅ΡΠ½ΡΠ΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΈ Π²ΡΠ΅ ΠΎΡΡΠ°Π»ΡΠ½ΡΠ΅, ΠΏΠΎΡΠ»Π΅ ΡΠ΅Π³ΠΎ ΡΡΠΈ ΠΏΠΎΠ΄ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° |
|
106 | /// Π½Π° Π΄Π²Π° ΠΏΠΎΠ΄ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° - ΠΊΠΎΠ½Π΅ΡΠ½ΡΠ΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΈ Π²ΡΠ΅ ΠΎΡΡΠ°Π»ΡΠ½ΡΠ΅, ΠΏΠΎΡΠ»Π΅ ΡΠ΅Π³ΠΎ ΡΡΠΈ ΠΏΠΎΠ΄ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° | |
148 | /// Π±ΡΠ΄ΡΡ ΡΠ΅Π·Π΄Π΅Π»Π΅Π½Ρ Π½Π° Π±ΠΎΠ»Π΅Π΅ ΠΌΠ΅Π»ΠΊΠΈΠ΅. ΠΠ½ΠΎΠ³Π΄Π° ΡΡΠ΅Π±ΡΠ΅ΡΡΡ Π³Π°ΡΠ°Π½ΡΠΈΡΠΎΠ²Π°ΡΡ ΡΠ°Π·Π»ΠΈΡΠΈΡ ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΠΎΡΡΠ½ΠΈΠΉ, |
|
107 | /// Π±ΡΠ΄ΡΡ ΡΠ΅Π·Π΄Π΅Π»Π΅Π½Ρ Π½Π° Π±ΠΎΠ»Π΅Π΅ ΠΌΠ΅Π»ΠΊΠΈΠ΅. ΠΠ½ΠΎΠ³Π΄Π° ΡΡΠ΅Π±ΡΠ΅ΡΡΡ Π³Π°ΡΠ°Π½ΡΠΈΡΠΎΠ²Π°ΡΡ ΡΠ°Π·Π»ΠΈΡΠΈΡ ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΠΎΡΡΠ½ΠΈΠΉ, | |
149 | /// Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π΄Π°Π½Π½ΡΡ ΡΡΠΊΠ½ΡΠΈΡ, Π΄Π»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ² ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ. |
|
108 | /// Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π΄Π°Π½Π½ΡΡ ΡΡΠΊΠ½ΡΠΈΡ, Π΄Π»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ² ΠΊΠΎΠ½Π΅ΡΠ½ΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ. | |
150 | /// </remarks> |
|
109 | /// </remarks> | |
151 | /// <returns>The final states.</returns> |
|
110 | /// <returns>The final states.</returns> | |
152 | protected virtual IEnumerable<HashSet<int>> GroupFinalStates() { |
|
111 | protected virtual IEnumerable<HashSet<int>> GroupFinalStates() { | |
153 | return new HashSet<int>[] { m_finalStates }; |
|
112 | return new HashSet<int>[] { m_finalStates }; | |
154 | } |
|
113 | } | |
155 |
|
114 | |||
156 |
protected void Optimize |
|
115 | protected void Optimize( | |
157 | IDFATableBuilder optimalDFA, |
|
116 | IDFATableBuilder optimalDFA, | |
158 | IAlphabet<TInput> inputAlphabet, |
|
117 | IDictionary<int,int> alphabetMap, | |
159 | IAlphabetBuilder<TInput> optimalInputAlphabet, |
|
118 | IDictionary<int,int> stateMap | |
160 | IAlphabet<TState> stateAlphabet, |
|
|||
161 | IAlphabetBuilder<TState> optimalStateAlphabet |
|
|||
162 | ) { |
|
119 | ) { | |
163 | Safe.ArgumentNotNull(optimalDFA, "dfa"); |
|
120 | Safe.ArgumentNotNull(optimalDFA, "dfa"); | |
164 |
Safe.ArgumentNotNull( |
|
121 | Safe.ArgumentNotNull(alphabetMap, "alphabetMap"); | |
165 |
Safe.ArgumentNotNull( |
|
122 | Safe.ArgumentNotNull(stateMap, "stateMap"); | |
166 | Safe.ArgumentNotNull(inputAlphabet, "inputAlphabet"); |
|
|||
167 | Safe.ArgumentNotNull(stateAlphabet, "stateAlphabet"); |
|
|||
168 |
|
123 | |||
169 | if (inputAlphabet.Count != m_symbolCount) |
|
|||
170 | throw new InvalidOperationException("The input symbols aphabet mismatch"); |
|
|||
171 | if (stateAlphabet.Count != m_stateCount) |
|
|||
172 | throw new InvalidOperationException("The states alphabet mismatch"); |
|
|||
173 |
|
124 | |||
174 | var setComparer = new CustomEqualityComparer<HashSet<int>>( |
|
125 | var setComparer = new CustomEqualityComparer<HashSet<int>>( | |
175 | (x, y) => x.SetEquals(y), |
|
126 | (x, y) => x.SetEquals(y), | |
176 | s => s.Sum(x => x.GetHashCode()) |
|
127 | s => s.Sum(x => x.GetHashCode()) | |
177 | ); |
|
128 | ); | |
178 |
|
129 | |||
179 | var optimalStates = new HashSet<HashSet<int>>(setComparer); |
|
130 | var optimalStates = new HashSet<HashSet<int>>(setComparer); | |
180 | var queue = new HashSet<HashSet<int>>(setComparer); |
|
131 | var queue = new HashSet<HashSet<int>>(setComparer); | |
181 |
|
132 | |||
182 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΊΠΎΠ½Π΅ΡΠ½ΡΠ΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ, ΡΠ³ΡΡΠΏΠΏΠΈΡΠΎΠ²Π°Π½Π½ΡΠ΅ ΠΏΠΎ ΠΌΠ°ΡΠΊΠ΅ΡΠ°ΠΌ |
|
133 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΊΠΎΠ½Π΅ΡΠ½ΡΠ΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ, ΡΠ³ΡΡΠΏΠΏΠΈΡΠΎΠ²Π°Π½Π½ΡΠ΅ ΠΏΠΎ ΠΌΠ°ΡΠΊΠ΅ΡΠ°ΠΌ | |
183 | optimalStates.UnionWith( |
|
134 | optimalStates.UnionWith( | |
184 | GroupFinalStates() |
|
135 | GroupFinalStates() | |
185 | ); |
|
136 | ); | |
186 |
|
137 | |||
187 | var state = new HashSet<int>( |
|
138 | var state = new HashSet<int>( | |
188 | Enumerable |
|
139 | Enumerable | |
189 | .Range(0, m_stateCount - 1) |
|
140 | .Range(0, m_stateCount - 1) | |
190 | .Where(i => !m_finalStates.Contains(i)) |
|
141 | .Where(i => !m_finalStates.Contains(i)) | |
191 | ); |
|
142 | ); | |
192 |
|
143 | |||
193 | optimalStates.Add(state); |
|
144 | optimalStates.Add(state); | |
194 | queue.Add(state); |
|
145 | queue.Add(state); | |
195 |
|
146 | |||
196 | var rmap = m_transitions |
|
147 | var rmap = m_transitions | |
197 | .GroupBy(t => t.s2) |
|
148 | .GroupBy(t => t.s2) | |
198 | .ToLookup( |
|
149 | .ToLookup( | |
199 | g => g.Key, // s2 |
|
150 | g => g.Key, // s2 | |
200 | g => g.ToLookup(t => t.edge, t => t.s1) |
|
151 | g => g.ToLookup(t => t.edge, t => t.s1) | |
201 | ); |
|
152 | ); | |
202 |
|
153 | |||
203 | while (queue.Count > 0) { |
|
154 | while (queue.Count > 0) { | |
204 | var stateA = queue.First(); |
|
155 | var stateA = queue.First(); | |
205 | queue.Remove(stateA); |
|
156 | queue.Remove(stateA); | |
206 |
|
157 | |||
207 | for (int c = 0; c < m_symbolCount; c++) { |
|
158 | for (int c = 0; c < m_symbolCount; c++) { | |
208 | var stateX = new HashSet<int>(); |
|
159 | var stateX = new HashSet<int>(); | |
209 | foreach(var a in stateA) |
|
160 | foreach(var a in stateA) | |
210 | stateX.UnionWith(rmap[a][c]); // all states from wich 'c' leads to 'a' |
|
161 | stateX.UnionWith(rmap[a][c]); // all states from wich 'c' leads to 'a' | |
211 |
|
162 | |||
212 | foreach (var stateY in optimalStates.ToArray()) { |
|
163 | foreach (var stateY in optimalStates.ToArray()) { | |
213 | if (stateX.Overlaps(stateY) && !stateY.IsSubsetOf(stateX)) { |
|
164 | if (stateX.Overlaps(stateY) && !stateY.IsSubsetOf(stateX)) { | |
214 | var stateR1 = new HashSet<int>(stateY); |
|
165 | var stateR1 = new HashSet<int>(stateY); | |
215 | var stateR2 = new HashSet<int>(stateY); |
|
166 | var stateR2 = new HashSet<int>(stateY); | |
216 |
|
167 | |||
217 | stateR1.IntersectWith(stateX); |
|
168 | stateR1.IntersectWith(stateX); | |
218 | stateR2.ExceptWith(stateX); |
|
169 | stateR2.ExceptWith(stateX); | |
219 |
|
170 | |||
220 | optimalStates.Remove(stateY); |
|
171 | optimalStates.Remove(stateY); | |
221 | optimalStates.Add(stateR1); |
|
172 | optimalStates.Add(stateR1); | |
222 | optimalStates.Add(stateR2); |
|
173 | optimalStates.Add(stateR2); | |
223 |
|
174 | |||
224 | if (queue.Contains(stateY)) { |
|
175 | if (queue.Contains(stateY)) { | |
225 | queue.Remove(stateY); |
|
176 | queue.Remove(stateY); | |
226 | queue.Add(stateR1); |
|
177 | queue.Add(stateR1); | |
227 | queue.Add(stateR2); |
|
178 | queue.Add(stateR2); | |
228 | } else { |
|
179 | } else { | |
229 | queue.Add(stateR1.Count <= stateR2.Count ? stateR1 : stateR2); |
|
180 | queue.Add(stateR1.Count <= stateR2.Count ? stateR1 : stateR2); | |
230 | } |
|
181 | } | |
231 | } |
|
182 | } | |
232 | } |
|
183 | } | |
233 | } |
|
184 | } | |
234 | } |
|
185 | } | |
235 |
|
186 | |||
236 | // ΠΊΠ°ΡΡΠ° ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΎΠΏΡΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΏΠΎ ΡΠΎΠΎΡΠ²Π΅ΡΡΠ²ΡΡΡΠ΅ΠΌΡ Π΅ΠΌΡ ΠΏΡΠΎΡΡΠΎΠΌΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ |
|
187 | // ΠΊΠ°ΡΡΠ° ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΎΠΏΡΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΏΠΎ ΡΠΎΠΎΡΠ²Π΅ΡΡΠ²ΡΡΡΠ΅ΠΌΡ Π΅ΠΌΡ ΠΏΡΠΎΡΡΠΎΠΌΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ | |
237 | var statesMap = stateAlphabet.Reclassify(optimalStateAlphabet, optimalStates); |
|
188 | var nextState = 0; | |
|
189 | foreach (var item in optimalStates) { | |||
|
190 | var id = nextState++; | |||
|
191 | foreach (var s in item) | |||
|
192 | stateMap[s] = id; | |||
|
193 | } | |||
238 |
|
194 | |||
239 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ Π°Π»ΡΠ°Π²ΠΈΡ |
|
195 | // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ Π°Π»ΡΠ°Π²ΠΈΡ | |
240 | // Π²Ρ ΠΎΠ΄Π½ΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ Π½Π΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ, Π΅ΡΠ»ΠΈ Move(s,a1) == Move(s,a2) |
|
196 | // Π²Ρ ΠΎΠ΄Π½ΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ Π½Π΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ, Π΅ΡΠ»ΠΈ Move(s,a1) == Move(s,a2), Π΄Π»Ρ Π»ΡΠ±ΠΎΠ³ΠΎ s | |
241 | var optimalAlphabet = m_transitions |
|
197 | // Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ Π°Π»Π³ΠΎΡΠΈΡΠΌ ΠΊΠ»Π°ΡΡΠ΅ΡΠΈΠ·Π°ΡΠΈΠΈ, ΡΠ½Π°ΡΠ°Π»Π° | |
242 | .GroupBy(t => Tuple.Create(statesMap[t.s1], statesMap[t.s2]), t => t.edge); |
|
198 | // ΡΡΠΈΡΠ°Π΅ΠΌ, ΡΡΠΎ Π²ΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ Π½Π΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ | |
|
199 | ||||
|
200 | var minClasses = new HashSet<HashSet<int>>(setComparer); | |||
|
201 | var alphaQueue = new Queue<HashSet<int>>(); | |||
|
202 | alphaQueue.Enqueue(new HashSet<int>(Enumerable.Range(0,AlphabetSize))); | |||
|
203 | ||||
|
204 | // Π΄Π»Ρ Π²ΡΠ΅Ρ ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ, Π±ΡΠ΄Π΅ΠΌ ΠΏΡΠΎΠ²Π΅ΡΡΡΡ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΠΊΠ»Π°ΡΡ Π½Π° ΡΠ°Π·Π»ΠΈΡΠΈΠΌΠΎΡΡΡ, | |||
|
205 | // Ρ.Π΅. ΡΠΈΠΌΠ²ΠΎΠ»Ρ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ, Π΅ΡΠ»ΠΈ ΠΎΠ½ΠΈ ΠΏΡΠΈΠ²ΠΎΠ΄ΡΡ ΠΊ ΡΠ°Π·Π½ΡΠΌ ΡΠΎΡΡΠΎΡΠ½ΠΈΡΠΌ | |||
|
206 | for (int s = 0 ; s < optimalStates.Count; s++) { | |||
|
207 | var newQueue = new Queue<HashSet<int>>(); | |||
|
208 | ||||
|
209 | foreach (var A in alphaQueue) { | |||
|
210 | // ΠΊΠ»Π°ΡΡΡ ΠΈΠ· ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠΈΠΌΠ²ΠΎΠ»Π° Π΄Π΅Π»ΠΈΡΡ Π±Π΅ΡΠΏΠΎΠ»Π΅Π·Π½ΠΎ, ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΠΈΠΌ ΠΈΡ ΡΡΠ°Π·Ρ Π² | |||
|
211 | // ΡΠ΅Π·ΡΠ»ΡΡΠΈΡΡΡΡΠΈΠΉ Π°Π»ΡΠ°Π²ΠΈΡ | |||
|
212 | if (A.Count == 1) { | |||
|
213 | minClasses.Add(A); | |||
|
214 | continue; | |||
|
215 | } | |||
|
216 | ||||
|
217 | // ΡΠ°Π·Π»ΠΈΡΠ°Π΅ΠΌ ΠΊΠ»Π°ΡΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΡ Π² ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ ΠΎΠΏΡΠΈΠΌΠ°Π»ΡΠ½ΡΠ΅ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ | |||
|
218 | // optimalState -> alphaClass | |||
|
219 | var classes = new Dictionary<int, HashSet<int>>(); | |||
|
220 | ||||
|
221 | foreach (var term in A) { | |||
|
222 | // ΠΈΡΠ΅ΠΌ Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄Ρ ΠΊΠ»Π°ΡΡΠ° ΠΏΠΎ ΡΠΈΠΌΠ²ΠΎΠ»Ρ term | |||
|
223 | var res = m_transitions.Where(t => stateMap[t.s1] == s && t.edge == term).Select(t => stateMap[t.s2]).ToArray(); | |||
243 |
|
224 | |||
244 | var alphabetMap = inputAlphabet.Reclassify(optimalInputAlphabet, optimalAlphabet); |
|
225 | var s2 = res.Length > 0 ? res[0] : -1; | |
|
226 | ||||
|
227 | HashSet<int> a2; | |||
|
228 | if (!classes.TryGetValue(s2, out a2)) { | |||
|
229 | a2 = new HashSet<int>(); | |||
|
230 | newQueue.Enqueue(a2); | |||
|
231 | classes[s2] = a2; | |||
|
232 | } | |||
|
233 | a2.Add(term); | |||
|
234 | } | |||
|
235 | } | |||
|
236 | ||||
|
237 | if (newQueue.Count == 0) | |||
|
238 | break; | |||
|
239 | alphaQueue = newQueue; | |||
|
240 | } | |||
|
241 | ||||
|
242 | // ΠΏΠΎΡΠ»Π΅ ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΡ ΡΠ°Π±ΠΎΡΡ Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° Π² ΠΎΡΠ΅ΡΠ΅Π΄ΠΈ ΠΎΡΡΠ°Π½ΡΡΡΡ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠ΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡΠ΅ ΠΊΠ»Π°ΡΡΡ | |||
|
243 | // Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² | |||
|
244 | foreach (var A in alphaQueue) | |||
|
245 | minClasses.Add(A); | |||
|
246 | ||||
|
247 | // ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ Π°Π»ΡΠ°Π²ΠΈΡΠΎΠ² Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². | |||
|
248 | // ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ ΡΠΈΠΌΠ²ΠΎΠ» DFAConst.UNCLASSIFIED_INPUT ΠΌΠΎΠΆΠ΅Ρ ΠΈΠΌΠ΅ΡΡ | |||
|
249 | // ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅, ΡΠΎΠ³Π΄Π° ΡΠΎΡ ΡΠ°Π½ΠΈΠΌ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ ΠΊΠ»Π°ΡΡ, | |||
|
250 | // ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠΉ ΡΡΠΎΡ ΡΠΈΠΌΠ²ΠΎΠ» Π½Π° ΡΠΎΠΌΠΆΠ΅ ΠΌΠ΅ΡΡΠ΅. | |||
|
251 | ||||
|
252 | var nextCls = 0; | |||
|
253 | foreach (var item in minClasses) { | |||
|
254 | if (nextCls == DFAConst.UNCLASSIFIED_INPUT) | |||
|
255 | nextCls++; | |||
|
256 | ||||
|
257 | // ΡΠΎΡ ΡΠ°Π½ΡΠ΅ΠΌ DFAConst.UNCLASSIFIED_INPUT | |||
|
258 | var cls = item.Contains(DFAConst.UNCLASSIFIED_INPUT) ? DFAConst.UNCLASSIFIED_INPUT : nextCls; | |||
|
259 | ||||
|
260 | foreach (var a in item) | |||
|
261 | alphabetMap[a] = cls; | |||
|
262 | ||||
|
263 | nextCls++; | |||
|
264 | } | |||
245 |
|
265 | |||
246 | // ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ Π°Π²ΡΠΎΠΌΠ°ΡΠ° |
|
266 | // ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ Π°Π²ΡΠΎΠΌΠ°ΡΠ° | |
247 |
optimalDFA.SetInitialState(state |
|
267 | optimalDFA.SetInitialState(stateMap[m_initialState]); | |
248 |
|
268 | |||
249 |
foreach (var sf in m_finalStates. |
|
269 | foreach (var sf in m_finalStates.Select(s => stateMap[s]).Distinct()) | |
250 |
optimalDFA.MarkFinalState(sf |
|
270 | optimalDFA.MarkFinalState(sf); | |
251 |
|
271 | |||
252 |
foreach (var t in m_transitions.Select(t => new AutomatonTransition(state |
|
272 | foreach (var t in m_transitions.Select(t => new AutomatonTransition(stateMap[t.s1],stateMap[t.s2],alphabetMap[t.edge])).Distinct()) | |
253 | optimalDFA.Add(t); |
|
273 | optimalDFA.Add(t); | |
254 |
|
||||
255 | } |
|
274 | } | |
256 |
|
275 | |||
257 | protected void PrintDFA<TInput, TState>(IAlphabet<TInput> inputAlphabet, IAlphabet<TState> stateAlphabet) { |
|
276 | protected void PrintDFA<TInput, TState>(IAlphabet<TInput> inputAlphabet, IAlphabet<TState> stateAlphabet) { | |
258 | Safe.ArgumentNotNull(inputAlphabet, "inputAlphabet"); |
|
277 | Safe.ArgumentNotNull(inputAlphabet, "inputAlphabet"); | |
259 | Safe.ArgumentNotNull(stateAlphabet, "stateAlphabet"); |
|
278 | Safe.ArgumentNotNull(stateAlphabet, "stateAlphabet"); | |
260 |
|
279 | |||
261 | var inputMap = inputAlphabet.CreateReverseMap(); |
|
|||
262 | var stateMap = stateAlphabet.CreateReverseMap(); |
|
|||
263 |
|
||||
264 | for (int i = 0; i < inputMap.Length; i++) |
|
|||
265 | Console.WriteLine("C{0}: {1}", i, String.Join(",", inputMap[i])); |
|
|||
266 |
|
||||
267 |
|
||||
268 | foreach(var t in m_transitions) |
|
280 | foreach(var t in m_transitions) | |
269 | Console.WriteLine( |
|
281 | Console.WriteLine( | |
270 | "[{0}] -{{{1}}}-> [{2}]{3}", |
|
282 | "[{0}] -{{{1}}}-> [{2}]{3}", | |
271 | stateMap[t.s1], |
|
283 | String.Join(",", stateAlphabet.GetSymbols(t.s1)), | |
272 |
String.Join(" |
|
284 | String.Join("", inputAlphabet.GetSymbols(t.edge)), | |
273 | stateMap[t.s2], |
|
285 | String.Join(",", stateAlphabet.GetSymbols(t.s2)), | |
274 | m_finalStates.Contains(t.s2) ? "$" : "" |
|
286 | m_finalStates.Contains(t.s2) ? "$" : "" | |
275 | ); |
|
287 | ); | |
276 |
|
||||
277 | } |
|
288 | } | |
278 |
|
289 | |||
279 | } |
|
290 | } | |
280 | } |
|
291 | } |
@@ -1,56 +1,46 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 |
|
4 | |||
5 | namespace Implab.Automaton { |
|
5 | namespace Implab.Automaton { | |
6 | /// <summary> |
|
6 | /// <summary> | |
7 | /// Dummy alphabet consists of integer numbers which are identical to their classes. |
|
7 | /// Dummy alphabet consists of integer numbers which are identical to their classes. | |
8 | /// </summary> |
|
8 | /// </summary> | |
9 | public class DummyAlphabet : IAlphabet<int> { |
|
9 | public class DummyAlphabet : IAlphabet<int> { | |
10 | readonly int m_size; |
|
10 | readonly int m_size; | |
11 |
|
11 | |||
12 | /// <summary> |
|
12 | /// <summary> | |
13 | /// Creates a new dummy alphabet with given size. |
|
13 | /// Creates a new dummy alphabet with given size. | |
14 | /// </summary> |
|
14 | /// </summary> | |
15 | /// <param name="size">The size of the alphabet, must be greater then zero.</param> |
|
15 | /// <param name="size">The size of the alphabet, must be greater then zero.</param> | |
16 | public DummyAlphabet(int size) { |
|
16 | public DummyAlphabet(int size) { | |
17 | Safe.ArgumentAssert(size > 0); |
|
17 | Safe.ArgumentAssert(size > 0); | |
18 | m_size = 0; |
|
18 | m_size = 0; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | #region IAlphabet implementation |
|
21 | #region IAlphabet implementation | |
22 |
|
22 | |||
23 | public List<int>[] CreateReverseMap() { |
|
23 | public List<int>[] CreateReverseMap() { | |
24 | Enumerable.Range(0, m_size).ToArray(); |
|
24 | Enumerable.Range(0, m_size).ToArray(); | |
25 | } |
|
25 | } | |
26 |
|
26 | |||
27 | public int[] Reclassify(IAlphabetBuilder<int> newAlphabet, IEnumerable<IEnumerable<int>> classes) { |
|
27 | public int Translate(int symbol) { | |
28 | Safe.ArgumentNotNull(newAlphabet, "newAlphabet"); |
|
28 | Safe.ArgumentInRange(symbol, 0, m_size, "symbol"); | |
29 | Safe.ArgumentNotNull(classes, "classes"); |
|
29 | return symbol; | |
30 | var map = new int[m_size]; |
|
|||
31 | foreach (var cls in classes) { |
|
|||
32 | if (cls.Contains(DFAConst.UNCLASSIFIED_INPUT)) |
|
|||
33 | continue; |
|
|||
34 | var newid = newAlphabet.DefineClass(cls); |
|
|||
35 | foreach (var id in cls) |
|
|||
36 | map[id] = newid; |
|
|||
37 | } |
|
|||
38 |
|
||||
39 | return map; |
|
|||
40 | } |
|
30 | } | |
41 |
|
31 | |||
42 |
public |
|
32 | public bool Contains(int symbol) { | |
43 |
Safe.ArgumentInRange(sym |
|
33 | Safe.ArgumentInRange(symbol, 0, m_size, "symbol"); | |
44 |
return |
|
34 | return true; | |
45 | } |
|
35 | } | |
46 |
|
36 | |||
47 | public int Count { |
|
37 | public int Count { | |
48 | get { |
|
38 | get { | |
49 | return m_size; |
|
39 | return m_size; | |
50 | } |
|
40 | } | |
51 | } |
|
41 | } | |
52 |
|
42 | |||
53 | #endregion |
|
43 | #endregion | |
54 | } |
|
44 | } | |
55 | } |
|
45 | } | |
56 |
|
46 |
@@ -1,48 +1,34 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 | using System.Text; |
|
4 | using System.Text; | |
5 | using System.Threading.Tasks; |
|
5 | using System.Threading.Tasks; | |
6 |
|
6 | |||
7 | namespace Implab.Automaton { |
|
7 | namespace Implab.Automaton { | |
8 | /// <summary> |
|
8 | /// <summary> | |
9 | /// ΠΠ»ΡΠ°Π²ΠΈΡ. ΠΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°Π·Π±ΠΈΡΡ Π½Π° ΠΊΠ»Π°ΡΡΡ, ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΊΠ»Π°ΡΡΡ ΠΈΠΌΠ΅ΡΡ Π½Π΅ΠΏΡΠ΅ΡΡΠ²Π½ΡΡ Π½ΡΠΌΠ΅ΡΠ°ΡΠΈΡ, |
|
9 | /// ΠΠ»ΡΠ°Π²ΠΈΡ. ΠΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°Π·Π±ΠΈΡΡ Π½Π° ΠΊΠ»Π°ΡΡΡ, ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΊΠ»Π°ΡΡΡ ΠΈΠΌΠ΅ΡΡ Π½Π΅ΠΏΡΠ΅ΡΡΠ²Π½ΡΡ Π½ΡΠΌΠ΅ΡΠ°ΡΠΈΡ, | |
10 | /// ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΈΡ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΈΠ½Π΄Π΅ΠΊΡΠΎΠ² ΠΌΠ°ΡΡΠΈΠ²ΠΎΠ². |
|
10 | /// ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΈΡ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΈΠ½Π΄Π΅ΠΊΡΠΎΠ² ΠΌΠ°ΡΡΠΈΠ²ΠΎΠ². | |
11 | /// </summary> |
|
11 | /// </summary> | |
12 | /// <remarks> |
|
12 | /// <remarks> | |
13 | /// <para>ΠΠ»ΡΠ°Π²ΠΈΡ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΡΠΌ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π² ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΈΠ½Π΄Π΅ΠΊΡΠΎΠ², ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠΎΠΊΡΠ°ΡΠΈΡΡ ΡΠ°Π·ΠΌΠ΅Ρ ΡΠ°Π±Π»ΠΈΡΡ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΎΠ² Π°Π²ΡΠΎΠΌΠ°ΡΠ° |
|
13 | /// <para>ΠΠ»ΡΠ°Π²ΠΈΡ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΡΠΌ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π² ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΈΠ½Π΄Π΅ΠΊΡΠΎΠ², ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠΎΠΊΡΠ°ΡΠΈΡΡ ΡΠ°Π·ΠΌΠ΅Ρ ΡΠ°Π±Π»ΠΈΡΡ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΎΠ² Π°Π²ΡΠΎΠΌΠ°ΡΠ° | |
14 | /// Π΄Π»Ρ Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π΄Π»Ρ Π½Π΅Π³ΠΎ Π½Π΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ.</para> |
|
14 | /// Π΄Π»Ρ Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π΄Π»Ρ Π½Π΅Π³ΠΎ Π½Π΅ ΡΠ°Π·Π»ΠΈΡΠΈΠΌΡ.</para> | |
15 | /// </remarks> |
|
15 | /// </remarks> | |
16 | /// <typeparam name="TSymbol">Π’ΠΈΠΏ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ².</typeparam> |
|
16 | /// <typeparam name="TSymbol">Π’ΠΈΠΏ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ².</typeparam> | |
17 | public interface IAlphabet<TSymbol> { |
|
17 | public interface IAlphabet<TSymbol> { | |
18 | /// <summary> |
|
18 | /// <summary> | |
19 | /// ΠΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΊΠ»Π°ΡΡΠΎΠ² ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅. |
|
19 | /// ΠΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΊΠ»Π°ΡΡΠΎΠ² ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅. | |
20 | /// </summary> |
|
20 | /// </summary> | |
21 | int Count { get; } |
|
21 | int Count { get; } | |
22 |
|
22 | |||
23 | /// <summary> |
|
23 | /// <summary> | |
24 | /// Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠ°ΡΡΡ ΠΎΠ±ΡΠ°ΡΠ½ΠΎΠ³ΠΎ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΊΠ»Π°ΡΡΠ° ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² Π°Π»ΡΠ°Π²ΠΈΡΠ° ΠΈ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½Π½ΡΠΌ |
|
|||
25 | /// Π΅ΠΌΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΌ ΡΠΈΠΌΠ²ΠΎΠ»Π°ΠΌ. |
|
|||
26 | /// </summary> |
|
|||
27 | /// <returns></returns> |
|
|||
28 | List<TSymbol>[] CreateReverseMap(); |
|
|||
29 |
|
||||
30 | /// <summary> |
|
|||
31 | /// Π‘ΠΎΠ·Π΄Π°Π΅Ρ Π½ΠΎΠ²ΡΠΉ Π°Π»ΡΠ°Π²ΠΈΡ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ, Π³ΠΎΡΠΏΠΏΠΈΡΡΡ Π΅Π³ΠΎ ΡΠΈΠ²ΠΎΠ»Ρ Π² Π±ΠΎΠ»Π΅Π΅ |
|
|||
32 | /// ΠΊΡΡΠΏΠ½ΡΠ΅ Π½Π΅ΠΏΠ΅ΡΠ΅ΡΠ΅ΠΊΠ°ΡΡΠΈΠ΅ΡΡ ΠΊΠ»Π°ΡΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². |
|
|||
33 | /// </summary> |
|
|||
34 | /// <param name="newAlphabet">ΠΠΎΠ²ΡΠΉ, ΠΏΡΡΡΠΎΠΉ Π°Π»ΡΠ°Π²ΠΈΡ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ Π±ΡΠ΄ΡΡ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Ρ ΠΊΠ»Π°ΡΡΡ.</param> |
|
|||
35 | /// <param name="classes">ΠΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΊΠ»Π°ΡΡΠΎΠ² ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ Π°Π»ΡΠ°Π²ΠΈΡΠ°.</param> |
|
|||
36 | /// <returns>ΠΠ°ΡΡΠ° Π΄Π»Ρ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄Π° ΠΊΠ»Π°ΡΡΠΎΠ² ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ |
|
|||
37 | /// Π°Π»ΡΠ°Π²ΠΈΡΠ° ΠΊ ΠΊΠ»Π°ΡΡΠ°ΠΌ Π½ΠΎΠ²ΠΎΠ³ΠΎ.</returns> |
|
|||
38 | /// <remarks>ΠΠΎΠ»Π·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠΊΡΡΠΏΠ½ΠΈΡΡ Π°Π»ΡΠ°Π²ΠΈΡ, ΠΎΠ±ΡΠ΅Π΄ΠΈΠ½ΠΈΠ² ΠΊΠ»Π°ΡΡΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ Π°Π»ΡΠ°Π²ΠΈΡΠ΅. ΠΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΏΡΠΈ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ Π°Π²ΡΠΎΠΌΠ°ΡΠ°.</remarks> |
|
|||
39 | int[] Reclassify(IAlphabetBuilder<TSymbol> newAlphabet, IEnumerable<IEnumerable<int>> classes); |
|
|||
40 |
|
||||
41 | /// <summary> |
|
|||
42 | /// ΠΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΠ΅Ρ Π²Ρ ΠΎΠ΄Π½ΠΎΠΉ ΡΠΈΠΌΠ²ΠΎΠ» Π² ΠΈΠ½Π΄Π΅ΠΊΡ ΡΠΈΠΌΠ²ΠΎΠ»Π° ΠΈΠ· Π°Π»ΡΠ°Π²ΠΈΡΠ°. |
|
24 | /// ΠΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΠ΅Ρ Π²Ρ ΠΎΠ΄Π½ΠΎΠΉ ΡΠΈΠΌΠ²ΠΎΠ» Π² ΠΈΠ½Π΄Π΅ΠΊΡ ΡΠΈΠΌΠ²ΠΎΠ»Π° ΠΈΠ· Π°Π»ΡΠ°Π²ΠΈΡΠ°. | |
43 | /// </summary> |
|
25 | /// </summary> | |
44 | /// <param name="symobl">ΠΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ»</param> |
|
26 | /// <param name="symobl">ΠΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ»</param> | |
45 | /// <returns>ΠΠ½Π΄Π΅ΠΊΡ Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅</returns> |
|
27 | /// <returns>ΠΠ½Π΄Π΅ΠΊΡ Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅</returns> | |
46 | int Translate(TSymbol symobl); |
|
28 | int Translate(TSymbol symobl); | |
|
29 | ||||
|
30 | bool Contains(TSymbol symbol); | |||
|
31 | ||||
|
32 | IEnumerable<TSymbol> GetSymbols(int cls); | |||
47 | } |
|
33 | } | |
48 | } |
|
34 | } |
@@ -1,22 +1,26 | |||||
1 |
|
1 | |||
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 |
|
3 | |||
4 | namespace Implab.Automaton { |
|
4 | namespace Implab.Automaton { | |
5 | public interface IAlphabetBuilder<TSymbol> : IAlphabet<TSymbol> { |
|
5 | public interface IAlphabetBuilder<TSymbol> : IAlphabet<TSymbol> { | |
6 | /// <summary> |
|
6 | /// <summary> | |
7 | /// ΠΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ» Π² Π°Π»ΡΠ°Π²ΠΈΡ, Π΅ΡΠ»ΠΈ ΡΠΈΠΌΠ²ΠΎΠ» ΡΠΆΠ΅ Π±ΡΠ» Π΄ΠΎΠ±Π°Π²Π»Π΅Π½, ΡΠΎ |
|
7 | /// ΠΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ» Π² Π°Π»ΡΠ°Π²ΠΈΡ, Π΅ΡΠ»ΠΈ ΡΠΈΠΌΠ²ΠΎΠ» ΡΠΆΠ΅ Π±ΡΠ» Π΄ΠΎΠ±Π°Π²Π»Π΅Π½, ΡΠΎ | |
8 | /// Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΡΡΡ ΡΠ°Π½Π΅Π΅ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½Π½ΡΠΉ Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ ΠΊΠ»Π°ΡΡ. |
|
8 | /// Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΡΡΡ ΡΠ°Π½Π΅Π΅ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½Π½ΡΠΉ Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ ΠΊΠ»Π°ΡΡ. | |
9 | /// </summary> |
|
9 | /// </summary> | |
10 | /// <param name="symbol">Π‘ΠΈΠΌΠ²ΠΎΠ» Π΄Π»Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΡ.</param> |
|
10 | /// <param name="symbol">Π‘ΠΈΠΌΠ²ΠΎΠ» Π΄Π»Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΡ.</param> | |
11 | /// <returns>ΠΠ½Π΄Π΅ΠΊΡ ΠΊΠ»Π°ΡΡΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½ Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ.</returns> |
|
11 | /// <returns>ΠΠ½Π΄Π΅ΠΊΡ ΠΊΠ»Π°ΡΡΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½ Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ.</returns> | |
12 | int DefineSymbol(TSymbol symbol); |
|
12 | int DefineSymbol(TSymbol symbol); | |
|
13 | ||||
|
14 | int DefineSymbol(TSymbol symbol, int cls); | |||
13 | /// <summary> |
|
15 | /// <summary> | |
14 | /// ΠΠΎΠ°Π±Π²Π»ΡΠ΅ΠΌ ΠΊΠ»Π°ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². ΠΠ½ΠΎΠΆΠ΅ΡΡΠ²Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² |
|
16 | /// ΠΠΎΠ°Π±Π²Π»ΡΠ΅ΠΌ ΠΊΠ»Π°ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². ΠΠ½ΠΎΠΆΠ΅ΡΡΠ²Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² | |
15 | /// Π±ΡΠ΄Π΅Ρ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½ ΡΠΈΠΌΠ²ΠΎΠ» Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅. |
|
17 | /// Π±ΡΠ΄Π΅Ρ ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½ ΡΠΈΠΌΠ²ΠΎΠ» Π² Π°Π»ΡΠ°Π²ΠΈΡΠ΅. | |
16 | /// </summary> |
|
18 | /// </summary> | |
17 | /// <param name="symbols">ΠΠ½ΠΎΠΆΠ΅ΡΡΠΎΠ² ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²</param> |
|
19 | /// <param name="symbols">ΠΠ½ΠΎΠΆΠ΅ΡΡΠΎΠ² ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²</param> | |
18 | /// <returns>ΠΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡ ΡΠΈΠΌΠ²ΠΎΠ»Π° Π°Π»ΡΠ°Π²ΠΈΡΠ°.</returns> |
|
20 | /// <returns>ΠΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡ ΡΠΈΠΌΠ²ΠΎΠ»Π° Π°Π»ΡΠ°Π²ΠΈΡΠ°.</returns> | |
19 | int DefineClass(IEnumerable<TSymbol> symbols); |
|
21 | int DefineClass(IEnumerable<TSymbol> symbols); | |
|
22 | ||||
|
23 | int DefineClass(IEnumerable<TSymbol> symbols, int cls); | |||
20 | } |
|
24 | } | |
21 | } |
|
25 | } | |
22 |
|
26 |
@@ -1,59 +1,53 | |||||
1 | using System.Collections.Generic; |
|
1 | using System.Collections.Generic; | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | namespace Implab.Automaton { |
|
4 | namespace Implab.Automaton { | |
5 | /// <summary> |
|
5 | /// <summary> | |
6 | /// ΠΠΎΠ»Π½ΠΎΡΡΡΡ ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ DFA Π°Π²ΡΠΎΠΌΠ°Ρ, Π΅Π³ΠΎ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅, ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΈ Π²Ρ ΠΎΠ΄Π½ΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ. |
|
6 | /// ΠΠΎΠ»Π½ΠΎΡΡΡΡ ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ DFA Π°Π²ΡΠΎΠΌΠ°Ρ, Π΅Π³ΠΎ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅, ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΈ Π²Ρ ΠΎΠ΄Π½ΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Ρ. | |
7 | /// </summary> |
|
7 | /// </summary> | |
8 | /// <example> |
|
8 | /// <example> | |
9 | /// class MyAutomaton { |
|
9 | /// class MyAutomaton { | |
10 | /// int m_current; |
|
10 | /// int m_current; | |
11 | /// readonly DFAStateDescriptor<string>[] m_automaton; |
|
11 | /// readonly DFAStateDescriptor<string>[] m_automaton; | |
12 | /// readonly IAlphabet<MyCommands> m_commands; |
|
12 | /// readonly IAlphabet<MyCommands> m_commands; | |
13 | /// |
|
13 | /// | |
14 | /// public MyAutomaton(IDFADefinition<MyCommands,MyStates,string> definition) { |
|
14 | /// public MyAutomaton(IDFADefinition<MyCommands,MyStates,string> definition) { | |
15 | /// m_current = definition.StateAlphabet.Translate(MyStates.Initial); |
|
15 | /// m_current = definition.StateAlphabet.Translate(MyStates.Initial); | |
16 | /// m_automaton = definition.GetTransitionTable(); |
|
16 | /// m_automaton = definition.GetTransitionTable(); | |
17 | /// m_commands = definition.InputAlphabet; |
|
17 | /// m_commands = definition.InputAlphabet; | |
18 | /// } |
|
18 | /// } | |
19 | /// |
|
19 | /// | |
20 | /// // defined a method which will move the automaton to the next state |
|
20 | /// // defined a method which will move the automaton to the next state | |
21 | /// public void Move(MyCommands cmd) { |
|
21 | /// public void Move(MyCommands cmd) { | |
22 | /// // use transition map to determine the next state |
|
22 | /// // use transition map to determine the next state | |
23 | /// var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)]; |
|
23 | /// var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)]; | |
24 | /// |
|
24 | /// | |
25 | /// // validate that we aren't in the unreachable state |
|
25 | /// // validate that we aren't in the unreachable state | |
26 | /// if (next == DFAConst.UNREACHABLE_STATE) |
|
26 | /// if (next == DFAConst.UNREACHABLE_STATE) | |
27 | /// throw new InvalidOperationException("The specified command is invalid"); |
|
27 | /// throw new InvalidOperationException("The specified command is invalid"); | |
28 | /// |
|
28 | /// | |
29 | /// // if everything is ok |
|
29 | /// // if everything is ok | |
30 | /// m_current = next; |
|
30 | /// m_current = next; | |
31 | /// } |
|
31 | /// } | |
32 | /// } |
|
32 | /// } | |
33 | /// </example> |
|
33 | /// </example> | |
34 | public interface IDFATable : IEnumerable<AutomatonTransition> { |
|
34 | public interface IDFATable : IEnumerable<AutomatonTransition> { | |
35 | /// <summary> |
|
|||
36 | /// Π’Π°Π±Π»ΠΈΡΠ° ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΎΠ² ΡΠΎΡΡΠΎΡΠ½ΠΈΠΉ Π°Π²ΡΠΎΠΌΠ°ΡΠ° |
|
|||
37 | /// </summary> |
|
|||
38 | /// <returns>The transition table.</returns> |
|
|||
39 | DFAStateDescriptior[] GetTransitionTable(); |
|
|||
40 |
|
||||
41 | int StateCount { |
|
35 | int StateCount { | |
42 | get; |
|
36 | get; | |
43 | } |
|
37 | } | |
44 |
|
38 | |||
45 | int AlphabetSize { |
|
39 | int AlphabetSize { | |
46 | get; |
|
40 | get; | |
47 | } |
|
41 | } | |
48 |
|
42 | |||
49 | int InitialState { |
|
43 | int InitialState { | |
50 | get; |
|
44 | get; | |
51 | } |
|
45 | } | |
52 |
|
46 | |||
53 | bool IsFinalState(int s); |
|
47 | bool IsFinalState(int s); | |
54 |
|
48 | |||
55 | IEnumerable<int> FinalStates { |
|
49 | IEnumerable<int> FinalStates { | |
56 | get; |
|
50 | get; | |
57 | } |
|
51 | } | |
58 | } |
|
52 | } | |
59 | } |
|
53 | } |
@@ -1,108 +1,86 | |||||
1 | using Implab; |
|
1 | using Implab; | |
2 | using System; |
|
2 | using System; | |
3 | using System.Collections.Generic; |
|
3 | using System.Collections.Generic; | |
4 | using System.Diagnostics; |
|
4 | using System.Diagnostics; | |
5 | using System.Linq; |
|
5 | using System.Linq; | |
6 |
|
6 | |||
7 | namespace Implab.Automaton { |
|
7 | namespace Implab.Automaton { | |
8 | /// <summary> |
|
8 | /// <summary> | |
9 | /// Indexed alphabet is the finite set of symbols where each symbol has a zero-based unique index. |
|
9 | /// Indexed alphabet is the finite set of symbols where each symbol has a zero-based unique index. | |
10 | /// </summary> |
|
10 | /// </summary> | |
11 | /// <remarks> |
|
11 | /// <remarks> | |
12 | /// Indexed alphabets are usefull in bulting efficient translations from source alphabet |
|
12 | /// Indexed alphabets are usefull in bulting efficient translations from source alphabet | |
13 | /// to the input alphabet of the automaton. It's assumed that the index to the symbol match |
|
13 | /// to the input alphabet of the automaton. It's assumed that the index to the symbol match | |
14 | /// is well known and documented. |
|
14 | /// is well known and documented. | |
15 | /// </remarks> |
|
15 | /// </remarks> | |
16 | public abstract class IndexedAlphabetBase<T> : IAlphabetBuilder<T> { |
|
16 | public abstract class IndexedAlphabetBase<T> : IAlphabetBuilder<T> { | |
17 | int m_nextId = 1; |
|
17 | int m_nextId = 1; | |
18 | readonly int[] m_map; |
|
18 | readonly int[] m_map; | |
19 |
|
19 | |||
20 | public int Count { |
|
|||
21 | get { return m_nextId; } |
|
|||
22 | } |
|
|||
23 |
|
||||
24 | protected IndexedAlphabetBase(int mapSize) { |
|
20 | protected IndexedAlphabetBase(int mapSize) { | |
25 | m_map = new int[mapSize]; |
|
21 | m_map = new int[mapSize]; | |
26 | } |
|
22 | } | |
27 |
|
23 | |||
28 | protected IndexedAlphabetBase(int[] map) { |
|
24 | protected IndexedAlphabetBase(int[] map) { | |
29 | Debug.Assert(map != null); |
|
25 | Debug.Assert(map != null && map.Length > 0); | |
|
26 | Debug.Assert(map.All(x => x >= 0)); | |||
30 |
|
27 | |||
31 | m_map = map; |
|
28 | m_map = map; | |
32 | m_nextId = map.Max() + 1; |
|
29 | m_nextId = map.Max() + 1; | |
33 | } |
|
30 | } | |
34 |
|
31 | |||
35 | public int DefineSymbol(T symbol) { |
|
32 | public int DefineSymbol(T symbol) { | |
36 | var index = GetSymbolIndex(symbol); |
|
33 | var index = GetSymbolIndex(symbol); | |
37 | if (m_map[index] == DFAConst.UNCLASSIFIED_INPUT) |
|
34 | if (m_map[index] == DFAConst.UNCLASSIFIED_INPUT) | |
38 | m_map[index] = m_nextId++; |
|
35 | m_map[index] = m_nextId++; | |
39 | return m_map[index]; |
|
36 | return m_map[index]; | |
40 | } |
|
37 | } | |
41 |
|
38 | |||
|
39 | public int DefineSymbol(T symbol, int cls) { | |||
|
40 | var index = GetSymbolIndex(symbol); | |||
|
41 | m_map[index] = cls; | |||
|
42 | m_nextId = Math.Max(cls + 1, m_nextId); | |||
|
43 | return cls; | |||
|
44 | } | |||
|
45 | ||||
42 | public int DefineClass(IEnumerable<T> symbols) { |
|
46 | public int DefineClass(IEnumerable<T> symbols) { | |
|
47 | return DefineClass(symbols, m_nextId); | |||
|
48 | } | |||
|
49 | ||||
|
50 | public int DefineClass(IEnumerable<T> symbols, int cls) { | |||
43 | Safe.ArgumentNotNull(symbols, "symbols"); |
|
51 | Safe.ArgumentNotNull(symbols, "symbols"); | |
44 | symbols = symbols.Distinct(); |
|
52 | symbols = symbols.Distinct(); | |
45 |
|
53 | |||
46 |
foreach (var symbol in symbols) |
|
54 | foreach (var symbol in symbols) | |
47 |
|
|
55 | m_map[GetSymbolIndex(symbol)] = cls; | |
48 | if (m_map[index] == DFAConst.UNCLASSIFIED_INPUT) |
|
56 | ||
49 | m_map[GetSymbolIndex(symbol)] = m_nextId; |
|
57 | m_nextId = Math.Max(cls + 1, m_nextId); | |
50 | else |
|
|||
51 | throw new InvalidOperationException(String.Format("Symbol '{0}' already in use", symbol)); |
|
|||
52 | } |
|
|||
53 | return m_nextId++; |
|
|||
54 | } |
|
|||
55 |
|
||||
56 | public List<T>[] CreateReverseMap() { |
|
|||
57 | return |
|
|||
58 | Enumerable.Range(0, Count) |
|
|||
59 | .Select( |
|
|||
60 | i => InputSymbols |
|
|||
61 | .Where(x => i != DFAConst.UNCLASSIFIED_INPUT && m_map[GetSymbolIndex(x)] == i) |
|
|||
62 | .ToList() |
|
|||
63 | ) |
|
|||
64 | .ToArray(); |
|
|||
65 | } |
|
|||
66 |
|
58 | |||
67 | public int[] Reclassify(IAlphabetBuilder<T> newAlphabet, IEnumerable<IEnumerable<int>> classes) { |
|
59 | return cls; | |
68 | Safe.ArgumentNotNull(newAlphabet, "newAlphabet"); |
|
|||
69 | Safe.ArgumentNotNull(classes, "classes"); |
|
|||
70 | var reverseMap = CreateReverseMap(); |
|
|||
71 |
|
||||
72 | var translationMap = new int[Count]; |
|
|||
73 |
|
||||
74 | foreach (var scl in classes) { |
|
|||
75 | // skip if the supper class contains the unclassified element |
|
|||
76 | if (scl.Contains(DFAConst.UNCLASSIFIED_INPUT)) |
|
|||
77 | continue; |
|
|||
78 | var range = new List<T>(); |
|
|||
79 | foreach (var cl in scl) { |
|
|||
80 | if (cl < 0 || cl >= reverseMap.Length) |
|
|||
81 | throw new ArgumentOutOfRangeException(String.Format("Class {0} is not valid for the current alphabet", cl)); |
|
|||
82 | range.AddRange(reverseMap[cl]); |
|
|||
83 | } |
|
|||
84 | var newClass = newAlphabet.DefineClass(range); |
|
|||
85 | foreach (var cl in scl) |
|
|||
86 | translationMap[cl] = newClass; |
|
|||
87 | } |
|
|||
88 |
|
||||
89 | return translationMap; |
|
|||
90 | } |
|
60 | } | |
91 |
|
61 | |||
92 | public virtual int Translate(T symbol) { |
|
62 | public virtual int Translate(T symbol) { | |
93 | return m_map[GetSymbolIndex(symbol)]; |
|
63 | return m_map[GetSymbolIndex(symbol)]; | |
94 | } |
|
64 | } | |
95 |
|
65 | |||
|
66 | public int Count { | |||
|
67 | get { return m_nextId; } | |||
|
68 | } | |||
|
69 | ||||
|
70 | public bool Contains(T symbol) { | |||
|
71 | return true; | |||
|
72 | } | |||
|
73 | ||||
96 | public abstract int GetSymbolIndex(T symbol); |
|
74 | public abstract int GetSymbolIndex(T symbol); | |
97 |
|
75 | |||
98 | public abstract IEnumerable<T> InputSymbols { get; } |
|
76 | public abstract IEnumerable<T> InputSymbols { get; } | |
99 |
|
77 | |||
100 | /// <summary> |
|
78 | /// <summary> | |
101 | /// Gets the translation map from the index of the symbol to it's class this is usefull for the optimized input symbols transtaion. |
|
79 | /// Gets the translation map from the index of the symbol to it's class this is usefull for the optimized input symbols transtaion. | |
102 | /// </summary> |
|
80 | /// </summary> | |
103 | /// <returns>The translation map.</returns> |
|
81 | /// <returns>The translation map.</returns> | |
104 | public int[] GetTranslationMap() { |
|
82 | public int[] GetTranslationMap() { | |
105 | return m_map; |
|
83 | return m_map; | |
106 | } |
|
84 | } | |
107 | } |
|
85 | } | |
108 | } |
|
86 | } |
@@ -1,109 +1,74 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 |
|
4 | |||
5 | namespace Implab.Automaton { |
|
5 | namespace Implab.Automaton { | |
6 | public class MapAlphabet<T> : IAlphabetBuilder<T> { |
|
6 | public class MapAlphabet<T> : IAlphabetBuilder<T> { | |
7 | readonly Dictionary<T,int> m_map; |
|
7 | readonly Dictionary<T,int> m_map; | |
8 |
int m_nextCls |
|
8 | int m_nextCls; | |
|
9 | readonly bool m_supportUnclassified; | |||
9 |
|
10 | |||
10 | public MapAlphabet() { |
|
11 | public MapAlphabet(bool supportUnclassified, IEqualityComparer<T> comparer) { | |
11 | m_map = new Dictionary<T, int>(); |
|
12 | m_map = comparer != null ? new Dictionary<T, int>(comparer) : new Dictionary<T,int>(); | |
12 | } |
|
13 | m_supportUnclassified = supportUnclassified; | |
13 |
|
14 | m_nextCls = supportUnclassified ? 1 : 0; | ||
14 | public MapAlphabet(IEqualityComparer<T> comparer) { |
|
|||
15 | m_map = new Dictionary<T, int>(comparer); |
|
|||
16 | } |
|
15 | } | |
17 |
|
16 | |||
18 | #region IAlphabetBuilder implementation |
|
17 | #region IAlphabetBuilder implementation | |
19 |
|
18 | |||
20 | public int DefineSymbol(T symbol) { |
|
19 | public int DefineSymbol(T symbol) { | |
21 | int cls; |
|
20 | int cls; | |
22 |
|
|
21 | return m_map.TryGetValue(symbol, out cls) ? cls : DefineSymbol(symbol, m_nextCls); | |
23 | return cls; |
|
22 | } | |
24 |
|
23 | |||
25 | cls = m_nextCls++; |
|
24 | public int DefineSymbol(T symbol, int cls) { | |
|
25 | Safe.ArgumentAssert(cls >= 0, "cls"); | |||
26 |
|
26 | |||
|
27 | m_nextCls = Math.Max(cls + 1, m_nextCls); | |||
27 | m_map.Add(symbol, cls); |
|
28 | m_map.Add(symbol, cls); | |
28 |
|
||||
29 | return cls; |
|
29 | return cls; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | public int DefineClass(IEnumerable<T> symbols) { |
|
32 | public int DefineClass(IEnumerable<T> symbols) { | |
|
33 | return DefineClass(symbols, m_nextCls); | |||
|
34 | } | |||
|
35 | ||||
|
36 | public int DefineClass(IEnumerable<T> symbols, int cls) { | |||
|
37 | Safe.ArgumentAssert(cls >= 0, "cls"); | |||
33 | Safe.ArgumentNotNull(symbols, "symbols"); |
|
38 | Safe.ArgumentNotNull(symbols, "symbols"); | |
|
39 | ||||
|
40 | m_nextCls = Math.Max(cls + 1, m_nextCls); | |||
34 | symbols = symbols.Distinct(); |
|
41 | symbols = symbols.Distinct(); | |
35 |
|
42 | |||
36 |
foreach (var symbol in symbols) |
|
43 | foreach (var symbol in symbols) | |
37 |
|
|
44 | m_map[symbol] = cls; | |
38 | m_map.Add(symbol, m_nextCls); |
|
45 | return cls; | |
39 | else |
|
|||
40 | throw new InvalidOperationException(String.Format("Symbol '{0}' already in use", symbol)); |
|
|||
41 | } |
|
|||
42 | return m_nextCls++; |
|
|||
43 | } |
|
46 | } | |
44 |
|
47 | |||
45 | #endregion |
|
48 | #endregion | |
46 |
|
49 | |||
47 | #region IAlphabet implementation |
|
50 | #region IAlphabet implementation | |
48 |
|
51 | |||
49 | public List<T>[] CreateReverseMap() { |
|
52 | public int Translate(T symbol) { | |
50 | var empty = new List<T>(); |
|
|||
51 | var rmap = new List<T>[m_nextCls]; |
|
|||
52 |
|
||||
53 | for (int i = 0; i < rmap.Length; i++) |
|
|||
54 | rmap[i] = empty; |
|
|||
55 |
|
||||
56 | foreach (var pair in m_map) { |
|
|||
57 | var symbols = rmap[pair.Value]; |
|
|||
58 | if (symbols == null) { |
|
|||
59 | symbols = new List<T>(); |
|
|||
60 | rmap[pair.Value] = symbols; |
|
|||
61 | } |
|
|||
62 |
|
||||
63 | symbols.Add(pair.Key); |
|
|||
64 | } |
|
|||
65 |
|
||||
66 | return rmap; |
|
|||
67 | } |
|
|||
68 |
|
||||
69 | public int[] Reclassify(IAlphabetBuilder<T> newAlphabet, IEnumerable<IEnumerable<int>> classes) { |
|
|||
70 | Safe.ArgumentNotNull(newAlphabet, "newAlphabet"); |
|
|||
71 | Safe.ArgumentNotNull(classes, "classes"); |
|
|||
72 |
|
||||
73 | var rmap = CreateReverseMap(); |
|
|||
74 | var map = new int[rmap.Length]; |
|
|||
75 |
|
||||
76 | foreach (var cls in classes) { |
|
|||
77 | if (cls.Contains(DFAConst.UNCLASSIFIED_INPUT)) |
|
|||
78 | continue; |
|
|||
79 |
|
||||
80 | var symbols = new List<T>(); |
|
|||
81 | foreach (var id in cls) { |
|
|||
82 | if (id < 0 || id >= rmap.Length) |
|
|||
83 | throw new ArgumentOutOfRangeException(String.Format("Class {0} is not valid for the current alphabet", id)); |
|
|||
84 | if (rmap[id] != null) |
|
|||
85 | symbols.AddRange(rmap[id]); |
|
|||
86 | } |
|
|||
87 |
|
||||
88 | var newId = newAlphabet.DefineClass(symbols); |
|
|||
89 |
|
||||
90 | foreach (var id in cls) |
|
|||
91 | map[id] = newId; |
|
|||
92 | } |
|
|||
93 | } |
|
|||
94 |
|
||||
95 | public int Translate(T symobl) { |
|
|||
96 | int cls; |
|
53 | int cls; | |
97 |
|
|
54 | if (m_map.TryGetValue(symbol, out cls)) | |
|
55 | return cls; | |||
|
56 | if (!m_supportUnclassified) | |||
|
57 | throw new ArgumentOutOfRangeException("symbol", "The specified symbol isn't in the alphabet"); | |||
|
58 | return DFAConst.UNCLASSIFIED_INPUT; | |||
98 | } |
|
59 | } | |
99 |
|
60 | |||
100 | public int Count { |
|
61 | public int Count { | |
101 | get { |
|
62 | get { | |
102 | return m_nextCls; |
|
63 | return m_nextCls; | |
103 | } |
|
64 | } | |
104 | } |
|
65 | } | |
105 |
|
66 | |||
|
67 | public bool Contains(T symbol) { | |||
|
68 | return m_supportUnclassified || m_map.ContainsKey(symbol); | |||
|
69 | } | |||
|
70 | ||||
106 | #endregion |
|
71 | #endregion | |
107 | } |
|
72 | } | |
108 | } |
|
73 | } | |
109 |
|
74 |
@@ -1,69 +1,69 | |||||
1 | using System; |
|
1 | using System; | |
2 | using System.Collections.Generic; |
|
2 | using System.Collections.Generic; | |
3 | using System.Linq; |
|
3 | using System.Linq; | |
4 |
|
4 | |||
5 | namespace Implab.Automaton.RegularExpressions { |
|
5 | namespace Implab.Automaton.RegularExpressions { | |
6 | public class RegularDFADefinition<TInput, TTag> : DFATable { |
|
6 | public class RegularDFADefinition<TInput, TTag> : DFATable { | |
7 |
|
7 | |||
8 | readonly Dictionary<int,TTag[]> m_tags = new Dictionary<int, TTag[]>(); |
|
8 | readonly Dictionary<int,TTag[]> m_tags = new Dictionary<int, TTag[]>(); | |
9 | readonly IAlphabet<TInput> m_alphabet; |
|
9 | readonly IAlphabet<TInput> m_alphabet; | |
10 |
|
10 | |||
11 | public RegularDFADefinition(IAlphabet<TInput> alphabet) { |
|
11 | public RegularDFADefinition(IAlphabet<TInput> alphabet) { | |
12 | Safe.ArgumentNotNull(alphabet, "aplhabet"); |
|
12 | Safe.ArgumentNotNull(alphabet, "aplhabet"); | |
13 |
|
13 | |||
14 | m_alphabet = alphabet; |
|
14 | m_alphabet = alphabet; | |
15 | } |
|
15 | } | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | public IAlphabet<TInput> InputAlphabet { |
|
18 | public IAlphabet<TInput> InputAlphabet { | |
19 | get { |
|
19 | get { | |
20 | return m_alphabet; |
|
20 | return m_alphabet; | |
21 | } |
|
21 | } | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | protected override DFAStateDescriptior[] ConstructTransitionTable() { |
|
|||
25 | if (InputAlphabet.Count != m_alphabet.Count) |
|
|||
26 | throw new InvalidOperationException("The alphabet doesn't match the transition table"); |
|
|||
27 |
|
||||
28 | return base.ConstructTransitionTable(); |
|
|||
29 | } |
|
|||
30 |
|
||||
31 | public void MarkFinalState(int s, TTag[] tags) { |
|
24 | public void MarkFinalState(int s, TTag[] tags) { | |
32 | MarkFinalState(s); |
|
25 | MarkFinalState(s); | |
33 | SetStateTag(s, tags); |
|
26 | SetStateTag(s, tags); | |
34 | } |
|
27 | } | |
35 |
|
28 | |||
36 | public void SetStateTag(int s, TTag[] tags) { |
|
29 | public void SetStateTag(int s, TTag[] tags) { | |
37 | Safe.ArgumentNotNull(tags, "tags"); |
|
30 | Safe.ArgumentNotNull(tags, "tags"); | |
38 | m_tags[s] = tags; |
|
31 | m_tags[s] = tags; | |
39 | } |
|
32 | } | |
40 |
|
33 | |||
41 | public TTag[] GetStateTag(int s) { |
|
34 | public TTag[] GetStateTag(int s) { | |
42 | TTag[] tags; |
|
35 | TTag[] tags; | |
43 | return m_tags.TryGetValue(s, out tags) ? tags : new TTag[0]; |
|
36 | return m_tags.TryGetValue(s, out tags) ? tags : new TTag[0]; | |
44 | } |
|
37 | } | |
45 |
|
38 | |||
46 | /// <summary> |
|
39 | /// <summary> | |
47 | /// Optimize the specified alphabet. |
|
40 | /// Optimize the specified alphabet. | |
48 | /// </summary> |
|
41 | /// </summary> | |
49 | /// <param name="alphabet">ΠΡΡΡΠΎΠΉ Π°Π»ΡΠ°Π²ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ΄Π΅Ρ Π·ΠΏΠΎΠ»Π½Π΅Π½ Π² ΠΏΡΠΎΡΠ΅ΡΡΠ΅ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ.</param> |
|
42 | /// <param name="alphabet">ΠΡΡΡΠΎΠΉ Π°Π»ΡΠ°Π²ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ΄Π΅Ρ Π·ΠΏΠΎΠ»Π½Π΅Π½ Π² ΠΏΡΠΎΡΠ΅ΡΡΠ΅ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ.</param> | |
50 | public RegularDFADefinition<TInput,TTag> Optimize(IAlphabetBuilder<TInput> alphabet) { |
|
43 | public RegularDFADefinition<TInput,TTag> Optimize(IAlphabetBuilder<TInput> alphabet) { | |
51 | Safe.ArgumentNotNull(alphabet, "alphabet"); |
|
44 | Safe.ArgumentNotNull(alphabet, "alphabet"); | |
52 |
|
45 | |||
53 | var dfaTable = new RegularDFADefinition<TInput, TTag>(alphabet); |
|
46 | var dfaTable = new RegularDFADefinition<TInput, TTag>(alphabet); | |
54 |
|
47 | |||
55 | var states = new DummyAlphabet(StateCount); |
|
48 | var states = new DummyAlphabet(StateCount); | |
56 |
var |
|
49 | var alphaMap = new Dictionary<int,int>(); | |
|
50 | var stateMap = new Dictionary<int,int>(); | |||
|
51 | Optimize(dfaTable, alphaMap, stateMap); | |||
57 |
|
52 | |||
58 | Optimize(dfaTable, InputAlphabet, alphabet, states, map); |
|
53 | foreach (var g in m_tags.Where(x => x.Key < StateCount).GroupBy(x => stateMap[x.Key], x => x.Value )) | |
59 |
|
||||
60 | foreach (var g in m_tags.Where(x => x.Key < StateCount).GroupBy(x => map.Translate(x.Key), x => x.Value )) |
|
|||
61 | dfaTable.SetStateTag(g.Key, g.SelectMany(x => x).ToArray()); |
|
54 | dfaTable.SetStateTag(g.Key, g.SelectMany(x => x).ToArray()); | |
62 |
|
55 | |||
63 | return dfaTable; |
|
56 | return dfaTable; | |
64 | } |
|
57 | } | |
65 |
|
58 | |||
|
59 | protected override IEnumerable<HashSet<int>> GroupFinalStates() { | |||
|
60 | var arrayComparer = new CustomEqualityComparer<TTag[]>( | |||
|
61 | (x,y) => x.Length == y.Length && x.All(it => y.Contains(it)), | |||
|
62 | x => x.Sum(it => x.GetHashCode()) | |||
|
63 | ); | |||
|
64 | return FinalStates.GroupBy(x => m_tags[x], arrayComparer).Select(g => new HashSet<int>(g)); | |||
|
65 | } | |||
66 |
|
66 | |||
67 | } |
|
67 | } | |
68 | } |
|
68 | } | |
69 |
|
69 |
@@ -1,271 +1,272 | |||||
1 | ο»Ώ<?xml version="1.0" encoding="utf-8"?> |
|
1 | ο»Ώ<?xml version="1.0" encoding="utf-8"?> | |
2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
2 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | <PropertyGroup> |
|
3 | <PropertyGroup> | |
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> |
|
6 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> | |
7 | <OutputType>Library</OutputType> |
|
7 | <OutputType>Library</OutputType> | |
8 | <RootNamespace>Implab</RootNamespace> |
|
8 | <RootNamespace>Implab</RootNamespace> | |
9 | <AssemblyName>Implab</AssemblyName> |
|
9 | <AssemblyName>Implab</AssemblyName> | |
10 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
10 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | |
11 | <ReleaseVersion>0.2</ReleaseVersion> |
|
11 | <ReleaseVersion>0.2</ReleaseVersion> | |
12 | <ProductVersion>8.0.30703</ProductVersion> |
|
12 | <ProductVersion>8.0.30703</ProductVersion> | |
13 | <SchemaVersion>2.0</SchemaVersion> |
|
13 | <SchemaVersion>2.0</SchemaVersion> | |
14 | </PropertyGroup> |
|
14 | </PropertyGroup> | |
15 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
15 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
16 | <DebugSymbols>true</DebugSymbols> |
|
16 | <DebugSymbols>true</DebugSymbols> | |
17 | <DebugType>full</DebugType> |
|
17 | <DebugType>full</DebugType> | |
18 | <Optimize>false</Optimize> |
|
18 | <Optimize>false</Optimize> | |
19 | <OutputPath>bin\Debug</OutputPath> |
|
19 | <OutputPath>bin\Debug</OutputPath> | |
20 | <DefineConstants>TRACE;DEBUG;</DefineConstants> |
|
20 | <DefineConstants>TRACE;DEBUG;</DefineConstants> | |
21 | <ErrorReport>prompt</ErrorReport> |
|
21 | <ErrorReport>prompt</ErrorReport> | |
22 | <WarningLevel>4</WarningLevel> |
|
22 | <WarningLevel>4</WarningLevel> | |
23 | <ConsolePause>false</ConsolePause> |
|
23 | <ConsolePause>false</ConsolePause> | |
24 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
24 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
25 | </PropertyGroup> |
|
25 | </PropertyGroup> | |
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
27 | <DebugType>full</DebugType> |
|
27 | <DebugType>full</DebugType> | |
28 | <Optimize>true</Optimize> |
|
28 | <Optimize>true</Optimize> | |
29 | <OutputPath>bin\Release</OutputPath> |
|
29 | <OutputPath>bin\Release</OutputPath> | |
30 | <ErrorReport>prompt</ErrorReport> |
|
30 | <ErrorReport>prompt</ErrorReport> | |
31 | <WarningLevel>4</WarningLevel> |
|
31 | <WarningLevel>4</WarningLevel> | |
32 | <ConsolePause>false</ConsolePause> |
|
32 | <ConsolePause>false</ConsolePause> | |
33 | </PropertyGroup> |
|
33 | </PropertyGroup> | |
34 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> |
|
34 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> | |
35 | <DebugSymbols>true</DebugSymbols> |
|
35 | <DebugSymbols>true</DebugSymbols> | |
36 | <DebugType>full</DebugType> |
|
36 | <DebugType>full</DebugType> | |
37 | <Optimize>false</Optimize> |
|
37 | <Optimize>false</Optimize> | |
38 | <OutputPath>bin\Debug</OutputPath> |
|
38 | <OutputPath>bin\Debug</OutputPath> | |
39 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> |
|
39 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> | |
40 | <ErrorReport>prompt</ErrorReport> |
|
40 | <ErrorReport>prompt</ErrorReport> | |
41 | <WarningLevel>4</WarningLevel> |
|
41 | <WarningLevel>4</WarningLevel> | |
42 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
42 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
43 | <ConsolePause>false</ConsolePause> |
|
43 | <ConsolePause>false</ConsolePause> | |
44 | </PropertyGroup> |
|
44 | </PropertyGroup> | |
45 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> |
|
45 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> | |
46 | <Optimize>true</Optimize> |
|
46 | <Optimize>true</Optimize> | |
47 | <OutputPath>bin\Release</OutputPath> |
|
47 | <OutputPath>bin\Release</OutputPath> | |
48 | <ErrorReport>prompt</ErrorReport> |
|
48 | <ErrorReport>prompt</ErrorReport> | |
49 | <WarningLevel>4</WarningLevel> |
|
49 | <WarningLevel>4</WarningLevel> | |
50 | <ConsolePause>false</ConsolePause> |
|
50 | <ConsolePause>false</ConsolePause> | |
51 | <DefineConstants>NET_4_5</DefineConstants> |
|
51 | <DefineConstants>NET_4_5</DefineConstants> | |
52 | </PropertyGroup> |
|
52 | </PropertyGroup> | |
53 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' "> |
|
53 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' "> | |
54 | <DebugSymbols>true</DebugSymbols> |
|
54 | <DebugSymbols>true</DebugSymbols> | |
55 | <DebugType>full</DebugType> |
|
55 | <DebugType>full</DebugType> | |
56 | <Optimize>false</Optimize> |
|
56 | <Optimize>false</Optimize> | |
57 | <OutputPath>bin\Debug</OutputPath> |
|
57 | <OutputPath>bin\Debug</OutputPath> | |
58 | <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants> |
|
58 | <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants> | |
59 | <ErrorReport>prompt</ErrorReport> |
|
59 | <ErrorReport>prompt</ErrorReport> | |
60 | <WarningLevel>4</WarningLevel> |
|
60 | <WarningLevel>4</WarningLevel> | |
61 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
61 | <RunCodeAnalysis>true</RunCodeAnalysis> | |
62 | <ConsolePause>false</ConsolePause> |
|
62 | <ConsolePause>false</ConsolePause> | |
63 | </PropertyGroup> |
|
63 | </PropertyGroup> | |
64 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' "> |
|
64 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' "> | |
65 | <Optimize>true</Optimize> |
|
65 | <Optimize>true</Optimize> | |
66 | <OutputPath>bin\Release</OutputPath> |
|
66 | <OutputPath>bin\Release</OutputPath> | |
67 | <DefineConstants>NET_4_5;MONO;</DefineConstants> |
|
67 | <DefineConstants>NET_4_5;MONO;</DefineConstants> | |
68 | <ErrorReport>prompt</ErrorReport> |
|
68 | <ErrorReport>prompt</ErrorReport> | |
69 | <WarningLevel>4</WarningLevel> |
|
69 | <WarningLevel>4</WarningLevel> | |
70 | <ConsolePause>false</ConsolePause> |
|
70 | <ConsolePause>false</ConsolePause> | |
71 | </PropertyGroup> |
|
71 | </PropertyGroup> | |
72 | <ItemGroup> |
|
72 | <ItemGroup> | |
73 | <Reference Include="System" /> |
|
73 | <Reference Include="System" /> | |
74 | <Reference Include="System.Xml" /> |
|
74 | <Reference Include="System.Xml" /> | |
75 | <Reference Include="mscorlib" /> |
|
75 | <Reference Include="mscorlib" /> | |
76 | </ItemGroup> |
|
76 | </ItemGroup> | |
77 | <ItemGroup> |
|
77 | <ItemGroup> | |
78 | <Compile Include="CustomEqualityComparer.cs" /> |
|
78 | <Compile Include="CustomEqualityComparer.cs" /> | |
79 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> |
|
79 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> | |
80 | <Compile Include="Diagnostics\EventText.cs" /> |
|
80 | <Compile Include="Diagnostics\EventText.cs" /> | |
81 | <Compile Include="Diagnostics\LogChannel.cs" /> |
|
81 | <Compile Include="Diagnostics\LogChannel.cs" /> | |
82 | <Compile Include="Diagnostics\LogicalOperation.cs" /> |
|
82 | <Compile Include="Diagnostics\LogicalOperation.cs" /> | |
83 | <Compile Include="Diagnostics\TextFileListener.cs" /> |
|
83 | <Compile Include="Diagnostics\TextFileListener.cs" /> | |
84 | <Compile Include="Diagnostics\TraceLog.cs" /> |
|
84 | <Compile Include="Diagnostics\TraceLog.cs" /> | |
85 | <Compile Include="Diagnostics\TraceEvent.cs" /> |
|
85 | <Compile Include="Diagnostics\TraceEvent.cs" /> | |
86 | <Compile Include="Diagnostics\TraceEventType.cs" /> |
|
86 | <Compile Include="Diagnostics\TraceEventType.cs" /> | |
87 | <Compile Include="ICancellable.cs" /> |
|
87 | <Compile Include="ICancellable.cs" /> | |
88 | <Compile Include="IProgressHandler.cs" /> |
|
88 | <Compile Include="IProgressHandler.cs" /> | |
89 | <Compile Include="IProgressNotifier.cs" /> |
|
89 | <Compile Include="IProgressNotifier.cs" /> | |
90 | <Compile Include="IPromiseT.cs" /> |
|
90 | <Compile Include="IPromiseT.cs" /> | |
91 | <Compile Include="IPromise.cs" /> |
|
91 | <Compile Include="IPromise.cs" /> | |
92 | <Compile Include="IServiceLocator.cs" /> |
|
92 | <Compile Include="IServiceLocator.cs" /> | |
93 | <Compile Include="ITaskController.cs" /> |
|
93 | <Compile Include="ITaskController.cs" /> | |
94 | <Compile Include="Parallels\DispatchPool.cs" /> |
|
94 | <Compile Include="Parallels\DispatchPool.cs" /> | |
95 | <Compile Include="Parallels\ArrayTraits.cs" /> |
|
95 | <Compile Include="Parallels\ArrayTraits.cs" /> | |
96 | <Compile Include="Parallels\MTQueue.cs" /> |
|
96 | <Compile Include="Parallels\MTQueue.cs" /> | |
97 | <Compile Include="Parallels\WorkerPool.cs" /> |
|
97 | <Compile Include="Parallels\WorkerPool.cs" /> | |
98 | <Compile Include="ProgressInitEventArgs.cs" /> |
|
98 | <Compile Include="ProgressInitEventArgs.cs" /> | |
99 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
99 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
100 | <Compile Include="Parallels\AsyncPool.cs" /> |
|
100 | <Compile Include="Parallels\AsyncPool.cs" /> | |
101 | <Compile Include="Safe.cs" /> |
|
101 | <Compile Include="Safe.cs" /> | |
102 | <Compile Include="ValueEventArgs.cs" /> |
|
102 | <Compile Include="ValueEventArgs.cs" /> | |
103 | <Compile Include="PromiseExtensions.cs" /> |
|
103 | <Compile Include="PromiseExtensions.cs" /> | |
104 | <Compile Include="SyncContextPromise.cs" /> |
|
104 | <Compile Include="SyncContextPromise.cs" /> | |
105 | <Compile Include="Diagnostics\OperationContext.cs" /> |
|
105 | <Compile Include="Diagnostics\OperationContext.cs" /> | |
106 | <Compile Include="Diagnostics\TraceContext.cs" /> |
|
106 | <Compile Include="Diagnostics\TraceContext.cs" /> | |
107 | <Compile Include="Diagnostics\LogEventArgs.cs" /> |
|
107 | <Compile Include="Diagnostics\LogEventArgs.cs" /> | |
108 | <Compile Include="Diagnostics\LogEventArgsT.cs" /> |
|
108 | <Compile Include="Diagnostics\LogEventArgsT.cs" /> | |
109 | <Compile Include="Diagnostics\Extensions.cs" /> |
|
109 | <Compile Include="Diagnostics\Extensions.cs" /> | |
110 | <Compile Include="PromiseEventType.cs" /> |
|
110 | <Compile Include="PromiseEventType.cs" /> | |
111 | <Compile Include="Parallels\AsyncQueue.cs" /> |
|
111 | <Compile Include="Parallels\AsyncQueue.cs" /> | |
112 | <Compile Include="PromiseT.cs" /> |
|
112 | <Compile Include="PromiseT.cs" /> | |
113 | <Compile Include="IDeferred.cs" /> |
|
113 | <Compile Include="IDeferred.cs" /> | |
114 | <Compile Include="IDeferredT.cs" /> |
|
114 | <Compile Include="IDeferredT.cs" /> | |
115 | <Compile Include="Promise.cs" /> |
|
115 | <Compile Include="Promise.cs" /> | |
116 | <Compile Include="PromiseTransientException.cs" /> |
|
116 | <Compile Include="PromiseTransientException.cs" /> | |
117 | <Compile Include="Parallels\Signal.cs" /> |
|
117 | <Compile Include="Parallels\Signal.cs" /> | |
118 | <Compile Include="Parallels\SharedLock.cs" /> |
|
118 | <Compile Include="Parallels\SharedLock.cs" /> | |
119 | <Compile Include="Diagnostics\ILogWriter.cs" /> |
|
119 | <Compile Include="Diagnostics\ILogWriter.cs" /> | |
120 | <Compile Include="Diagnostics\ListenerBase.cs" /> |
|
120 | <Compile Include="Diagnostics\ListenerBase.cs" /> | |
121 | <Compile Include="Parallels\BlockingQueue.cs" /> |
|
121 | <Compile Include="Parallels\BlockingQueue.cs" /> | |
122 | <Compile Include="AbstractEvent.cs" /> |
|
122 | <Compile Include="AbstractEvent.cs" /> | |
123 | <Compile Include="AbstractPromise.cs" /> |
|
123 | <Compile Include="AbstractPromise.cs" /> | |
124 | <Compile Include="AbstractPromiseT.cs" /> |
|
124 | <Compile Include="AbstractPromiseT.cs" /> | |
125 | <Compile Include="FuncTask.cs" /> |
|
125 | <Compile Include="FuncTask.cs" /> | |
126 | <Compile Include="FuncTaskBase.cs" /> |
|
126 | <Compile Include="FuncTaskBase.cs" /> | |
127 | <Compile Include="FuncTaskT.cs" /> |
|
127 | <Compile Include="FuncTaskT.cs" /> | |
128 | <Compile Include="ActionChainTaskBase.cs" /> |
|
128 | <Compile Include="ActionChainTaskBase.cs" /> | |
129 | <Compile Include="ActionChainTask.cs" /> |
|
129 | <Compile Include="ActionChainTask.cs" /> | |
130 | <Compile Include="ActionChainTaskT.cs" /> |
|
130 | <Compile Include="ActionChainTaskT.cs" /> | |
131 | <Compile Include="FuncChainTaskBase.cs" /> |
|
131 | <Compile Include="FuncChainTaskBase.cs" /> | |
132 | <Compile Include="FuncChainTask.cs" /> |
|
132 | <Compile Include="FuncChainTask.cs" /> | |
133 | <Compile Include="FuncChainTaskT.cs" /> |
|
133 | <Compile Include="FuncChainTaskT.cs" /> | |
134 | <Compile Include="ActionTaskBase.cs" /> |
|
134 | <Compile Include="ActionTaskBase.cs" /> | |
135 | <Compile Include="ActionTask.cs" /> |
|
135 | <Compile Include="ActionTask.cs" /> | |
136 | <Compile Include="ActionTaskT.cs" /> |
|
136 | <Compile Include="ActionTaskT.cs" /> | |
137 | <Compile Include="ICancellationToken.cs" /> |
|
137 | <Compile Include="ICancellationToken.cs" /> | |
138 | <Compile Include="SuccessPromise.cs" /> |
|
138 | <Compile Include="SuccessPromise.cs" /> | |
139 | <Compile Include="SuccessPromiseT.cs" /> |
|
139 | <Compile Include="SuccessPromiseT.cs" /> | |
140 | <Compile Include="PromiseAwaiterT.cs" /> |
|
140 | <Compile Include="PromiseAwaiterT.cs" /> | |
141 | <Compile Include="PromiseAwaiter.cs" /> |
|
141 | <Compile Include="PromiseAwaiter.cs" /> | |
142 | <Compile Include="Components\ComponentContainer.cs" /> |
|
142 | <Compile Include="Components\ComponentContainer.cs" /> | |
143 | <Compile Include="Components\Disposable.cs" /> |
|
143 | <Compile Include="Components\Disposable.cs" /> | |
144 | <Compile Include="Components\DisposablePool.cs" /> |
|
144 | <Compile Include="Components\DisposablePool.cs" /> | |
145 | <Compile Include="Components\ObjectPool.cs" /> |
|
145 | <Compile Include="Components\ObjectPool.cs" /> | |
146 | <Compile Include="Components\ServiceLocator.cs" /> |
|
146 | <Compile Include="Components\ServiceLocator.cs" /> | |
147 | <Compile Include="Components\IInitializable.cs" /> |
|
147 | <Compile Include="Components\IInitializable.cs" /> | |
148 | <Compile Include="TaskController.cs" /> |
|
148 | <Compile Include="TaskController.cs" /> | |
149 | <Compile Include="Components\App.cs" /> |
|
149 | <Compile Include="Components\App.cs" /> | |
150 | <Compile Include="Components\IRunnable.cs" /> |
|
150 | <Compile Include="Components\IRunnable.cs" /> | |
151 | <Compile Include="Components\ExecutionState.cs" /> |
|
151 | <Compile Include="Components\ExecutionState.cs" /> | |
152 | <Compile Include="Components\RunnableComponent.cs" /> |
|
152 | <Compile Include="Components\RunnableComponent.cs" /> | |
153 | <Compile Include="Components\IFactory.cs" /> |
|
153 | <Compile Include="Components\IFactory.cs" /> | |
154 | <Compile Include="Automaton\DFAStateDescriptor.cs" /> |
|
154 | <Compile Include="Automaton\DFAStateDescriptor.cs" /> | |
155 | <Compile Include="Automaton\EnumAlphabet.cs" /> |
|
155 | <Compile Include="Automaton\EnumAlphabet.cs" /> | |
156 | <Compile Include="Automaton\IAlphabet.cs" /> |
|
156 | <Compile Include="Automaton\IAlphabet.cs" /> | |
157 | <Compile Include="Automaton\ParserException.cs" /> |
|
157 | <Compile Include="Automaton\ParserException.cs" /> | |
158 | <Compile Include="Automaton\Scanner.cs" /> |
|
158 | <Compile Include="Automaton\Scanner.cs" /> | |
159 | <Compile Include="Automaton\IndexedAlphabetBase.cs" /> |
|
159 | <Compile Include="Automaton\IndexedAlphabetBase.cs" /> | |
160 | <Compile Include="Automaton\IAlphabetBuilder.cs" /> |
|
160 | <Compile Include="Automaton\IAlphabetBuilder.cs" /> | |
161 | <Compile Include="Automaton\RegularExpressions\AltToken.cs" /> |
|
161 | <Compile Include="Automaton\RegularExpressions\AltToken.cs" /> | |
162 | <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" /> |
|
162 | <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" /> | |
163 | <Compile Include="Automaton\RegularExpressions\CatToken.cs" /> |
|
163 | <Compile Include="Automaton\RegularExpressions\CatToken.cs" /> | |
164 | <Compile Include="Automaton\DFAConst.cs" /> |
|
164 | <Compile Include="Automaton\DFAConst.cs" /> | |
165 | <Compile Include="Automaton\RegularExpressions\Grammar.cs" /> |
|
165 | <Compile Include="Automaton\RegularExpressions\Grammar.cs" /> | |
166 | <Compile Include="Automaton\RegularExpressions\StarToken.cs" /> |
|
166 | <Compile Include="Automaton\RegularExpressions\StarToken.cs" /> | |
167 | <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" /> |
|
167 | <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" /> | |
168 | <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" /> |
|
168 | <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" /> | |
169 | <Compile Include="Automaton\RegularExpressions\EndToken.cs" /> |
|
169 | <Compile Include="Automaton\RegularExpressions\EndToken.cs" /> | |
170 | <Compile Include="Automaton\RegularExpressions\Token.cs" /> |
|
170 | <Compile Include="Automaton\RegularExpressions\Token.cs" /> | |
171 | <Compile Include="Automaton\RegularExpressions\IVisitor.cs" /> |
|
171 | <Compile Include="Automaton\RegularExpressions\IVisitor.cs" /> | |
172 | <Compile Include="Automaton\AutomatonTransition.cs" /> |
|
172 | <Compile Include="Automaton\AutomatonTransition.cs" /> | |
173 | <Compile Include="Automaton\RegularExpressions\RegularDFABuilder.cs" /> |
|
173 | <Compile Include="Automaton\RegularExpressions\RegularDFABuilder.cs" /> | |
174 | <Compile Include="Formats\JSON\JSONElementContext.cs" /> |
|
174 | <Compile Include="Formats\JSON\JSONElementContext.cs" /> | |
175 | <Compile Include="Formats\JSON\JSONElementType.cs" /> |
|
175 | <Compile Include="Formats\JSON\JSONElementType.cs" /> | |
176 | <Compile Include="Formats\JSON\JSONGrammar.cs" /> |
|
176 | <Compile Include="Formats\JSON\JSONGrammar.cs" /> | |
177 | <Compile Include="Formats\JSON\JSONParser.cs" /> |
|
177 | <Compile Include="Formats\JSON\JSONParser.cs" /> | |
178 | <Compile Include="Formats\JSON\JSONScanner.cs" /> |
|
178 | <Compile Include="Formats\JSON\JSONScanner.cs" /> | |
179 | <Compile Include="Formats\JSON\JsonTokenType.cs" /> |
|
179 | <Compile Include="Formats\JSON\JsonTokenType.cs" /> | |
180 | <Compile Include="Formats\JSON\JSONWriter.cs" /> |
|
180 | <Compile Include="Formats\JSON\JSONWriter.cs" /> | |
181 | <Compile Include="Formats\JSON\JSONXmlReader.cs" /> |
|
181 | <Compile Include="Formats\JSON\JSONXmlReader.cs" /> | |
182 | <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" /> |
|
182 | <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" /> | |
183 | <Compile Include="Formats\JSON\StringTranslator.cs" /> |
|
183 | <Compile Include="Formats\JSON\StringTranslator.cs" /> | |
184 | <Compile Include="Automaton\MapAlphabet.cs" /> |
|
184 | <Compile Include="Automaton\MapAlphabet.cs" /> | |
185 | <Compile Include="Automaton\DummyAlphabet.cs" /> |
|
185 | <Compile Include="Automaton\DummyAlphabet.cs" /> | |
186 | <Compile Include="Automaton\RegularExpressions\RegularDFADefinition.cs" /> |
|
186 | <Compile Include="Automaton\RegularExpressions\RegularDFADefinition.cs" /> | |
187 | <Compile Include="Formats\CharAlphabet.cs" /> |
|
187 | <Compile Include="Formats\CharAlphabet.cs" /> | |
188 | <Compile Include="Formats\ByteAlphabet.cs" /> |
|
188 | <Compile Include="Formats\ByteAlphabet.cs" /> | |
189 | <Compile Include="Formats\RegularCharDFADefinition.cs" /> |
|
189 | <Compile Include="Formats\RegularCharDFADefinition.cs" /> | |
190 | <Compile Include="Automaton\IDFATable.cs" /> |
|
190 | <Compile Include="Automaton\IDFATable.cs" /> | |
191 | <Compile Include="Automaton\IDFATableBuilder.cs" /> |
|
191 | <Compile Include="Automaton\IDFATableBuilder.cs" /> | |
192 | <Compile Include="Automaton\DFATable.cs" /> |
|
192 | <Compile Include="Automaton\DFATable.cs" /> | |
|
193 | <Compile Include="Automaton\RegularExpressions\DFAStateDescriptorT.cs" /> | |||
193 | </ItemGroup> |
|
194 | </ItemGroup> | |
194 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
195 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
195 | <ItemGroup /> |
|
196 | <ItemGroup /> | |
196 | <ProjectExtensions> |
|
197 | <ProjectExtensions> | |
197 | <MonoDevelop> |
|
198 | <MonoDevelop> | |
198 | <Properties> |
|
199 | <Properties> | |
199 | <Policies> |
|
200 | <Policies> | |
200 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> |
|
201 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> | |
201 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> |
|
202 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> | |
202 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> |
|
203 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> | |
203 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> |
|
204 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> | |
204 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> |
|
205 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> | |
205 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> |
|
206 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> | |
206 | <NameConventionPolicy> |
|
207 | <NameConventionPolicy> | |
207 | <Rules> |
|
208 | <Rules> | |
208 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
209 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
209 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
210 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
210 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
211 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
211 | <RequiredPrefixes> |
|
212 | <RequiredPrefixes> | |
212 | <String>I</String> |
|
213 | <String>I</String> | |
213 | </RequiredPrefixes> |
|
214 | </RequiredPrefixes> | |
214 | </NamingRule> |
|
215 | </NamingRule> | |
215 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
216 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
216 | <RequiredSuffixes> |
|
217 | <RequiredSuffixes> | |
217 | <String>Attribute</String> |
|
218 | <String>Attribute</String> | |
218 | </RequiredSuffixes> |
|
219 | </RequiredSuffixes> | |
219 | </NamingRule> |
|
220 | </NamingRule> | |
220 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
221 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
221 | <RequiredSuffixes> |
|
222 | <RequiredSuffixes> | |
222 | <String>EventArgs</String> |
|
223 | <String>EventArgs</String> | |
223 | </RequiredSuffixes> |
|
224 | </RequiredSuffixes> | |
224 | </NamingRule> |
|
225 | </NamingRule> | |
225 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
226 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
226 | <RequiredSuffixes> |
|
227 | <RequiredSuffixes> | |
227 | <String>Exception</String> |
|
228 | <String>Exception</String> | |
228 | </RequiredSuffixes> |
|
229 | </RequiredSuffixes> | |
229 | </NamingRule> |
|
230 | </NamingRule> | |
230 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
231 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
231 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> |
|
232 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> | |
232 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
233 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
233 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> |
|
234 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> | |
234 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
235 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
235 | <RequiredPrefixes> |
|
236 | <RequiredPrefixes> | |
236 | <String>m_</String> |
|
237 | <String>m_</String> | |
237 | </RequiredPrefixes> |
|
238 | </RequiredPrefixes> | |
238 | </NamingRule> |
|
239 | </NamingRule> | |
239 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> |
|
240 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> | |
240 | <RequiredPrefixes> |
|
241 | <RequiredPrefixes> | |
241 | <String>_</String> |
|
242 | <String>_</String> | |
242 | </RequiredPrefixes> |
|
243 | </RequiredPrefixes> | |
243 | </NamingRule> |
|
244 | </NamingRule> | |
244 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
245 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> | |
245 | <RequiredPrefixes> |
|
246 | <RequiredPrefixes> | |
246 | <String>m_</String> |
|
247 | <String>m_</String> | |
247 | </RequiredPrefixes> |
|
248 | </RequiredPrefixes> | |
248 | </NamingRule> |
|
249 | </NamingRule> | |
249 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
250 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
250 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
251 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
251 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
252 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
252 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
253 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
253 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
254 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> | |
254 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
255 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> | |
255 | <RequiredPrefixes> |
|
256 | <RequiredPrefixes> | |
256 | <String>T</String> |
|
257 | <String>T</String> | |
257 | </RequiredPrefixes> |
|
258 | </RequiredPrefixes> | |
258 | </NamingRule> |
|
259 | </NamingRule> | |
259 | </Rules> |
|
260 | </Rules> | |
260 | </NameConventionPolicy> |
|
261 | </NameConventionPolicy> | |
261 | </Policies> |
|
262 | </Policies> | |
262 | </Properties> |
|
263 | </Properties> | |
263 | </MonoDevelop> |
|
264 | </MonoDevelop> | |
264 | </ProjectExtensions> |
|
265 | </ProjectExtensions> | |
265 | <ItemGroup> |
|
266 | <ItemGroup> | |
266 | <Folder Include="Components\" /> |
|
267 | <Folder Include="Components\" /> | |
267 | <Folder Include="Automaton\RegularExpressions\" /> |
|
268 | <Folder Include="Automaton\RegularExpressions\" /> | |
268 | <Folder Include="Formats\" /> |
|
269 | <Folder Include="Formats\" /> | |
269 | <Folder Include="Formats\JSON\" /> |
|
270 | <Folder Include="Formats\JSON\" /> | |
270 | </ItemGroup> |
|
271 | </ItemGroup> | |
271 | </Project> No newline at end of file |
|
272 | </Project> |
General Comments 0
You need to be logged in to leave comments.
Login now