@abaplint/core
Version:
abaplint - Core API
20 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CDSCase = void 0;
const _1 = require(".");
const combi_1 = require("../../abap/2_statements/combi");
class CDSCase extends combi_1.Expression {
getRunnable() {
// caseParen: explicit "( case ... end )" alternative placed BEFORE CDSArithmetics.
// This avoids CDSArithmetics trying ( case ... end ) as an operand (partial match + fail),
// which causes 2^N backtracking for N levels of nested parenthesized CASE expressions.
// CDSArithmetics is still tried after for arithmetic like (-1)*Amount or (2*A)-B.
const caseParen = (0, combi_1.seq)("(", CDSCase, ")");
const value = (0, combi_1.altPrio)(_1.CDSString, CDSCase, caseParen, _1.CDSArithmetics, _1.CDSCast, _1.CDSAggregate, _1.CDSArithParen, _1.CDSFunction, _1.CDSInteger, _1.CDSPrefixedName);
const simple = (0, combi_1.seq)((0, combi_1.altPrio)(_1.CDSArithmetics, _1.CDSArithParen, _1.CDSAggregate, _1.CDSFunction, _1.CDSPrefixedName), (0, combi_1.plusPrio)((0, combi_1.seq)("WHEN", value, "THEN", value)));
const complex = (0, combi_1.plusPrio)((0, combi_1.seq)("WHEN", _1.CDSCondition, "THEN", value));
return (0, combi_1.seq)("CASE", (0, combi_1.altPrio)(complex, simple), (0, combi_1.optPrio)((0, combi_1.seq)("ELSE", value)), "END");
}
}
exports.CDSCase = CDSCase;
//# sourceMappingURL=cds_case.js.map