"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ast_1 = require("../ast");
function combineExpressions(expressions, operator = "&&") {
    let result;
    for (let i = expressions.length - 1; i >= 0; i--) {
        let e = expressions[i];
        if (result == null) {
            result = e;
        }
        else {
            //  we iterate in reverse and add new values to left
            //  so that the array will be left to right and symmetrical with toSubExpressions
            result = new ast_1.BinaryExpression({ left: e, operator, right: result });
        }
    }
    return result;
}
exports.default = combineExpressions;
