rawsql-ts
Version:
High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
23 lines • 1.15 kB
JavaScript
import { JoinOnClause } from "../models/Clause";
import { ValueParser } from "./ValueParser";
export 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.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 JoinOnClause(condition.value);
return { value: joinOn, newIndex: idx };
}
return null;
}
}
//# sourceMappingURL=JoinOnClauseParser.js.map