public void TestConsumeTab() { var stream = new TabAwareCharacterStream("a\tb"); stream.CurrentChar.Should().Be('a'); stream.MoveToNextChar(); stream.TryConsumeWhiteSpace(4).Should().BeTrue(); stream.CurrentChar.Should().Be('b'); stream.TryConsumeWhiteSpace(1).Should().BeFalse(); }
public void TestConsumePartialTab() { var stream = new TabAwareCharacterStream("a\tb"); stream.CurrentChar.Should().Be('a'); stream.MoveToNextChar(); stream.TryConsumeWhiteSpace(2).Should().BeTrue(); stream.CurrentChar.Should().Be('b', "stream should be at next character after consuming partial tab"); stream.TryConsumeWhiteSpace(2).Should().BeTrue(); stream.CurrentChar.Should().Be('b'); stream.TryConsumeWhiteSpace(1).Should().BeFalse(); }
public void TestConsumeTooMuch() { var stream = new TabAwareCharacterStream("a\tb"); stream.MoveToNextChar(); stream.TryConsumeWhiteSpace(2).Should().BeTrue(); stream.TryConsumeWhiteSpace(3).Should().BeFalse(); stream.CurrentChar.Should().Be('b'); stream.TryConsumeWhiteSpace(2).Should().BeTrue("consuming too much space should have no effect"); stream.CurrentChar.Should().Be('b'); stream.TryConsumeWhiteSpace(1).Should().BeFalse(); }
public void TestPeekPartialTab() { var stream = new TabAwareCharacterStream("a\tb"); stream.MoveToNextChar(); stream.TryConsumeWhiteSpace(2).Should().BeTrue(); using (stream.Peek()) stream.TryConsumeWhiteSpace(2).Should().BeTrue(); stream.TryConsumeWhiteSpace(2).Should().BeTrue("resetting peek should preserve partial tabs"); stream.CurrentChar.Should().Be('b'); stream.TryConsumeWhiteSpace(1).Should().BeFalse(); }
public void TestConsumeMixedWhitespace() { var stream = new TabAwareCharacterStream("a \t \t\t \tb"); stream.MoveToNextChar(); // Stream is at first space stream.TryConsumeWhiteSpace(99).Should().BeFalse(); stream.TryConsumeWhiteSpace(2).Should().BeTrue(); // Stream is at center of first tab stream.TryConsumeWhiteSpace(99).Should().BeFalse(); stream.TryConsumeWhiteSpace(4).Should().BeTrue(); // Stream is at second tab stream.TryConsumeWhiteSpace(99).Should().BeFalse(); stream.TryConsumeWhiteSpace(5).Should().BeTrue(); // Stream is at first space in third tab stream.TryConsumeWhiteSpace(99).Should().BeFalse(); stream.TryConsumeWhiteSpace(9).Should().BeTrue(); stream.CurrentChar.Should().Be('b'); }
protected ParserBase(TabAwareCharacterStream stream, Action<Artifact> reporter) { this.stream = stream; this.artifactReporter = reporter; }
public FencedCodeBlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
public ContentBlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
public MarkdownParser(TabAwareCharacterStream stream) { this.stream = stream; }
protected BlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
protected StreamPeeker(TabAwareCharacterStream stream) { this.Stream = stream; StartPosition = stream.Position; }
public TabAwarePeeker(TabAwareCharacterStream stream) : base(stream) { this.remainingSpaces = stream.remainingSpaces; }