private void ExtractLiteral(ReadCharBag charBag = null) { ReadCharBag currentBag = charBag ?? _readCharBag; History <char> previousCharCircularArray = new History <char>(3); while (true) { _currentChar = (char)_sourceStream.ReadByte(); if (_currentChar == '"') { if (previousCharCircularArray.Current == '\\') { if (previousCharCircularArray.Preceding(1) == '\\') { break; } } else { break; } } else if (_currentChar == '\uffff') { throw new EndOfFileExtractLiteralException(); } currentBag.Add(_currentChar); previousCharCircularArray.Add(_currentChar); } }
public static ReadCharBag FromCharBag([NotNull] ReadCharBag initialBag) { if (initialBag == null) { throw new ArgumentNullException(nameof(initialBag)); } var result = new ReadCharBag { _readChars = new char[initialBag._readChars.Length] }; initialBag._readChars.CopyTo(result._readChars, 0); return(result); }
private void ExtractDigit(ReadCharBag charBag = null) { ReadCharBag currentBag = charBag ?? _readCharBag; while (true) { _currentChar = (char)_sourceStream.ReadByte(); if (!char.IsDigit(_currentChar)) { break; } currentBag.Add(_currentChar); } }
private void ExtractWhisteSpace(ReadCharBag charBag = null) { ReadCharBag currentBag = charBag ?? _readCharBag; while (true) { _currentChar = (char)_sourceStream.ReadByte(); if (!char.IsWhiteSpace(_currentChar)) { if (_currentChar != '\uffff') { _sourceStream.Position--; } break; } currentBag.Add(_currentChar); } }
private void ExtractKeyword(ReadCharBag charBag = null) { ReadCharBag currentBag = charBag ?? _readCharBag; while (true) { _currentChar = (char)_sourceStream.ReadByte(); if (_currentChar == ':' || _currentChar == ',' || char.IsWhiteSpace(_currentChar)) { break; } if (_currentChar == '\uffff') { throw new EndOfFileExtractLiteralException(); } currentBag.Add(_currentChar); } }
private JsonLexer() { _readCharBag = new ReadCharBag(); Diagnostics = new DiagnosticBag(); }