Exemple #1
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");
        }
Exemple #2
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");
        }
Exemple #3
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");
        }
Exemple #4
0
 public void Parser_OfAtLeastOneChar_AcceptsManyChars()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').AtLeastOnce(), "aaa");
 }
Exemple #5
0
 public void Parser_OfManyChars_AcceptsManyChars()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "aaa");
 }
Exemple #6
0
 public void Parser_OfManyChars_AcceptsEmptyInput()
 {
     AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "");
 }
Exemple #7
0
        public void ParsesString_AsSequenceOfChars()
        {
            var p = Parse.String("abc");

            AssertParser.SucceedsWithAll(p, "abc");
        }
Exemple #8
0
        public void WhenFirstOptionSucceedsButConsumesNothing_SecondOptionTried()
        {
            var p = Parse.Char('a').Many().XOr(Parse.Char('b').Many());

            AssertParser.SucceedsWithAll(p, "bbb");
        }
Exemple #9
0
 public void CanParseMutuallyLeftRecursiveGrammar()
 {
     AssertParser.SucceedsWithAll(ABSeq.End(), "baba");
 }