Beispiel #1
0
 public void MixTest()
 {
     var expr   = Repeat.Create(Sequence.Create(first, Continue.Create(second), (a, b) => ""), list => list.Count);
     var parser = Parser.Create(expr);
     {
         Assert.IsTrue(parser.Parse("123456123456", out var ret, out var exceptions, out _));
         Assert.AreEqual(ret, 2);
     }
     {
         Assert.IsFalse(parser.Parse("123123456", out _, out var exceptions, out _));
         Assert.AreEqual(exceptions.Count, 1);
     }
 }
Beispiel #2
0
 public void SequenceTest()
 {
     var expr   = Sequence.Create(first, Continue.Create(second), third, (a, b, c) => "OK");
     var parser = Parser.Create(expr);
     {
         Assert.IsTrue(parser.Parse("123456789", out var ret, out _, out _));
         Assert.AreEqual(ret, "OK");
     }
     {
         Assert.IsFalse(parser.Parse("123789", out _, out var exceptions, out _));
         Assert.AreEqual(exceptions.Count, 1);
     }
 }