コード例 #1
0
        // Peek one char ahead
        private char32 PeekChar()
        {
            if (_preview1 == null)
            {
                var saved = _current;
                NextChar();
                _preview1 = _current;
                _current  = saved;
            }

            return(_preview1.Value.CurrentChar);
        }
コード例 #2
0
 private void Reset()
 {
     // Initialize the position at -1 when starting
     _preview1 = null;
     _current  = new LexerInternalState {
         Position = new TextPosition(_reader.Start, 0, 0)
     };
     // It is important to initialize this separately from the previous line
     _current.CurrentChar = NextCharFromReader();
     _token  = new SyntaxTokenValue();
     _errors = null;
 }
コード例 #3
0
        private void NextChar()
        {
            // If we have a character in preview
            if (_preview1 != null)
            {
                _current  = _preview1.Value;
                _preview1 = null;
                return;
            }

            // Else move to the next position
            _current.Position     = _current.NextPosition;
            _current.PreviousChar = _current.CurrentChar; // save the previous character
            _current.CurrentChar  = NextCharFromReader();
        }