/** * Token Utilities * * Core token creation, stream implementation, and character classification. * These are the foundational building blocks used by all tokenizers. */ import type { LanguageToken, TokenKind, TokenStream, StreamMark, SourcePosition } from '../types'; /** * Configuration for a native language time unit pattern. * Used by tryNumberWithTimeUnits() to match language-specific time units. */ export interface TimeUnitMapping { /** The pattern to match (e.g., 'segundos', 'ミリ秒') */ readonly pattern: string; /** The standard suffix to use (ms, s, m, h) */ readonly suffix: string; /** Length of the pattern (for optimization) */ readonly length: number; /** Whether to check for word boundary after the pattern */ readonly checkBoundary?: boolean; /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */ readonly notFollowedBy?: string; /** Whether to do case-insensitive matching */ readonly caseInsensitive?: boolean; } /** * Concrete implementation of TokenStream. */ export declare class TokenStreamImpl implements TokenStream { readonly tokens: readonly LanguageToken[]; readonly language: string; private pos; constructor(tokens: LanguageToken[], language: string); peek(offset?: number): LanguageToken | null; advance(): LanguageToken; isAtEnd(): boolean; mark(): StreamMark; reset(mark: StreamMark): void; position(): number; /** * Get remaining tokens as an array. */ remaining(): LanguageToken[]; /** * Consume tokens while predicate is true. */ takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[]; /** * Skip tokens while predicate is true. */ skipWhile(predicate: (token: LanguageToken) => boolean): void; } /** * Create a source position from start and end offsets. */ export declare function createPosition(start: number, end: number): SourcePosition; /** * Options for creating a token with optional morphological data. */ export interface CreateTokenOptions { /** Explicitly normalized form from keyword map */ normalized?: string; /** Morphologically normalized stem */ stem?: string; /** Confidence in the stem (0.0-1.0) */ stemConfidence?: number; /** Additional metadata for specific token types (e.g., event modifier data) */ metadata?: Record; } /** * Token creation options (object style). */ export interface TokenCreationParams extends CreateTokenOptions { value: string; kind: TokenKind; position: SourcePosition; } /** * Create a language token (object style). */ export declare function createToken(params: TokenCreationParams): LanguageToken; /** * Create a language token (separate parameters style). */ export declare function createToken(value: string, kind: TokenKind, position: SourcePosition, normalizedOrOptions?: string | CreateTokenOptions): LanguageToken; /** * Check if a character is whitespace. */ export declare function isWhitespace(char: string): boolean; /** * Check if a string starts with a CSS selector prefix. * Includes JSX-style element selectors:
,
*/ export declare function isSelectorStart(char: string): boolean; /** * Check if a character is a quote (string delimiter). */ export declare function isQuote(char: string): boolean; /** * Check if a character is a digit. */ export declare function isDigit(char: string): boolean; /** * Strip diacritical marks that are OPTIONAL in their script — currently Arabic * harakat (U+064B–U+0652: fatha, kasra, damma, sukun, shadda…) and the * superscript alif (U+0670). * * `بدّل` and `بَدِّل` are the same word; Arabic prose writes either. So any place * that compares an Arabic surface form against a declared keyword has to compare * stripped, or the same word fails to match itself. * * Deliberately Arabic-only. Latin diacritics are NOT optional — `obtén`, `récupère` * and `vá` differ from their unaccented spellings in meaning or validity — and * Hebrew niqqud (U+05B0–U+05BC) is out of range too, so this is inert for every * other script. */ export declare function stripOptionalDiacritics(word: string): string; /** * Check if a character is an ASCII letter. */ export declare function isAsciiLetter(char: string): boolean; /** * Check if a character is part of an ASCII identifier. */ export declare function isAsciiIdentifierChar(char: string): boolean; //# sourceMappingURL=token-utils.d.ts.map