internal override InternalResult <U> Parse(ref ParseState <TToken> state) { var start = state.Location; state.PushBookmark(); // don't discard input buffer var result = _parser.Parse(ref state); if (!result.Success) { state.PopBookmark(); return(InternalResult.Failure <U>(result.ConsumedInput)); } var delta = state.Location - start; var val = _selector(state.LookBehind(delta), result.Value); state.PopBookmark(); return(InternalResult.Success <U>(val, result.ConsumedInput)); }
internal sealed override bool TryParse(ref ParseState <TToken> state, ref ExpectedCollector <TToken> expecteds, out U result) { var start = state.Location; state.PushBookmark(); // don't discard input buffer var success = _parser.TryParse(ref state, ref expecteds, out var result1); if (!success) { state.PopBookmark(); result = default; return(false); } var delta = state.Location - start; result = _selector(state.LookBehind(delta), result1); state.PopBookmark(); return(true); }