parseAsync method
Experimental. Not yet fully implemented
Implementation
@override
AsyncResult<O> parseAsync(State<ChunkedData<I>> state) {
final result = AsyncResult<O>();
late AsyncResult<O> r1;
final failPos = state.failPos;
final errorCount = state.errorCount;
var action = 0;
void parse() {
while (true) {
switch (action) {
case 0:
r1 = p.parseAsync(state);
action = 1;
if (r1.ok == null) {
r1.handler = parse;
return;
}
break;
case 1:
if ((result.ok = r1.ok) == true) {
result.value = r1.value;
} else {
if (state.canHandleError(failPos, errorCount)) {
if (state.pos == state.failPos) {
state.clearErrors(failPos, errorCount);
state.fail<Object?>(ErrorExpectedTag(tag));
}
}
}
state.input.handler = result.handler;
action = -1;
return;
default:
throw StateError('Invalid state: $action');
}
}
}
parse();
return result;
}