@FunctionalInterface public interface TreeRewriter<V>
TreeNode
and is done in place.
Description from Wikipedia: In mathematics, computer science, and logic, rewriting covers a wide range of (potentially non-deterministic) methods of replacing sub-terms of a formula with other terms. In their most basic form, they consist of a set of objects, plus relations on how to transform those objects. Rewriting can be non-deterministic. One rule to rewrite a term could be applied in many different ways to that term, or more than one rule could be applicable. Rewriting systems then do not provide an algorithm for changing one term to another, but a set of possible rule applications. When combined with an appropriate algorithm, however, rewrite systems can be viewed as computer programs, and several theorem provers and declarative programming languages are based on term rewriting.
TreeNode
object.Modifier and Type | Method and Description |
---|---|
static <V> TreeRewriter<V> |
concat(TreeRewriter<V>... rewriters)
Concat the given
rewriters to one tree-rewriter. |
default int |
rewrite(TreeNode<V> tree)
Applies the rewriting to the given (mutable)
tree . |
int |
rewrite(TreeNode<V> tree,
int limit)
Applies the rewriting to the given (mutable)
tree . |
static <V> int |
rewrite(TreeNode<V> tree,
int limit,
Iterable<? extends TreeRewriter<V>> rewriters)
Rewrites the given
tree by applying the given rewriters . |
static <V> int |
rewrite(TreeNode<V> tree,
Iterable<? extends TreeRewriter<V>> rewriters)
Rewrites the given
tree by applying the given rewriters . |
int rewrite(TreeNode<V> tree, int limit)
tree
. The tree
rewrite is done in place. Via the limit
parameter, the termination
of the tree-rewrite process can be guaranteed.tree
- the tree to be rewrittenlimit
- the maximal number this rewrite rule is applied to the given
tree. This guarantees the termination of the rewrite method.tree
NullPointerException
- if the given tree
is null
IllegalArgumentException
- if the limit
is smaller than
onedefault int rewrite(TreeNode<V> tree)
tree
. The tree
rewrite is done in place. The limit of the applied rewrites is set
unlimited (Integer.MAX_VALUE
).tree
- the tree to be rewrittentrue
if the tree has been changed (rewritten) by this
method, false
if the tree hasn't been changedNullPointerException
- if the given tree
is null
rewrite(TreeNode, int)
static <V> int rewrite(TreeNode<V> tree, int limit, Iterable<? extends TreeRewriter<V>> rewriters)
tree
by applying the given rewriters
.
This method to apply the all rewriters, in the order they are given in
the sequence, until the tree stays unchanged.V
- the tree value typetree
- the tree to rewritelimit
- the maximal number this rewrite rule is applied to the given
tree. This guarantees the termination of the rewrite method.rewriters
- the rewriters applied to the treetrue
if the tree has been changed (rewritten) by this
method, false
if the tree hasn't been changedNullPointerException
- if one of the arguments is null
IllegalArgumentException
- if the limit
is smaller than
zerostatic <V> int rewrite(TreeNode<V> tree, Iterable<? extends TreeRewriter<V>> rewriters)
tree
by applying the given rewriters
.
This method to apply the all rewriters, in the order they are given in
the sequence, until the tree stays unchanged.V
- the tree value typetree
- the tree to rewriterewriters
- the rewriters applied to the treetrue
if the tree has been changed (rewritten) by this
method, false
if the tree hasn't been changedNullPointerException
- if one of the arguments is null
rewrite(TreeNode, int, Iterable)
@SafeVarargs static <V> TreeRewriter<V> concat(TreeRewriter<V>... rewriters)
rewriters
to one tree-rewriter.V
- the tree value typerewriters
- the tree-rewriter to concatenateNullPointerException
- if the given rewriters
are
null
IllegalArgumentException
- if the limit
is smaller than
zero© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)