Mercurial > pub > ImplabNet
comparison Implab/Automaton/DFATable.cs @ 176:0c3c69fe225b ref20160224
rewritten the text scanner
author | cin |
---|---|
date | Tue, 22 Mar 2016 18:58:40 +0300 |
parents | 92d5278d1b10 |
children | d5c5db0335ee |
comparison
equal
deleted
inserted
replaced
175:96a89dcb4060 | 176:0c3c69fe225b |
---|---|
98 | 98 |
99 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { | 99 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { |
100 return GetEnumerator(); | 100 return GetEnumerator(); |
101 } | 101 } |
102 | 102 |
103 public DFAStateDescriptor[] CreateTransitionTable() { | 103 public int[,] CreateTransitionTable() { |
104 var table = new DFAStateDescriptor[StateCount]; | 104 var table = new int[StateCount,AlphabetSize]; |
105 | 105 |
106 foreach (var t in this) { | 106 for (int i = 0; i < StateCount; i++) |
107 if (table[t.s1].transitions == null) | 107 for (int j = 0; i < AlphabetSize; j++) |
108 table[t.s1] = new DFAStateDescriptor(AlphabetSize, IsFinalState(t.s1)); | 108 table[i, j] = DFAConst.UNREACHABLE_STATE; |
109 if (table[t.s2].transitions == null) | 109 |
110 table[t.s2] = new DFAStateDescriptor(AlphabetSize, IsFinalState(t.s2)); | 110 foreach (var t in this) |
111 table[t.s1].transitions[t.edge] = t.s2; | 111 table[t.s1,t.edge] = t.s2; |
112 } | 112 |
113 return table; | |
114 } | |
115 | |
116 public bool[] CreateFinalStateTable() { | |
117 var table = new bool[StateCount]; | |
118 | |
119 foreach (var s in FinalStates) | |
120 table[s] = true; | |
113 | 121 |
114 return table; | 122 return table; |
115 } | 123 } |
116 | 124 |
117 /// <summary>Формирует множества конечных состояний перед началом работы алгоритма минимизации.</summary> | 125 /// <summary>Формирует множества конечных состояний перед началом работы алгоритма минимизации.</summary> |