@abaplint/core
Version:
abaplint - Core API
26 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CDSCondition = void 0;
const _1 = require(".");
const combi_1 = require("../../abap/2_statements/combi");
const cds_integer_1 = require("./cds_integer");
class CDSCondition extends combi_1.Expression {
getRunnable() {
const left = (0, combi_1.altPrio)(_1.CDSString, _1.CDSCast, _1.CDSFunction, _1.CDSAggregate, _1.CDSPrefixedName);
const nonLikeOperators = (0, combi_1.altPrio)("=", (0, combi_1.seq)("!", "="), (0, combi_1.seq)("<", ">"), (0, combi_1.seq)(">", "="), (0, combi_1.seq)("<", "="), "<", ">");
const likeOperators = (0, combi_1.altPrio)("LIKE", "NOT LIKE");
// Right side of comparison: simple values first, then parenthesized, then full arithmetic last.
// CDSArithmetics is last to avoid triggering CDSPrefixedName→CDSCondition→CDSArithmetics cycle.
const right = (0, combi_1.altPrio)(_1.CDSArithParen, left, cds_integer_1.CDSInteger, _1.CDSArithmetics);
// ESCAPE is only valid with LIKE/NOT LIKE, not with other comparison operators.
const compare = (0, combi_1.altPrio)((0, combi_1.seq)(likeOperators, right, (0, combi_1.opt)((0, combi_1.seq)("ESCAPE", _1.CDSString))), (0, combi_1.seq)(nonLikeOperators, right));
const is = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("INITIAL", "NULL"));
const between = (0, combi_1.seq)("BETWEEN", left, "AND", left);
const condition = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), left, (0, combi_1.altPrio)(compare, is, between));
const paren = (0, combi_1.seq)("(", CDSCondition, ")");
const notParen = (0, combi_1.seq)("NOT", paren);
return (0, combi_1.seq)((0, combi_1.altPrio)(condition, notParen, paren), (0, combi_1.starPrio)((0, combi_1.seq)((0, combi_1.altPrio)("AND", "OR"), (0, combi_1.altPrio)(condition, notParen, paren))));
}
}
exports.CDSCondition = CDSCondition;
//# sourceMappingURL=cds_condition.js.map