private static String format(final Cfg.Symbol<?> symbol) {
		return switch (symbol) {
			case Cfg.NonTerminal<?> nt -> String.format("<%s>", nt.name());
			case Cfg.Terminal<?> t -> "'" + t.name()
					.replace("\\", "\\\\")
					.replace("'", "\\'") + "'";
		};
	}
Formats the given <em>CFG</em> as BNF grammar string.

@param grammar the CFG to format as BNF
@return the BNF formatted grammar string
@throws NullPointerException if the give {@code grammar} is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/grammar/Bnf.java