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"); }
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"); }
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"); }
public void Parser_OfAtLeastOneChar_AcceptsManyChars() { AssertParser.SucceedsWithAll(Parse.Char('a').AtLeastOnce(), "aaa"); }
public void Parser_OfManyChars_AcceptsManyChars() { AssertParser.SucceedsWithAll(Parse.Char('a').Many(), "aaa"); }
public void Parser_OfManyChars_AcceptsEmptyInput() { AssertParser.SucceedsWithAll(Parse.Char('a').Many(), ""); }
public void ParsesString_AsSequenceOfChars() { var p = Parse.String("abc"); AssertParser.SucceedsWithAll(p, "abc"); }
public void WhenFirstOptionSucceedsButConsumesNothing_SecondOptionTried() { var p = Parse.Char('a').Many().XOr(Parse.Char('b').Many()); AssertParser.SucceedsWithAll(p, "bbb"); }