annotate Implab/Formats/Json/JsonScanner.cs @ 260:547a2fc0d93e v3 v3.0.6

minor fixes
author cin
date Fri, 13 Apr 2018 19:14:59 +0300
parents 302ca905c19e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
e227e78d72e4 DFA refactoring
cin
parents: 163
diff changeset
1 using System;
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
2 using System.Globalization;
165
e227e78d72e4 DFA refactoring
cin
parents: 163
diff changeset
3 using Implab.Automaton;
176
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
4 using System.Text;
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
5 using Implab.Components;
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
6 using System.IO;
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
7
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
8 namespace Implab.Formats.Json {
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
9 /// <summary>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
10 /// Сканнер (лексер), разбивающий поток символов на токены JSON.
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
11 /// </summary>
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
12 public abstract class JsonScanner : Disposable {
236
302ca905c19e JsonReader optimizations
cin
parents: 230
diff changeset
13 readonly FastInputScanner<JsonGrammar.TokenType> m_jsonContext = JsonGrammar.CreateJsonExpressionScanner();
302ca905c19e JsonReader optimizations
cin
parents: 230
diff changeset
14 readonly FastInputScanner<JsonGrammar.TokenType> m_stringContext = JsonGrammar.CreateStringExpressionScanner();
176
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
15
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
16 readonly char[] m_unescapeBuf = new char[4];
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
17 readonly char[] m_buffer;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
18 int m_length;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
19 int m_pos;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
20 readonly StringBuilder m_tokenBuilder = new StringBuilder();
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
21
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
22 protected JsonScanner(char[] buffer, int pos, int length) {
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
23 m_buffer = buffer;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
24 m_pos = pos;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
25 m_length = length;
176
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
26 }
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
27
236
302ca905c19e JsonReader optimizations
cin
parents: 230
diff changeset
28 bool ReadChunk(FastInputScanner<JsonGrammar.TokenType> scanner, out JsonGrammar.TokenType tokenType) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
29 scanner.ResetState();
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
30
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
31 while(scanner.Scan(m_buffer, m_pos, m_length)) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
32 // scanner requests new data
176
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
33
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
34 if (m_pos != m_length) // capture results for the future
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
35 m_tokenBuilder.Append(m_buffer, m_pos, m_length - m_pos);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
36
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
37 // read next data
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
38 m_length = Read(m_buffer, 0, m_buffer.Length);
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
39
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
40 if (m_length == 0) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
41 // no data is read
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
42 if (scanner.Position == m_pos) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
43 // scanned hasn't moved, that's the end
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
44 m_pos = 0;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
45 tokenType = JsonGrammar.TokenType.None;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
46 return false;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
47 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
48
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
49 if (scanner.IsFinal) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
50 m_pos = 0;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
51 tokenType = scanner.Tag;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
52 return true;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
53 } else {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
54 throw new ParserException("Unexpected EOF");
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
55 }
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
56 }
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
57
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
58 m_pos = 0;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
59 }
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
60 var scannerPos = scanner.Position;
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
61
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
62 // scanner stops as scannerPos
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
63 if (!scanner.IsFinal)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
64 throw new ParserException($"Unexpected character '{m_buffer[scannerPos + 1]}'");
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
65
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
66 tokenType = scanner.Tag;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
67 if (scannerPos != m_pos && tokenType == JsonGrammar.TokenType.Number || tokenType == JsonGrammar.TokenType.Literal)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
68 m_tokenBuilder.Append(m_buffer, m_pos, scannerPos - m_pos);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
69
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
70 m_pos = scannerPos;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
71 return true;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
72 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
73
236
302ca905c19e JsonReader optimizations
cin
parents: 230
diff changeset
74 bool ReadStringChunk(FastInputScanner<JsonGrammar.TokenType> scanner, out JsonGrammar.TokenType tokenType) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
75 scanner.ResetState();
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
76
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
77 while (scanner.Scan(m_buffer, m_pos, m_length)) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
78 // scanner requests new data
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
79
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
80 if (m_pos != m_length) // capture results for the future
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
81 m_tokenBuilder.Append(m_buffer, m_pos, m_length - m_pos);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
82
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
83 // read next data
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
84 m_length = Read(m_buffer, 0, m_buffer.Length);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
85
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
86 if (m_length == 0) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
87 // no data is read
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
88 if (scanner.Position == m_pos) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
89 // scanned hasn't moved, that's the end
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
90 m_pos = 0;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
91 tokenType = JsonGrammar.TokenType.None;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
92 return false;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
93 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
94
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
95 if (scanner.IsFinal) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
96 m_pos = 0;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
97 tokenType = scanner.Tag;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
98 return true;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
99 } else {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
100 throw new ParserException("Unexpected EOF");
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
101 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
102 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
103
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
104 m_pos = 0;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
105 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
106 var scannerPos = scanner.Position;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
107
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
108 // scanner stops as scannerPos
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
109 if (!scanner.IsFinal)
236
302ca905c19e JsonReader optimizations
cin
parents: 230
diff changeset
110 throw new ParserException($"Unexpected character '{m_buffer[scannerPos]}'");
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
111
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
112 if (scannerPos != m_pos) {
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
113 m_tokenBuilder.Append(m_buffer, m_pos, scannerPos - m_pos);
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
114 m_pos = scannerPos;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
115 }
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
116 tokenType = scanner.Tag;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
117 return true;
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
118 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
119
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
120 protected abstract int Read(char[] buffer, int offset, int size);
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
121
180
c32688129f14 refactoring complete, JSONParser rewritten
cin
parents: 179
diff changeset
122
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
123 /// <summary>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
124 /// Читает следующий лексический элемент из входных данных.
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
125 /// </summary>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
126 /// <param name="tokenValue">Возвращает значение прочитанного токена.</param>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
127 /// <param name="tokenType">Возвращает тип прочитанного токена.</param>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
128 /// <returns><c>true</c> - чтение произведено успешно. <c>false</c> - достигнут конец входных данных</returns>
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
129 /// <remarks>В случе если токен не распознается, возникает исключение. Значения токенов обрабатываются, т.е.
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
130 /// в строках обрабатываются экранированные символы, числа становтся типа double.</remarks>
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
131 public bool ReadToken(out string tokenValue, out JsonTokenType tokenType) {
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
132 JsonGrammar.TokenType tag;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
133 m_tokenBuilder.Clear();
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
134 while (ReadChunk(m_jsonContext, out tag)) {
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
135 switch (tag) {
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
136 case JsonGrammar.TokenType.StringBound:
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
137 tokenValue = ReadString();
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
138 tokenType = JsonTokenType.String;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
139 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
140 case JsonGrammar.TokenType.Number:
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
141 tokenValue = m_tokenBuilder.ToString();
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
142 tokenType = JsonTokenType.Number;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
143 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
144 case JsonGrammar.TokenType.Literal:
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
145 tokenType = JsonTokenType.Literal;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
146 tokenValue = m_tokenBuilder.ToString();
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
147 break;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
148 case JsonGrammar.TokenType.Whitespace:
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
149 m_tokenBuilder.Clear();
183
4f82e0f161c3 fixed DFA optimization, JSON is fully functional
cin
parents: 180
diff changeset
150 continue;
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
151 default:
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
152 tokenType = (JsonTokenType)tag;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
153 tokenValue = null;
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
154 break;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
155 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
156 return true;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
157 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
158 tokenValue = null;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
159 tokenType = JsonTokenType.None;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
160 return false;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
161 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
162
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
163 string ReadString() {
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
164 JsonGrammar.TokenType tag;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
165 m_tokenBuilder.Clear();
176
0c3c69fe225b rewritten the text scanner
cin
parents: 165
diff changeset
166
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
167 while (ReadStringChunk(m_stringContext, out tag)) {
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
168 switch (tag) {
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
169 case JsonGrammar.TokenType.StringBound:
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
170 m_tokenBuilder.Length--;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
171 return m_tokenBuilder.ToString();
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
172 case JsonGrammar.TokenType.UnescapedChar:
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
173 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
174 case JsonGrammar.TokenType.EscapedUnicode: // \xXXXX - unicode escape sequence
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
175 m_tokenBuilder.CopyTo(m_tokenBuilder.Length - 4, m_unescapeBuf, 0, 4);
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
176 m_tokenBuilder.Length -= 6;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
177 m_tokenBuilder.Append(StringTranslator.TranslateHexUnicode(m_unescapeBuf, 0));
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
178 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
179 case JsonGrammar.TokenType.EscapedChar: // \t - escape sequence
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
180 var ch = m_tokenBuilder[m_tokenBuilder.Length-1];
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
181 m_tokenBuilder.Length -= 2;
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 208
diff changeset
182 m_tokenBuilder.Append(StringTranslator.TranslateEscapedChar(ch));
163
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
183 break;
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
184 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
185 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
186
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
187 throw new ParserException("Unexpected end of data");
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
188 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
189 }
419aa51b04fd JSON moved to Formats namespace
cin
parents:
diff changeset
190 }