annotate Implab/Automaton/Scanner.cs @ 172:92d5278d1b10 ref20160224

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