parseRow$Async method

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

@event Row = @list1(Field, Separator ↑ v:Field) ;

Implementation

AsyncResult<List<String>> parseRow$Async(State<ChunkedParsingSink> state) {
  final $0 = AsyncResult<List<String>>();
  beginEvent(CsvExParserEvent.rowEvent);
  List<String>? $2;
  var $3 = 0;
  late bool $6;
  late List<String> $7;
  String? $4;
  late AsyncResult<String> $8;
  late AsyncResult<String> $10;
  String? $5;
  late bool $13;
  late bool $14;
  late int $15;
  late String $20;
  String? $12;
  late AsyncResult<String> $22;
  late AsyncResult<String> $24;
  void $1() {
    while (true) {
      switch ($3) {
        case 0:
          $7 = [];
          beginEvent(CsvExParserEvent.fieldEvent);
          state.input.beginBuffering();
          $8 = parseString$Async(state);
          if (!$8.isComplete) {
            $8.onComplete = $1;
            $3 = 1;
            return;
          }
          $3 = 1;
          break;
        case 1:
          $4 = $8.value;
          state.input.endBuffering();
          final $26 = !state.ok && state.isRecoverable;
          if (!$26) {
            $3 = 2;
            break;
          }
          $10 = parseText$Async(state);
          if (!$10.isComplete) {
            $10.onComplete = $1;
            $3 = 3;
            return;
          }
          $3 = 3;
          break;
        case 2:
          $4 = endEvent<String>(CsvExParserEvent.fieldEvent, $4, state.ok);
          final $27 = state.ok;
          if (!$27) {
            $3 = 4;
            break;
          }
          $7.add($4!);
          $6 = state.ignoreErrors;
          state.ignoreErrors = true;
          $3 = 6;
          break;
        case 3:
          $4 = $10.value;
          $3 = 2;
          break;
        case 4:
          state.setOk($7.isNotEmpty);
          if (state.ok) {
            $2 = $7;
          }
          endEvent<List<String>>(CsvExParserEvent.rowEvent, $2, state.ok);
          $0.value = $2;
          $0.isComplete = true;
          state.input.handle = $0.onComplete;
          $3 = -1;
          return;
        case 5:
          state.ignoreErrors = $6;
          $3 = 4;
          break;
        case 6:
          $15 = state.pos;
          $14 = true;
          $13 = state.ignoreErrors;
          $20 = _separator;
          final $29 = $20.isEmpty;
          if (!$29) {
            $3 = 7;
            break;
          }
          state.setOk(true);
          $3 = 8;
          break;
        case 7:
          final $17 = state.input;
          if (state.pos + $20.length - 1 >= $17.end && !$17.isClosed) {
            $17.sleep = true;
            $17.handle = $1;
            $3 = 7;
            return;
          }
          final $16 = $17.data;
          final $19 = state.pos - $17.start;
          final $18 = $16.codeUnitAt($19) == $20.codeUnitAt(0) &&
              $16.startsWith($20, $19);
          if ($18) {
            state.pos += $20.length;
            state.setOk(true);
          } else {
            state.fail(ErrorExpectedTags([$20]));
          }
          $3 = 8;
          break;
        case 8:
          final $30 = state.ok;
          if (!$30) {
            $3 = 9;
            break;
          }
          $14 = false;
          state.ignoreErrors = false;
          state.setOk(true);
          state.input.cut(state.pos);
          final $31 = state.ok;
          if (!$31) {
            $3 = 10;
            break;
          }
          beginEvent(CsvExParserEvent.fieldEvent);
          state.input.beginBuffering();
          $22 = parseString$Async(state);
          if (!$22.isComplete) {
            $22.onComplete = $1;
            $3 = 11;
            return;
          }
          $3 = 11;
          break;
        case 9:
          if (!state.ok) {
            if (!$14) {
              state.isRecoverable = false;
            }
            state.backtrack($15);
          }
          state.ignoreErrors = $13;
          if (!state.ok) {
            $3 = 5;
            break;
          }
          $7.add($5!);
          $3 = 6;
          break;
        case 10:
          $3 = 9;
          break;
        case 11:
          $12 = $22.value;
          state.input.endBuffering();
          final $32 = !state.ok && state.isRecoverable;
          if (!$32) {
            $3 = 12;
            break;
          }
          $24 = parseText$Async(state);
          if (!$24.isComplete) {
            $24.onComplete = $1;
            $3 = 13;
            return;
          }
          $3 = 13;
          break;
        case 12:
          $12 = endEvent<String>(CsvExParserEvent.fieldEvent, $12, state.ok);
          if (state.ok) {
            $5 = $12;
          }
          $3 = 10;
          break;
        case 13:
          $12 = $24.value;
          $3 = 12;
          break;
        default:
          throw StateError('Invalid state: ${$3}');
      }
    }
  }

  $1();
  return $0;
}