示例#1
0
        public static IParsingResult <TInput, T> ErrorMessage <TInput, T>(
            this IParsingResult <TInput, T> result, string errorMessage)
        {
            if (result.Success)
            {
                return(result);
            }
            ParsingError error = result.Error;

            error.Message = errorMessage;
            return(new FailParsingResult <TInput, T>(result.Input, result.Corrections, error));
        }
 public SuccessParsingResult(TValue value, IParserInput <TInput> next,
                             IReadOnlyList <ParsingError> corrections, ParsingError continuationError)
 {
     if (next == null)
     {
         throw new ArgumentNullException(nameof(next));
     }
     _value             = value;
     _next              = next;
     _continuationError = continuationError;
     _corrections       = corrections ?? ReadOnlyList <ParsingError> .Empty;
 }
示例#3
0
 public FailParsingResult(IParserInput <TInput> input, IReadOnlyList <ParsingError> corrections, ParsingError error)
 {
     _input       = input;
     _corrections = corrections;
     _error       = error;
 }
示例#4
0
 public FailParsingResult(IParserInput <TInput> input, ParsingError[] corrections, ParsingError error)
 {
     _input       = input;
     _corrections = corrections == null ? ReadOnlyList <ParsingError> .Empty : new ReadOnlyList <ParsingError>(corrections);
     _error       = error;
 }