/** * Lexer for tokenizing formula strings */ /** * Token types for formula lexing */ export type TokenType = 'NUMBER' | 'STRING' | 'BOOLEAN' | 'IDENTIFIER' | 'FUNCTION' | 'OPERATOR' | 'LPAREN' | 'RPAREN' | 'LBRACE' | 'RBRACE' | 'LBRACKET' | 'RBRACKET' | 'COMMA' | 'SEMICOLON' | 'COLON' | 'DOLLAR' | 'EXCLAMATION' | 'AT' | 'HASH' | 'INFINITY' | 'ERROR' | 'EOF' | 'WHITESPACE'; /** * Token interface */ export interface Token { type: TokenType; value: string; position: { start: number; end: number; }; } /** * Lexer class for tokenizing formula strings */ export declare class Lexer { private input; private position; private tokens; constructor(input: string); /** * Tokenize the entire input string */ tokenize(): Token[]; /** * Get the next token from the input */ private nextToken; /** * Read a whitespace token */ private readWhitespace; /** * Read a number token */ private readNumber; /** * Read a string token (enclosed in double quotes) */ private readString; /** * Read a sheet name (enclosed in single quotes) */ private readSheetName; /** * Read an error token (e.g., #DIV/0!) */ private readError; /** * Read an identifier (cell reference, function name, boolean) */ private readIdentifier; /** * Check if current position is whitespace */ private isWhitespace; /** * Check if a character is whitespace */ private isWhitespaceChar; /** * Check if a character is a digit */ private isDigit; /** * Check if a character is alphabetic */ private isAlpha; /** * Check if a character is alphanumeric */ private isAlnum; /** * Check if a character can be part of an identifier * This includes letters, certain symbols that are commonly used in column names */ private isIdentifierChar; /** * Peek ahead to check if we have a table selector */ private peekSelector; } /** * Quick tokenization function */ export declare function tokenize(input: string): Token[]; /** * Token stream for parser consumption */ export declare class TokenStream { private tokens; private position; constructor(tokens: Token[]); /** * Peek at current token without consuming */ peek(): Token; /** * Peek ahead by n tokens */ peekAhead(n: number): Token | null; /** * Peek at the next token without consuming */ peekNext(): Token | null; /** * Consume current token and advance */ consume(): Token; /** * Check if current token matches type */ match(type: TokenType): boolean; /** * Check if current token matches value */ matchValue(value: string): boolean; /** * Consume token if it matches type */ consumeIf(type: TokenType): Token | null; /** * Check if at end of stream */ isAtEnd(): boolean; /** * Get current position in stream */ getPosition(): number; /** * Set position in stream */ setPosition(position: number): void; /** * Get all tokens */ getTokens(): Token[]; }