parseText$Async method
Text = $TextChar* ;
Implementation
AsyncResult<String> parseText$Async(State<ChunkedParsingSink> state) {
final $0 = AsyncResult<String>();
String? $2;
var $3 = 0;
late int $4;
late bool $5;
late int $7;
int? $6;
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:
$7 = state.pos;
$3 = 3;
break;
case 3:
final $9 = state.input;
if (state.pos >= $9.end && !$9.isClosed) {
$9.sleep = true;
$9.handle = $1;
$3 = 3;
return;
}
if (state.pos < $9.end) {
final $10 = $9.data.runeAt(state.pos - $9.start);
final $11 = !($10 < 13 ? $10 == 10 : $10 <= 13 || $10 == 34);
if ($11) {
state.pos += $10 > 0xffff ? 2 : 1;
$6 = $10;
state.setOk(true);
} else {
state.fail(const ErrorUnexpectedCharacter());
}
} else {
state.fail(const ErrorUnexpectedEndOfInput());
}
if (state.ok) {
// ignore: unused_local_variable
final $$ = $6!;
final $8 = (() => $$ != _separatorChar)();
if (!$8) {
state
.fail(ErrorMessage($7 - state.pos, 'Unexpected character'));
state.backtrack($7);
}
}
if (!state.ok) {
$3 = 1;
break;
}
$3 = 2;
break;
default:
throw StateError('Invalid state: ${$3}');
}
}
}
$1();
return $0;
}