UNPKG

rawsql-ts

Version:

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

29 lines 1.26 kB
import { UsingClause } from "../models/Clause"; import { TokenType } from "../models/Lexeme"; import { SourceExpressionParser } from "./SourceExpressionParser"; /** * Parses the USING clause in DELETE statements. */ export class UsingClauseParser { static parseFromLexeme(lexemes, index) { var _a; if (lexemes[index].value !== "using") { throw new Error(`Syntax error at position ${index}: Expected 'USING' but found '${lexemes[index].value}'.`); } let idx = index + 1; const sources = []; // Parse the first source expression referenced by USING. const firstSource = SourceExpressionParser.parseFromLexeme(lexemes, idx); sources.push(firstSource.value); idx = firstSource.newIndex; // Parse any additional sources separated by commas. while (((_a = lexemes[idx]) === null || _a === void 0 ? void 0 : _a.type) === TokenType.Comma) { idx++; const nextSource = SourceExpressionParser.parseFromLexeme(lexemes, idx); sources.push(nextSource.value); idx = nextSource.newIndex; } return { value: new UsingClause(sources), newIndex: idx }; } } //# sourceMappingURL=UsingClauseParser.js.map