UNPKG

rawsql-ts

Version:

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

48 lines (47 loc) 1.97 kB
import { Lexeme, TokenType } from "../models/Lexeme"; import { ValueComponent } from "../models/ValueComponent"; export declare class ValueParser { static parse(query: string): ValueComponent; /** * Parse from lexeme array with logical operator controls */ static parseFromLexeme(lexemes: Lexeme[], index: number, allowAndOperator?: boolean, allowOrOperator?: boolean): { value: ValueComponent; newIndex: number; }; /** * Parse expressions with operator precedence handling * Uses precedence climbing algorithm */ private static parseExpressionWithPrecedence; /** * Transfer positioned comments from lexeme to value component if the component doesn't already handle them */ private static transferPositionedComments; private static parseItem; static parseArgument(openToken: TokenType, closeToken: TokenType, lexemes: Lexeme[], index: number): { value: ValueComponent; newIndex: number; }; /** * Parse postfix array access operations [index] or [start:end] * @param lexemes Array of lexemes * @param index Current index * @param baseExpression The base expression to apply array access to * @returns Result with potentially modified expression and new index */ private static parseArrayAccess; /** * Check if the bracket at the given index represents SQL Server bracket identifier syntax * Returns true if this looks like [identifier] or [schema].[table] syntax */ private static isSqlServerBracketIdentifier; /** * Determines if a type token followed by parentheses is a type constructor or function call * @param lexemes Array of lexemes * @param openParenIndex Index of the opening parenthesis * @param typeName Name of the type/function * @returns True if this is a type constructor, false if it's a function call */ private static isTypeConstructor; }