public static <V> TreeRewriteRule<V> parse(
		final String rule,
		final Function<? super String, ? extends V> mapper
	) {
		final String[] parts = rule.split("->");
		if (parts.length == 1) {
			throw new IllegalArgumentException(format(
				"Invalid rewrite rule; missing separator '->': %s", rule
			));
		}
		if (parts.length > 2) {
			throw new IllegalArgumentException(format(
				"Invalid rewrite rule; found %d separators '->': %s",
				parts.length - 1, rule
			));
		}

		return new TreeRewriteRule<>(
			TreePattern.compile(parts[0], mapper),
			TreePattern.compile(parts[1], mapper)
		);
	}
Compiles the string representation of a rewrite rule:
<pre> {@code
    add($x,0) -> $x
    mul($x,1) -> $x
} </pre>

@param <V> the tree node type
@param rule the rewrite rule
@param mapper the mapper function which converts the node value into the
       actual type {@code V}
@return a new rewrite rule, compiled from the given rule string
@throws IllegalArgumentException if the rewrite rule is invalid
@throws NullPointerException if on of the arguments is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeRewriteRule.java