Beispiel #1
0
        public int NextCharacter()
        {
            // Check if anything's been buffered ahead
            if (readBufferLength > 1)
            {
                // Move the start index forward
                readBufferStartIndex = (readBufferStartIndex + 1) & 7;

                // Decrement the length
                readBufferLength = readBufferLength - 1;

                // Read the buffered character
                currentCharacter = readBuffer[readBufferStartIndex];
            }
            else
            {
                // Read the next character
                currentCharacter = inputReader.Read();

                // Save the character into the read buffer so we can Peek(0) it
                readBuffer[readBufferStartIndex] = currentCharacter;
            }

            // Record the character
            RecordCharacter(currentCharacter);

            // Bump the character position
            currentPosition.BumpForChar(currentCharacter);

            // Return the new current character;
            return(currentCharacter);
        }
Beispiel #2
0
        public int NextCharacter()
        {
            currentIndex = currentIndex + 1;

            if (currentIndex >= inputString.Length)
            {
                currentPosition.BumpForChar(-1);
                return(-1);
            }

            var c = inputString[currentIndex];

            currentPosition.BumpForChar(c);

            return(c);
        }