import { AstBuilder } from "../core/Production.js";
import { Evaluator } from "../Evaluator.js";
import { Rule } from "./Rule.js";
export class Or extends Rule {
    constructor(tgt, ...children) {
        super("or", tgt, ...children);
        this.setEvaluator(Evaluator.FIRST_CHILD_EVALUATOR);
    }
    createBNF(grammar) {
        for (let io = 0; io < this.children.length; io++) {
            const fio = io;
            const option = this.children[io];
            const p = Rule.addProduction(grammar, this, this.tgt, option);
            const that = this;
            p.onExtension((_parent, ...children) => {
                let c0 = children[0];
                c0.setNthEntryInParent(fio);
                c0.setName(that.getNameForChild(fio));
            });
            p.setAstBuilder(AstBuilder.DEFAULT);
        }
    }
}
//# sourceMappingURL=Or.js.map