import { Alternation as e, Alternative as t, NonTerminal as n, Option as r, Repetition as i, RepetitionMandatory as a, RepetitionMandatoryWithSeparator as o, RepetitionWithSeparator as s, Terminal as c } from "../../../../../@chevrotain/gast/lib/src/model.js";
//#region ../../node_modules/chevrotain/lib/src/parse/grammar/rest.js
var l = class {
	walk(l, u = []) {
		l.definition.forEach((d, f) => {
			let p = l.definition.slice(f + 1);
			/* istanbul ignore else */
			if (d instanceof n) this.walkProdRef(d, p, u);
			else if (d instanceof c) this.walkTerminal(d, p, u);
			else if (d instanceof t) this.walkFlat(d, p, u);
			else if (d instanceof r) this.walkOption(d, p, u);
			else if (d instanceof a) this.walkAtLeastOne(d, p, u);
			else if (d instanceof o) this.walkAtLeastOneSep(d, p, u);
			else if (d instanceof s) this.walkManySep(d, p, u);
			else if (d instanceof i) this.walkMany(d, p, u);
			else if (d instanceof e) this.walkOr(d, p, u);
			else throw Error("non exhaustive match");
		});
	}
	walkTerminal(e, t, n) {}
	walkProdRef(e, t, n) {}
	walkFlat(e, t, n) {
		let r = t.concat(n);
		this.walk(e, r);
	}
	walkOption(e, t, n) {
		let r = t.concat(n);
		this.walk(e, r);
	}
	walkAtLeastOne(e, t, n) {
		let i = [new r({ definition: e.definition })].concat(t, n);
		this.walk(e, i);
	}
	walkAtLeastOneSep(e, t, n) {
		let r = u(e, t, n);
		this.walk(e, r);
	}
	walkMany(e, t, n) {
		let i = [new r({ definition: e.definition })].concat(t, n);
		this.walk(e, i);
	}
	walkManySep(e, t, n) {
		let r = u(e, t, n);
		this.walk(e, r);
	}
	walkOr(e, n, r) {
		let i = n.concat(r);
		e.definition.forEach((e) => {
			let n = new t({ definition: [e] });
			this.walk(n, i);
		});
	}
};
function u(e, t, n) {
	return [new r({ definition: [new c({ terminalType: e.separator })].concat(e.definition) })].concat(t, n);
}
//#endregion
export { l as RestWalker };
