docs: IntervalType scanIntervalType() {
  
          int       precision = -1;
          int       scale     = -1;
          int       startToken;
          int       endToken;
          final int errorCode = ErrorCode.X_22006;
  
          startToken = endToken = token.tokenType;
  
          scanNext(errorCode);
  
          if (token.tokenType == Tokens.OPENBRACKET) {
              scanNext(errorCode);
  
              if (token.dataType == null
                      || token.dataType.typeCode != Types.SQL_INTEGER) {
                  throw Error.error(errorCode);
              }
  
              precision = ((Number) this.token.tokenValue).intValue();
  
              scanNext(errorCode);
  
              if (token.tokenType == Tokens.COMMA) {
                  if (startToken != Tokens.SECOND) {
                      throw Error.error(errorCode);
                  }
  
                  scanNext(errorCode);
  
                  if (token.dataType == null
                          || token.dataType.typeCode != Types.SQL_INTEGER) {
                      throw Error.error(errorCode);
                  }
  
                  scale = ((Number) token.tokenValue).intValue();
  
                  scanNext(errorCode);
              }
  
              if (token.tokenType != Tokens.CLOSEBRACKET) {
                  throw Error.error(errorCode);
              }
  
              scanNext(errorCode);
          }
  
          if (token.tokenType == Tokens.TO) {
              scanNext(errorCode);
  
              endToken = token.tokenType;
  
              scanNext(errorCode);
          }
  
          if (token.tokenType == Tokens.OPENBRACKET) {
              if (endToken != Tokens.SECOND || endToken == startToken) {
                  throw Error.error(errorCode);
              }
  
              scanNext(errorCode);
  
              if (token.dataType == null
                      || token.dataType.typeCode != Types.SQL_INTEGER) {
                  throw Error.error(errorCode);
              }
  
              scale = ((Number) token.tokenValue).intValue();
  
              scanNext(errorCode);
  
              if (token.tokenType != Tokens.CLOSEBRACKET) {
                  throw Error.error(errorCode);
              }
  
              scanNext(errorCode);
          }
  
          int startIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
                                          startToken);
          int endIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
                                        endToken);
  
          return IntervalType.getIntervalType(startIndex, endIndex, precision,
                                              scale);
      }