UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

58 lines (57 loc) 1.69 kB
import { Lexeme } from '../models/Lexeme'; /** * Utility class for cursor-to-lexeme mapping in SQL text * Provides functionality to find lexemes at specific cursor positions for IDE integration */ export declare class LexemeCursor { private static readonly SQL_COMMANDS; /** * Find the lexeme at the specified cursor position * @param sql The SQL string * @param cursorPosition The cursor position (0-based) * @returns The lexeme at the position, or null if not found */ static findLexemeAtPosition(sql: string, cursorPosition: number): Lexeme | null; /** * Get all lexemes with position information * @param sql The SQL string * @returns Array of lexemes with position information */ static getAllLexemesWithPosition(sql: string): Lexeme[]; /** * Skip whitespace characters */ private static skipWhitespace; /** * Parse the next token starting at the given position */ private static parseNextToken; /** * Parse string literal tokens */ private static parseStringLiteral; /** * Parse operator tokens */ private static parseOperator; /** * Parse word tokens (identifiers, commands, functions) */ private static parseWordToken; /** * Determine the token type for operators */ private static getOperatorTokenType; /** * Determine the token type for word tokens */ private static getWordTokenType; /** * Check if token value should be lowercased */ private static shouldLowercase; /** * Create a lexeme with position information */ private static createLexeme; }