public void AdvanceCharBy5_OnNewSlidingTextWindow_ChangesOffsetTo5()
        {
            var sourceText        = SourceText.From("abcdefghijklmnopqrstuvwyx0123456789");
            var slidingTextWindow = new SlidingTextWindow(sourceText);

            slidingTextWindow.AdvanceChar(5);

            Assert.AreEqual(5, slidingTextWindow.Offset);
        }
        public void PeekChar_WithOffsetMoreThanDefaultWindowLength_ReturnsCharacter()
        {
            var text              = "abcdefghijklmnopqrstuvwyx0123456789";
            var sourceText        = SourceText.From(text);
            var slidingTextWindow = new SlidingTextWindow(sourceText);

            slidingTextWindow.AdvanceChar(30);

            var peekedChar = slidingTextWindow.PeekChar();

            Assert.AreEqual(text[30], peekedChar);
        }
Exemple #3
0
        private string LexSyntaxTrivia()
        {
            TextWindow.Start();

            var ch = TextWindow.PeekChar();

            while (char.IsWhiteSpace(ch))
            {
                TextWindow.AdvanceChar();
                ch = TextWindow.PeekChar();
            }

            return(TextWindow.GetText());
        }