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); }
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); }
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); }
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); }