コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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');
        }
コード例 #6
0
 protected ParserBase(TabAwareCharacterStream stream, Action<Artifact> reporter)
 {
     this.stream = stream;
     this.artifactReporter = reporter;
 }
コード例 #7
0
 public FencedCodeBlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
コード例 #8
0
 public ContentBlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
コード例 #9
0
 public MarkdownParser(TabAwareCharacterStream stream)
 {
     this.stream = stream;
 }
コード例 #10
0
 protected BlockParser(TabAwareCharacterStream stream, Action<Artifact> reporter) : base(stream, reporter) { }
コード例 #11
0
 protected StreamPeeker(TabAwareCharacterStream stream)
 {
     this.Stream   = stream;
     StartPosition = stream.Position;
 }
コード例 #12
0
 public TabAwarePeeker(TabAwareCharacterStream stream)
     : base(stream)
 {
     this.remainingSpaces = stream.remainingSpaces;
 }
コード例 #13
0
 public TabAwarePeeker(TabAwareCharacterStream stream)
     : base(stream)
 {
     this.remainingSpaces = stream.remainingSpaces;
 }
コード例 #14
0
 protected StreamPeeker(TabAwareCharacterStream stream)
 {
     this.Stream = stream;
     StartPosition = stream.Position;
 }