fastParseEol$Async method

AsyncResult<Object?> fastParseEol$Async(
  1. State<ChunkedParsingSink> state
)

Eol = '\n' / '\r\n' / '\r' ;

Implementation

AsyncResult<Object?> fastParseEol$Async(State<ChunkedParsingSink> state) {
  final $0 = AsyncResult<Object?>();
  var $2 = 0;
  void $1() {
    while (true) {
      switch ($2) {
        case 0:
          final $3 = state.input;
          if (state.pos >= $3.end && !$3.isClosed) {
            $3.sleep = true;
            $3.handle = $1;
            $2 = 0;
            return;
          }
          const $4 = '\n';
          final $5 = state.pos < $3.end &&
              $3.data.codeUnitAt(state.pos - $3.start) == 10;
          if ($5) {
            state.pos++;
            state.setOk(true);
          } else {
            state.fail(const ErrorExpectedTags([$4]));
          }
          final $15 = !state.ok && state.isRecoverable;
          if (!$15) {
            $2 = 1;
            break;
          }
          $2 = 2;
          break;
        case 1:
          $0.isComplete = true;
          state.input.handle = $0.onComplete;
          $2 = -1;
          return;
        case 2:
          final $7 = state.input;
          if (state.pos + 1 >= $7.end && !$7.isClosed) {
            $7.sleep = true;
            $7.handle = $1;
            $2 = 2;
            return;
          }
          const $8 = '\r\n';
          final $9 = state.pos + 1 < $7.end &&
              $7.data.codeUnitAt(state.pos - $7.start) == 13 &&
              $7.data.codeUnitAt(state.pos - $7.start + 1) == 10;
          if ($9) {
            state.pos += 2;
            state.setOk(true);
          } else {
            state.fail(const ErrorExpectedTags([$8]));
          }
          final $16 = !state.ok && state.isRecoverable;
          if (!$16) {
            $2 = 3;
            break;
          }
          $2 = 4;
          break;
        case 3:
          $2 = 1;
          break;
        case 4:
          final $11 = state.input;
          if (state.pos >= $11.end && !$11.isClosed) {
            $11.sleep = true;
            $11.handle = $1;
            $2 = 4;
            return;
          }
          const $12 = '\r';
          final $13 = state.pos < $11.end &&
              $11.data.codeUnitAt(state.pos - $11.start) == 13;
          if ($13) {
            state.pos++;
            state.setOk(true);
          } else {
            state.fail(const ErrorExpectedTags([$12]));
          }
          $2 = 3;
          break;
        default:
          throw StateError('Invalid state: ${$2}');
      }
    }
  }

  $1();
  return $0;
}