import every_default from "../../../../lodash-es/every.js";
import includes_default from "../../../../lodash-es/includes.js";
import some_default from "../../../../lodash-es/some.js";
import { AbstractProduction, Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from "./model.js";
function isSequenceProd(e) {
	return e instanceof Alternative || e instanceof Option || e instanceof Repetition || e instanceof RepetitionMandatory || e instanceof RepetitionMandatoryWithSeparator || e instanceof RepetitionWithSeparator || e instanceof Terminal || e instanceof Rule;
}
function isOptionalProd(g, _ = []) {
	return g instanceof Option || g instanceof Repetition || g instanceof RepetitionWithSeparator ? !0 : g instanceof Alternation ? some_default(g.definition, (e) => isOptionalProd(e, _)) : g instanceof NonTerminal && includes_default(_, g) ? !1 : g instanceof AbstractProduction ? (g instanceof NonTerminal && _.push(g), every_default(g.definition, (e) => isOptionalProd(e, _))) : !1;
}
function isBranchingProd(e) {
	return e instanceof Alternation;
}
function getProductionDslName(e) {
	/* istanbul ignore else */
	if (e instanceof NonTerminal) return "SUBRULE";
	if (e instanceof Option) return "OPTION";
	if (e instanceof Alternation) return "OR";
	if (e instanceof RepetitionMandatory) return "AT_LEAST_ONE";
	if (e instanceof RepetitionMandatoryWithSeparator) return "AT_LEAST_ONE_SEP";
	if (e instanceof RepetitionWithSeparator) return "MANY_SEP";
	if (e instanceof Repetition) return "MANY";
	if (e instanceof Terminal) return "CONSUME";
	throw Error("non exhaustive match");
}
export { getProductionDslName, isBranchingProd, isOptionalProd, isSequenceProd };
