import Decimal from '../../core/decimal/decimal.cjs'; import PositionRange, { Position } from '../../core/positions.cjs'; import IOError from '../../errors/io-error.cjs'; import TokenType from './token-types.cjs'; /** * Represents the error value stored in ERROR tokens. * When the originalError is an IOError, errorCode will be available. */ interface TokenErrorValue { __error: true; errorCode?: string; message: string; originalError: Error; } /** * Type guard to check if an error is an IOError with an errorCode */ declare function isIOError(error: Error): error is IOError; /** * Union type representing all possible token values. * This provides type safety for the parsed value of each token type. */ type TokenValue = string | number | bigint | Decimal | boolean | null | Date | Buffer | TokenErrorValue | undefined; /** * String literal type for token subtypes. */ type TokenSubType = 'REGULAR_STRING' | 'OPEN_STRING' | 'RAW_STRING' | 'BINARY_STRING' | 'HEX' | 'OCTAL' | 'BINARY' | typeof TokenType.DATETIME | typeof TokenType.DATE | typeof TokenType.TIME | typeof TokenType.SECTION_SCHEMA | typeof TokenType.SECTION_NAME | undefined; /** * Represents a parsed token. */ declare class Token implements PositionRange { pos: number; row: number; col: number; token: string; value: TokenValue; type: TokenType | string; subType?: TokenSubType | string; constructor(); /** * Create a token. * @param pos - The starting position of the token in the input. * @param row - The row number of the token's starting position. * @param col - The column number of the token's starting position. * @param token - The raw text of the token from the input. * @param value - The parsed value of the token. * @param type - A descriptive type name for the token. * @param subType - Optional subtype for the token. */ static init(pos: number, row: number, col: number, token: string, value: TokenValue, type: TokenType | string, subType?: TokenSubType | string): Token; clone(): Token; getStartPos(): Position; /** * Returns the ending position (row, col, pos) of the token. * Useful for debugging and generating error messages. */ getEndPos(): Position; } export { type TokenErrorValue, type TokenSubType, type TokenValue, Token as default, isIOError };