コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        private void ExtractDigit(ReadCharBag charBag = null)
        {
            ReadCharBag currentBag = charBag ?? _readCharBag;

            while (true)
            {
                _currentChar = (char)_sourceStream.ReadByte();
                if (!char.IsDigit(_currentChar))
                {
                    break;
                }
                currentBag.Add(_currentChar);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 private JsonLexer()
 {
     _readCharBag = new ReadCharBag();
     Diagnostics  = new DiagnosticBag();
 }