rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
54 lines (53 loc) • 1.5 kB
TypeScript
import { BaseTokenReader } from './BaseTokenReader';
import { Lexeme } from '../models/Lexeme';
/**
* Manages and coordinates multiple token readers
*/
export declare class TokenReaderManager {
private readers;
private input;
private position;
private tokenCache;
private cacheHits;
private cacheMisses;
constructor(input: string, position?: number);
/**
* Register a token reader
* @param reader The reader to register
* @returns This manager instance for chaining
*/
register(reader: BaseTokenReader): TokenReaderManager;
/**
* Register multiple token readers
* @param readers The readers to register
* @returns This manager instance for chaining
*/
registerAll(readers: BaseTokenReader[]): TokenReaderManager;
/**
* Update the position for all readers
*/
private setPosition;
/**
* Try to read a token using all registered readers
* @param position The position to read from
* @param previous The previous token, if any
* @returns The lexeme if a reader could read it, null otherwise
*/
tryRead(position: number, previous: Lexeme | null): Lexeme | null;
/**
* Get the maximum position among all readers
*/
getMaxPosition(): number;
/**
* Get the input string
*/
getInput(): string;
/**
* Get cache statistics
*/
getCacheStats(): {
hits: number;
misses: number;
ratio: number;
};
}