annotate Implab/Formats/ReaderScanner.cs @ 226:9428ea36838e v2

fixed JSON parser error when parsing escaped double quote symbol
author cin
date Fri, 25 Aug 2017 02:16:35 +0300
parents 4f82e0f161c3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
1 using System;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
2 using System.IO;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
3
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
4 namespace Implab.Formats {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
5 public class ReaderScanner: TextScanner {
183
4f82e0f161c3 fixed DFA optimization, JSON is fully functional
cin
parents: 176
diff changeset
6 const int CHUNK_SIZE = 1024*4;
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
7 const int BUFFER_MAX = CHUNK_SIZE*1024;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
8
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
9 readonly TextReader m_reader;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
10
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
11 public ReaderScanner(TextReader reader, int limit, int chunk) : base(limit, chunk) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
12 Safe.ArgumentNotNull(reader, "reader");
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
13 m_reader = reader;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
14 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
15
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
16 public ReaderScanner(TextReader reader) : this(reader, BUFFER_MAX, CHUNK_SIZE) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
17 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
18
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
19 protected override int Read(char[] buffer, int offset, int size) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
20 return m_reader.Read(buffer, offset, size);
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
21 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
22
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
23 protected override void Dispose(bool disposing) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
24 if (disposing)
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
25 Safe.Dispose(m_reader);
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
26 base.Dispose(disposing);
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
27 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
28 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
29 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
30