parseText$Async method
Text =
$^,"\n\r
*
;
Implementation
AsyncResult<String> parseText$Async(State<ChunkedParsingSink> state) {
final $0 = AsyncResult<String>();
String? $2;
var $3 = 0;
late int $4;
late bool $5;
void $1() {
while (true) {
switch ($3) {
case 0:
$4 = state.pos;
state.input.beginBuffering();
$5 = state.ignoreErrors;
state.ignoreErrors = true;
$3 = 2;
break;
case 1:
state.ignoreErrors = $5;
state.setOk(true);
state.input.endBuffering();
if (state.ok) {
final input = state.input;
final start = input.start;
$2 = input.data.substring($4 - start, state.pos - start);
}
$0.value = $2;
$0.isComplete = true;
state.input.handle = $0.onComplete;
$3 = -1;
return;
case 2:
final $6 = state.input;
if (state.pos >= $6.end && !$6.isClosed) {
$6.sleep = true;
$6.handle = $1;
$3 = 2;
return;
}
if (state.pos < $6.end) {
final c = $6.data.runeAt(state.pos - $6.start);
final $7 = !(c < 13 ? c == 10 : c <= 13 || c == 34 || c == 44);
if ($7) {
state.pos += c > 0xffff ? 2 : 1;
state.setOk(true);
} else {
state.fail(const ErrorUnexpectedCharacter());
}
} else {
state.fail(const ErrorUnexpectedEndOfInput());
}
if (!state.ok) {
$3 = 1;
break;
}
$3 = 2;
break;
default:
throw StateError('Invalid state: ${$3}');
}
}
}
$1();
return $0;
}