- All Known Implementing Classes:
ConstRewriter
,TreeRewriteRule
,TRS
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
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.
- Since:
- 5.0
- Version:
- 5.0
- API Note:
- The rewriting is done in place, to a mutable
TreeNode
object.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> TreeRewriter
<V> concat
(TreeRewriter<V>... rewriters) Concat the givenrewriters
to one tree-rewriter.default int
Applies the rewriting to the given (mutable)tree
.int
Applies the rewriting to the given (mutable)tree
.static <V> int
rewrite
(TreeNode<V> tree, int limit, Iterable<? extends TreeRewriter<V>> rewriters) Rewrites the giventree
by applying the givenrewriters
.static <V> int
rewrite
(TreeNode<V> tree, Iterable<? extends TreeRewriter<V>> rewriters) Rewrites the giventree
by applying the givenrewriters
.
-
Method Details
-
rewrite
Applies the rewriting to the given (mutable)tree
. The tree rewrite is done in place. Via thelimit
parameter, the termination of the tree-rewrite process can be guaranteed.- Parameters:
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.- Returns:
- the number of rewrites applied to the input
tree
- Throws:
NullPointerException
- if the giventree
isnull
IllegalArgumentException
- if thelimit
is smaller than one
-
rewrite
Applies the rewriting to the given (mutable)tree
. The tree rewrite is done in place. The limit of the applied rewrites is set unlimited (Integer.MAX_VALUE
).- Parameters:
tree
- the tree to be rewritten- Returns:
true
if the tree has been changed (rewritten) by this method,false
if the tree hasn't been changed- Throws:
NullPointerException
- if the giventree
isnull
- See Also:
-
rewrite
Rewrites the giventree
by applying the givenrewriters
. This method to apply all rewriters, in the order they are given in the sequence, until the tree stays unchanged.- Type Parameters:
V
- the tree value type- Parameters:
tree
- 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 tree- Returns:
true
if the tree has been changed (rewritten) by this method,false
if the tree hasn't been changed- Throws:
NullPointerException
- if one of the arguments isnull
IllegalArgumentException
- if thelimit
is smaller than zero
-
rewrite
Rewrites the giventree
by applying the givenrewriters
. This method to apply all rewriters, in the order they are given in the sequence, until the tree stays unchanged.- Type Parameters:
V
- the tree value type- Parameters:
tree
- the tree to rewriterewriters
- the rewriters applied to the tree- Returns:
true
if the tree has been changed (rewritten) by this method,false
if the tree hasn't been changed- Throws:
NullPointerException
- if one of the arguments isnull
- See Also:
-
concat
Concat the givenrewriters
to one tree-rewriter.- Type Parameters:
V
- the tree value type- Parameters:
rewriters
- the tree-rewriter to concatenate- Returns:
- a new tree-rewriter which concatenates the given one
- Throws:
NullPointerException
- if the givenrewriters
arenull
IllegalArgumentException
- if thelimit
is smaller than zero
-