Mercurial > pub > ImplabNet
comparison Implab/Automaton/DFATable.cs @ 236:302ca905c19e v2
JsonReader optimizations
author | cin |
---|---|
date | Tue, 21 Nov 2017 14:57:58 +0300 |
parents | 5f7a3e1d32b9 |
children | fa6cbf4d8841 |
comparison
equal
deleted
inserted
replaced
235:b49969a7043c | 236:302ca905c19e |
---|---|
114 public int[,] CreateTransitionTable() { | 114 public int[,] CreateTransitionTable() { |
115 var table = new int[StateCount,AlphabetSize]; | 115 var table = new int[StateCount,AlphabetSize]; |
116 | 116 |
117 for (int i = 0; i < StateCount; i++) | 117 for (int i = 0; i < StateCount; i++) |
118 for (int j = 0; j < AlphabetSize; j++) | 118 for (int j = 0; j < AlphabetSize; j++) |
119 table[i, j] = AutomatonConst.UNREACHABLE_STATE; | 119 table[i, j] = AutomatonConst.UnreachableState; |
120 | 120 |
121 foreach (var t in this) | 121 foreach (var t in this) |
122 table[t.s1,t.edge] = (byte)t.s2; | 122 table[t.s1,t.edge] = (byte)t.s2; |
123 | 123 |
124 return table; | 124 return table; |
288 // специальное значение, тогда сохраним минимальный класс, | 288 // специальное значение, тогда сохраним минимальный класс, |
289 // содержащий этот символ на томже месте. | 289 // содержащий этот символ на томже месте. |
290 | 290 |
291 var nextCls = 0; | 291 var nextCls = 0; |
292 foreach (var item in minClasses) { | 292 foreach (var item in minClasses) { |
293 if (nextCls == AutomatonConst.UNCLASSIFIED_INPUT) | 293 if (nextCls == AutomatonConst.UnclassifiedInput) |
294 nextCls++; | 294 nextCls++; |
295 | 295 |
296 // сохраняем DFAConst.UNCLASSIFIED_INPUT | 296 // сохраняем DFAConst.UNCLASSIFIED_INPUT |
297 var cls = item.Contains(AutomatonConst.UNCLASSIFIED_INPUT) ? AutomatonConst.UNCLASSIFIED_INPUT : nextCls++; | 297 var cls = item.Contains(AutomatonConst.UnclassifiedInput) ? AutomatonConst.UnclassifiedInput : nextCls++; |
298 optimalDFA.AddSymbol(cls); | 298 optimalDFA.AddSymbol(cls); |
299 | 299 |
300 foreach (var a in item) | 300 foreach (var a in item) |
301 alphabetMap[a] = cls; | 301 alphabetMap[a] = cls; |
302 } | 302 } |
324 | 324 |
325 foreach (var t in m_transitions) | 325 foreach (var t in m_transitions) |
326 data.Add(String.Format( | 326 data.Add(String.Format( |
327 "{0} -> {2} [label={1}];", | 327 "{0} -> {2} [label={1}];", |
328 String.Join("", stateAlphabet.GetSymbols(t.s1)), | 328 String.Join("", stateAlphabet.GetSymbols(t.s1)), |
329 ToLiteral(ToLiteral(String.Join("", t.edge == AutomatonConst.UNCLASSIFIED_INPUT ? new [] { "@" } : inputAlphabet.GetSymbols(t.edge).Select(x => x.ToString())))), | 329 ToLiteral(ToLiteral(String.Join("", t.edge == AutomatonConst.UnclassifiedInput ? new [] { "@" } : inputAlphabet.GetSymbols(t.edge).Select(x => x.ToString())))), |
330 String.Join("", stateAlphabet.GetSymbols(t.s2)) | 330 String.Join("", stateAlphabet.GetSymbols(t.s2)) |
331 )); | 331 )); |
332 data.Add("}"); | 332 data.Add("}"); |
333 return String.Join("\n", data); | 333 return String.Join("\n", data); |
334 } | 334 } |