Closed Whiteknight closed 1 year ago
If the ParseResultSequence returns a failure result, the underlying sequence will be in the same position so all subsequent reads from that same position will produce the same failure. So, once we hit a failure, we're done. We should be able to detect this situation and return a cached error value which is similar but distinct from an end sentinel.
GetNext()
should be able to detect .IsAtEnd
for the underlying sequence and choose what to do:
This is done now. There's a callback that can be passed to the FromParseResult()
method which can be used to construct a result. +tests.
There are two options:
In either case we probably want to change the setup of parse result sequences to give the user a bit more easy control over what gets returned, and what happens in other cases (what if the inner parser fails? Throw an exception? Return the failure as-is?) etc.
Since this type is so critical for 2-stage parsers, and we have several examples in the test suite which showcase it, we need to make sure whatever we put in supports downstream parsing efforts.