예제 #1
0
            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);
            }