Exemplo n.º 1
0
 public static void FitsTheory(TextParser <TextSpan> parser, string input, bool isMatch)
 {
     if (isMatch)
     {
         SucceedsWithAll(parser, input);
     }
     else
     {
         Fails(parser.AtEnd(), input);
     }
 }
Exemplo n.º 2
0
        public static bool TryParseAll <T>(TextParser <T> parser, string source, out T value, out string error)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var result = parser.AtEnd()(new TextSpan(source));

            if (result.HasValue)
            {
                value = result.Value;
                error = null;
                return(true);
            }

            value = default;
            error = result.ToString();
            return(false);
        }