UNPKG

rawsql-ts

Version:

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

27 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JoinOnClauseParser = void 0; const Clause_1 = require("../models/Clause"); const ValueParser_1 = require("./ValueParser"); class JoinOnClauseParser { static tryParse(lexemes, index) { var _a; let idx = index; if (idx < lexemes.length && lexemes[idx].value === 'on') { const onKeywordComments = lexemes[idx].positionedComments; idx++; // Skip 'on' keyword // Parse the condition expression const condition = ValueParser_1.ValueParser.parseFromLexeme(lexemes, idx); const afterKeywordComments = (_a = onKeywordComments === null || onKeywordComments === void 0 ? void 0 : onKeywordComments.filter(comment => comment.position === 'after').flatMap(comment => comment.comments)) !== null && _a !== void 0 ? _a : []; if (afterKeywordComments.length > 0) { condition.value.addPositionedComments('before', afterKeywordComments); } idx = condition.newIndex; const joinOn = new Clause_1.JoinOnClause(condition.value); return { value: joinOn, newIndex: idx }; } return null; } } exports.JoinOnClauseParser = JoinOnClauseParser; //# sourceMappingURL=JoinOnClauseParser.js.map