parseRows$Async method

AsyncResult<List<List<String>>> parseRows$Async(
  1. State<ChunkedParsingSink> state
)

Rows = v:@list1(Row, RowEnding ↑ v:Row) ;

Implementation

AsyncResult<List<List<String>>> parseRows$Async(
    State<ChunkedParsingSink> state) {
  final $0 = AsyncResult<List<List<String>>>();
  List<List<String>>? $2;
  var $3 = 0;
  late bool $6;
  late List<List<String>> $7;
  List<String>? $4;
  late AsyncResult<List<String>> $8;
  List<String>? $5;
  late bool $11;
  late bool $12;
  late int $13;
  late int $14;
  late AsyncResult<Object?> $15;
  late int $17;
  List<String>? $10;
  late AsyncResult<List<String>> $20;
  void $1() {
    while (true) {
      switch ($3) {
        case 0:
          $7 = [];
          $8 = parseRow$Async(state);
          if (!$8.isComplete) {
            $8.onComplete = $1;
            $3 = 1;
            return;
          }
          $3 = 1;
          break;
        case 1:
          $4 = $8.value;
          final $22 = state.ok;
          if (!$22) {
            $3 = 2;
            break;
          }
          $7.add($4!);
          $6 = state.ignoreErrors;
          state.ignoreErrors = true;
          $3 = 4;
          break;
        case 2:
          state.setOk($7.isNotEmpty);
          if (state.ok) {
            $2 = $7;
          }
          $0.value = $2;
          $0.isComplete = true;
          state.input.handle = $0.onComplete;
          $3 = -1;
          return;
        case 3:
          state.ignoreErrors = $6;
          $3 = 2;
          break;
        case 4:
          $13 = state.pos;
          $12 = true;
          $11 = state.ignoreErrors;
          $14 = state.pos;
          $15 = fastParseEol$Async(state);
          if (!$15.isComplete) {
            $15.onComplete = $1;
            $3 = 5;
            return;
          }
          $3 = 5;
          break;
        case 5:
          final $24 = state.ok;
          if (!$24) {
            $3 = 6;
            break;
          }
          $17 = state.pos;
          state.input.beginBuffering();
          $3 = 7;
          break;
        case 6:
          if (!state.ok) {
            state.backtrack($14);
          }
          final $25 = state.ok;
          if (!$25) {
            $3 = 8;
            break;
          }
          $12 = false;
          state.ignoreErrors = false;
          state.setOk(true);
          state.input.cut(state.pos);
          final $26 = state.ok;
          if (!$26) {
            $3 = 9;
            break;
          }
          $20 = parseRow$Async(state);
          if (!$20.isComplete) {
            $20.onComplete = $1;
            $3 = 10;
            return;
          }
          $3 = 10;
          break;
        case 7:
          final $18 = state.input;
          if (state.pos >= $18.end && !$18.isClosed) {
            $18.sleep = true;
            $18.handle = $1;
            $3 = 7;
            return;
          }
          if (state.pos >= $18.end) {
            state.setOk(true);
          } else {
            state.fail(const ErrorExpectedEndOfInput());
          }
          state.input.endBuffering();
          if (state.ok) {
            final length = $17 - state.pos;
            state.fail(switch (length) {
              0 => const ErrorUnexpectedInput(0),
              -1 => const ErrorUnexpectedInput(-1),
              -2 => const ErrorUnexpectedInput(-2),
              _ => ErrorUnexpectedInput(length)
            });
            state.backtrack($17);
          } else {
            state.setOk(true);
          }
          $3 = 6;
          break;
        case 8:
          if (!state.ok) {
            if (!$12) {
              state.isRecoverable = false;
            }
            state.backtrack($13);
          }
          state.ignoreErrors = $11;
          if (!state.ok) {
            $3 = 3;
            break;
          }
          $7.add($5!);
          $3 = 4;
          break;
        case 9:
          $3 = 8;
          break;
        case 10:
          $10 = $20.value;
          if (state.ok) {
            $5 = $10;
          }
          $3 = 9;
          break;
        default:
          throw StateError('Invalid state: ${$3}');
      }
    }
  }

  $1();
  return $0;
}