annotate Implab/Automaton/Scanner.cs @ 163:419aa51b04fd ref20160224

JSON moved to Formats namespace Working in RegularDFA
author cin
date Wed, 24 Feb 2016 20:12:52 +0300
parents 0526412bbb26
children ec35731ae299
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
162
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
1 using Implab;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
2 using System;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
3 using System.Collections.Generic;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
4 using System.IO;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
5 using Implab.Components;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
6
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
7 namespace Implab.Automaton {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
8 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
9 /// Базовый класс для разбора потока входных символов на токены.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
10 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
11 /// <remarks>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
12 /// Сканнер имеет внутри буффер с симолами входного текста, по которому перемещаются два
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
13 /// указателя, начала и конца токена, при перемещении искользуется ДКА для определения
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
14 /// конца токена и допустимости текущего символа.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
15 /// </remarks>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
16 public abstract class Scanner<TTag> : Disposable {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
17 struct ScannerConfig {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
18 public DFAStateDescriptior<TTag>[] states;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
19 public int[] alphabetMap;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
20 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
21
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
22 Stack<ScannerConfig> m_defs = new Stack<ScannerConfig>();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
23
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
24 DFAStateDescriptior<TTag>[] m_states;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
25 int[] m_alphabetMap;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
26
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
27 protected DFAStateDescriptior<TTag> m_currentState;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
28 int m_previewCode;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
29
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
30 protected int m_tokenLen = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
31 protected int m_tokenOffset;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
32
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
33 protected char[] m_buffer;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
34 protected int m_bufferSize;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
35 protected int m_pointer;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
36
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
37 TextReader m_reader;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
38 bool m_disposeReader;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
39 int m_chunkSize = 1024; // 1k
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
40 int m_limit = 10 * 1024 * 1024; // 10Mb
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
41
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
42 protected Scanner(DFAStateDescriptior<TTag>[] states, int[] alphabet) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
43 Safe.ArgumentNotEmpty(states, "states");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
44 Safe.ArgumentNotNull(alphabet, "alphabet");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
45
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
46 m_states = states;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
47 m_alphabetMap = alphabet;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
48
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
49 Feed(new char[0]);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
50 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
51
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
52 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
53 /// Заполняет входными данными буффер.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
54 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
55 /// <param name="data">Данные для обработки.</param>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
56 /// <remarks>Копирование данных не происходит, переданный массив используется в
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
57 /// качестве входного буффера.</remarks>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
58 public void Feed(char[] data) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
59 Safe.ArgumentNotNull(data, "data");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
60
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
61 Feed(data, data.Length);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
62 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
63
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
64 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
65 /// Заполняет буффур чтения входными данными.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
66 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
67 /// <param name="data">Данные для обработки.</param>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
68 /// <param name="length">Длина данных для обработки.</param>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
69 /// <remarks>Копирование данных не происходит, переданный массив используется в
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
70 /// качестве входного буффера.</remarks>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
71 public void Feed(char[] data, int length) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
72 Safe.ArgumentNotNull(data, "data");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
73 Safe.ArgumentInRange(length, 0, data.Length, "length");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
74 AssertNotDisposed();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
75
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
76 m_pointer = -1;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
77 m_buffer = data;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
78 m_bufferSize = length;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
79 Shift();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
80 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
81
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
82 public void Feed(TextReader reader, bool dispose) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
83 Safe.ArgumentNotNull(reader, "reader");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
84 AssertNotDisposed();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
85
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
86 if (m_reader != null && m_disposeReader)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
87 m_reader.Dispose();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
88
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
89 m_reader = reader;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
90 m_disposeReader = dispose;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
91 m_pointer = -1;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
92 m_buffer = new char[m_chunkSize];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
93 m_bufferSize = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
94 Shift();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
95 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
96
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
97 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
98 /// Получает текущий токен в виде строки.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
99 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
100 /// <returns></returns>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
101 protected string GetTokenValue() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
102 return new String(m_buffer, m_tokenOffset, m_tokenLen);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
103 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
104
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
105 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
106 /// Метки текущего токена, которые были назначены в регулярном выражении.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
107 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
108 protected TTag[] TokenTags {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
109 get {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
110 return m_currentState.tag;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
111 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
112 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
113
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
114 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
115 /// Признак конца данных
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
116 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
117 public bool EOF {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
118 get {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
119 return m_pointer >= m_bufferSize;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
120 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
121 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
122
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
123 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
124 /// Читает следующий токен, при этом <see cref="m_tokenOffset"/> указывает на начало токена,
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
125 /// <see cref="m_tokenLen"/> на длину токена, <see cref="m_buffer"/> - массив символов, в
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
126 /// котором находится токен.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
127 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
128 /// <returns><c>false</c> - достигнут конец данных, токен не прочитан.</returns>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
129 protected bool ReadTokenInternal() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
130 if (m_pointer >= m_bufferSize)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
131 return false;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
132
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
133 m_currentState = m_states[DFADefinition.INITIAL_STATE];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
134 m_tokenLen = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
135 m_tokenOffset = m_pointer;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
136 int nextState;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
137 do {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
138 nextState = m_currentState.transitions[m_previewCode];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
139 if (nextState == DFAConst.UNREACHABLE_STATE) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
140 if (m_currentState.final)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
141 return true;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
142 else
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
143 throw new ParserException(
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
144 String.Format(
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
145 "Unexpected symbol '{0}', at pos {1}",
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
146 m_buffer[m_pointer],
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
147 Position
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
148 )
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
149 );
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
150 } else {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
151 m_currentState = m_states[nextState];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
152 m_tokenLen++;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
153 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
154
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
155 } while (Shift());
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
156
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
157 // END OF DATA
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
158 if (!m_currentState.final)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
159 throw new ParserException("Unexpected end of data");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
160
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
161 return true;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
162 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
163
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
164
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
165 bool Shift() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
166 m_pointer++;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
167
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
168 if (m_pointer >= m_bufferSize) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
169 if (!ReadNextChunk())
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
170 return false;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
171 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
172
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
173 m_previewCode = m_alphabetMap[m_buffer[m_pointer]];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
174
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
175 return true;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
176 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
177
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
178 bool ReadNextChunk() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
179 if (m_reader == null)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
180 return false;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
181
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
182 // extend buffer if nesessary
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
183 if (m_pointer + m_chunkSize > m_buffer.Length) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
184 // trim unused buffer head
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
185 var size = m_tokenLen + m_chunkSize;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
186 if (size >= m_limit)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
187 throw new ParserException(String.Format("Input buffer {0} bytes limit exceeded", m_limit));
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
188 var temp = new char[size];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
189 Array.Copy(m_buffer, m_tokenOffset, temp, 0, m_tokenLen);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
190 m_pointer -= m_tokenOffset;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
191 m_bufferSize -= m_tokenOffset;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
192 m_tokenOffset = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
193 m_buffer = temp;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
194 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
195
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
196 var read = m_reader.Read(m_buffer, m_tokenLen, m_chunkSize);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
197 if (read == 0)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
198 return false;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
199
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
200 m_bufferSize += read;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
201
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
202 return true;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
203 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
204
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
205 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
206 /// Позиция сканнера во входном буфере
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
207 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
208 public int Position {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
209 get {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
210 return m_pointer + 1;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
211 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
212 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
213
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
214 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
215 /// Преключает внутренний ДКА на указанный, позволяет реализовать подобие захватывающей
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
216 /// группировки.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
217 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
218 /// <param name="states">Таблица состояний нового ДКА</param>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
219 /// <param name="alphabet">Таблица входных символов для нового ДКА</param>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
220 protected void Switch(DFAStateDescriptior<TTag>[] states, int[] alphabet) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
221 Safe.ArgumentNotNull(states, "dfa");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
222
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
223 m_defs.Push(new ScannerConfig {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
224 states = m_states,
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
225 alphabetMap = m_alphabetMap
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
226 });
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
227
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
228 m_states = states;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
229 m_alphabetMap = alphabet;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
230
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
231 m_previewCode = m_alphabetMap[m_buffer[m_pointer]];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
232 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
233
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
234 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
235 /// Восстанавливает предыдущей ДКА сканнера.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
236 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
237 protected void Restore() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
238 if (m_defs.Count == 0)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
239 throw new InvalidOperationException();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
240 var prev = m_defs.Pop();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
241 m_states = prev.states;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
242 m_alphabetMap = prev.alphabetMap;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
243 m_previewCode = m_alphabetMap[m_buffer[m_pointer]];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
244 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
245
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
246 protected override void Dispose(bool disposing) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
247 if (disposing) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
248 if (m_reader != null && m_disposeReader)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
249 m_reader.Dispose();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
250 m_buffer = null;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
251 m_bufferSize = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
252 m_pointer = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
253 m_tokenLen = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
254 m_tokenOffset = 0;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
255 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
256 base.Dispose(disposing);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
257 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
258 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
259 }