private static <T> Rule<T> rebuild(
		final Rule<T> rule,
		final Collection<Symbol<T>> symbols
	) {
		return new Rule<>(
			(NonTerminal<T>)select(rule.start, symbols),
			rule.alternatives.stream()
				.map(e -> rebuild(e, symbols))
				.toList()
		);
	}
Create a grammar object with the given rules.

@param rules the rules the grammar consists of
@throws IllegalArgumentException if the list of rules is empty or there
        are duplicate rules
@throws NullPointerException if the list of rules is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/grammar/Cfg.java