Example #1
0
        public void Not_Success_ReturnsError()
        {
            var parser = Parse.Not(Chars.Any());
            var result = parser.Parse("xyz");

            ParseAssert.ErrorEquals("Unexpected \"x\"", result);
        }
Example #2
0
        public void Not_Error_ReturnsSuccess()
        {
            var parser = Parse.Not(Chars.String("xyz"));
            var result = parser.Parse("x");

            ParseAssert.ValueEquals(Unit.Instance, result);
        }
Example #3
0
 /// <summary>
 /// Only succeeds when the second parser fails. Returns the result of the first parser.
 /// </summary>
 public static IParser <TValueA> NotFollowedBy <TValueA, TValueB>(this IParser <TValueA> parserA, IParser <TValueB> parserB)
 {
     return(from a in parserA
            from b in Parse.Not(parserB)
            select a);
 }