import { Evaluator } from "../Evaluator.js";
import { Rule } from "./Rule.js";
export class Star extends Rule {
    constructor(tgt, child) {
        super("star", tgt, child);
        this.setEvaluator(Evaluator.ALL_CHILDREN_EVALUATOR);
    }
    getEntry() {
        return this.children[0];
    }
    createBNF(grammar) {
        const p1 = Rule.addProduction(grammar, this, this.tgt, this.children[0], this.tgt);
        Rule.addProduction(grammar, this, this.tgt);
        const that = this;
        p1.onExtension((parent, ...children) => {
            let nthEntry = parent.getNthEntryInParent();
            let c0 = children[0];
            let c1 = children[1];
            c0.setNthEntryInParent(nthEntry);
            c0.setName(that.getNameForChild(nthEntry));
            c1.setNthEntryInParent(nthEntry + 1);
            c1.setName(parent.getName());
        });
        p1.setAstBuilder((parent, ...children) => {
            parent.addChildren(children[0]);
            parent.addChildren(...children[1].getChildren());
        });
    }
}
//# sourceMappingURL=Star.js.map