code: private void resolveImplicitLevels(int start, int limit, byte level, byte sor, byte eor) {
          if ((level & 1) == 0) { // even level
              for (int i = start; i < limit; ++i) {
                  byte t = resultTypes[i];
                  // Rule I1.
                  if (t == L ) {
                      // no change
                  } else if (t == R) {
                      resultLevels[i] += 1;
                  } else { // t == AN || t == EN
                      resultLevels[i] += 2;
                  }
              }
          } else { // odd level
              for (int i = start; i < limit; ++i) {
                  byte t = resultTypes[i];
                  // Rule I2.
                  if (t == R) {
                      // no change
                  } else { // t == L || t == AN || t == EN
                      resultLevels[i] += 1;
                  }
              }
          }
      }
docs: 7) resolving implicit embedding levels
  Rules I1, I2.