Example #1
0
        internal sealed override bool TryParse(ref ParseState <TToken> state, ref ExpectedCollector <TToken> expecteds, out T result)
        {
            state.PushBookmark();

            var success = _parser.TryParse(ref state, ref expecteds, out result);

            if (success)
            {
                state.Rewind();
                return(true);
            }
            state.PopBookmark();
            return(success);
        }
Example #2
0
            internal override InternalResult <T> Parse(ref ParseState <TToken> state)
            {
                state.PushBookmark();

                var result = _parser.Parse(ref state);

                if (result.Success)
                {
                    state.Rewind();
                    return(InternalResult.Success <T>(result.Value, false));
                }
                state.PopBookmark();
                return(result);
            }
Example #3
0
            internal sealed override InternalResult <T> Parse(ref ParseState <TToken> state)
            {
                // start buffering the input
                state.PushBookmark();
                var result = _parser.Parse(ref state);

                if (!result.Success)
                {
                    // return to the start of the buffer and discard the bookmark
                    state.Rewind();
                    return(InternalResult.Failure <T>(false));
                }

                // discard the buffer
                state.PopBookmark();
                return(result);
            }
Example #4
0
        internal sealed override bool TryParse(ref ParseState <TToken> state, ref ExpectedCollector <TToken> expecteds, out T result)
        {
            // start buffering the input
            state.PushBookmark();
            var success = _parser.TryParse(ref state, ref expecteds, out result);

            if (!success)
            {
                // return to the start of the buffer and discard the bookmark
                state.Rewind();
                return(false);
            }

            // discard the buffer
            state.PopBookmark();
            return(true);
        }