public ParseResult <TResult> Parse(string text) { if (parseActions is null) { return(ParseResult <TResult> .FormatOnlyPattern); } if (text is null) { return(ParseResult <TResult> .ArgumentNull(nameof(text))); } if (text.Length == 0) { return(ParseResult <TResult> .ValueStringEmpty); } var valueCursor = new ValueCursor(text); // Prime the pump... the value cursor ends up *before* the first character, but // our steps always assume it's *on* the right character. valueCursor.MoveNext(); var result = ParsePartial(valueCursor); if (!result.Success) { return(result); } // Check that we've used up all the text if (valueCursor.Current != TextCursor.Nul) { return(ParseResult <TResult> .ExtraValueCharacters(valueCursor, valueCursor.Remainder)); } return(result); }
/// <summary> /// Performs the first part of the parse, validating the value is non-empty before /// handing over to ParseImpl for the meat of the work. /// </summary> public ParseResult <T> Parse(string text) { if (text == null) { return(ParseResult <T> .ArgumentNull("text")); } if (text.Length == 0) { return(ParseResult <T> .ValueStringEmpty); } return(ParseImpl(text)); }