예제 #1
0
 public void WithOr_WhenFirstOptionFailsAndConsumesInput_SecondOptionTried()
 {
     var first = Parse.Char('a').Once().Concat(Parse.Char('b').Once());
     var second = Parse.Char('a').Once();
     var p = first.Or(second);
     AssertParser.SucceedsWithAll(p, "a");
 }
예제 #2
0
        public void CanSpecifyParsersUsingQueryComprehensions()
        {
            var p = from a in Parse.Char('a').Once()
                    from bs in Parse.Char('b').Many()
                    from cs in Parse.Char('c').AtLeastOnce()
                    select a.Concat(bs).Concat(cs);

            AssertParser.SucceedsWithAll(p, "abbbc");
        }
예제 #3
0
 public void ConcatenatingParsers_ConcatenatesResults()
 {
     var p = Parse.Char('a').Once().Then(a =>
         Parse.Char('b').Once().Select(b => a.Concat(b)));
     AssertParser.SucceedsWithAll(p, "ab");
 }
예제 #4
0
 public void Parser_OfAtLeastOneChar_AcceptsManyChars()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').AtLeastOnce(), "aaa");
 }
예제 #5
0
 public void Parser_OfManyChars_AcceptsManyChars()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "aaa");
 }
예제 #6
0
 public void Parser_OfManyChars_AcceptsEmptyInput()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "");
 }
예제 #7
0
 public void ParsesString_AsSequenceOfChars()
 {
     var p = Parse.String("abc");
     AssertParser.SucceedsWithAll(p, "abc");
 }
예제 #8
0
 public void WhenFirstOptionSucceedsButConsumesNothing_SecondOptionTried()
 {
     var p = Parse.Char('a').Many().XOr(Parse.Char('b').Many());
     AssertParser.SucceedsWithAll(p, "bbb");
 }