Alternative extractor for Bind constructs.
General product duplication functionality.
An extractor pattern for terms that contain a single name child.
Generic term deconstruction.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Traversal to all children.
Traversal to all children. Construct a strategy that applies s
to all
term children of the subject term. If s
succeeds on all of the children,
then succeed, forming a new term from the constructor
of the original term and the result of s
for each child. If s
fails on any
child, fail. If there are no children, succeed. If s
succeeds on all
children producing the same terms (by eq
for references and by ==
for
other values), then the overall strategy returns the subject term.
This operation works on finite Rewritable
, Product
, Map
and Traversable
values, checked for in that order.
Children of a Rewritable
(resp. Product, collection) value are processed
in the order returned by the value's deconstruct (resp. productElement
,
foreach
) method.
s
is evaluated at most once.
Implementation of all
for Map
values.
Implementation of all
for Map
values.
Implementation of all
for Product
values.
Implementation of all
for Product
values.
Implementation of all
for Rewritable
values.
Implementation of all
for Rewritable
values.
Implementation of all
for Traversable
values.
Implementation of all
for Traversable
values.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.allbu
Construct a strategy that applies s
in a bottom-up fashion to all
subterms at each level, stopping at a frontier where s succeeds.
Construct a strategy that applies s
in a bottom-up fashion to all
subterms at each level, stopping at a frontier where s succeeds.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.alldownup2
Construct a strategy that applies s1
in a top-down, prefix fashion
stopping at a frontier where s1
succeeds.
Construct a strategy that applies s1
in a top-down, prefix fashion
stopping at a frontier where s1
succeeds. s2
is applied in a bottom-up,
postfix fashion to the result.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.alltd
Construct a strategy that applies s
in a top-down fashion, stopping
at a frontier where s succeeds.
Construct a strategy that applies s
in a top-down fashion, stopping
at a frontier where s succeeds.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.alltdfold
Construct a strategy that applies s1
in a top-down, prefix fashion
stopping at a frontier where s1
succeeds.
Construct a strategy that applies s1
in a top-down, prefix fashion
stopping at a frontier where s1
succeeds. s2
is applied in a bottom-up,
postfix fashion to the results of the recursive calls.
Alpha equivalence of two terms.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.and
and(s1, s2)
applies s1
and s2
to the subject
term and succeeds if both succeed.
and(s1, s2)
applies s1
and s2
to the subject
term and succeeds if both succeed. s2
will always
be applied, i.e., and is not a short-circuit
operator
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.attempt
Construct a strategy that applies s
, yielding the result of s
if it
succeeds, otherwise leave the original subject term unchanged.
Construct a strategy that applies s
, yielding the result of s
if it
succeeds, otherwise leave the original subject term unchanged. In
Stratego library this strategy is called try
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.bottomup
Construct a strategy that applies s
in a bottom-up, postfix fashion
to the subject term.
Construct a strategy that applies s
in a bottom-up, postfix fashion
to the subject term.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.bottomupS
Construct a strategy that applies s
in a bottom-up, postfix fashion
to the subject term but stops when the strategy produced by stop
succeeds.
Construct a strategy that applies s
in a bottom-up, postfix fashion
to the subject term but stops when the strategy produced by stop
succeeds. stop
is given the whole strategy itself as its argument.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.breadthfirst
Construct a strategy that applies s
in breadth first order.
Construct a strategy that applies s
in breadth first order. This
strategy does not apply s
to the root of the subject term.
It is called breadthfirst
to follow Stratego's library, but is not
really conducting a breadth-first traversal since all of the
descendants of the first child of a term are visited before any of
the descendants of the second child of a term.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Construct a strategy that always succeeds, changing the subject term to
the given term t
.
Construct a strategy that always succeeds, changing the subject term to
the given term t
. The term t
is evaluated at most once.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Traversal to a single child.
Traversal to a single child. Construct a strategy that applies s
to
the ith child of the subject term (counting from one). If s
succeeds on
the ith child producing t
, then succeed, forming a new term that is the
same as the original term except that the ith child is now t
. If s
fails
on the ith child or the subject term does not have an ith child, then fail.
child(i, s)
is equivalent to Stratego's i(s)
operator. If s
succeeds on
the ith child producing the same term (by eq
for references and by ==
for
other values), then the overall strategy returns the subject term.
This operation works for instances of Product
or finite Seq
values.
s
is evaluated at most once.
Implementation of child
for Product
values.
Implementation of child
for Product
values.
Implementation of child
for Seq
values.
Implementation of child
for Seq
values.
Collect query results in a traversable collection.
Collect query results in a traversable collection. Run the function
f
as a top-down left-to-right query on the subject term. Each
application of f
returns a single value. All of these values are
accumulated in the collection.
As for collect
in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for collect
in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.collect
Collect query results in a traversable collection.
Collect query results in a traversable collection. Run the function
f
as a top-down left-to-right query on the subject term. Each
application of f
returns a collection of values. All of these values
are accumulated in the collection.
As for collectall
in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for collectall
in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.collectall
Collect query results in a list.
Collect query results in a list. Run the function f
as a top-down
left-to-right query on the subject term. Accumulate the values
produced by the function in a list and return the final value of
the list.
Collect query results in a set.
Collect query results in a set. Run the function f
as a top-down
left-to-right query on the subject term. Accumulate the values
produced by the function in a set and return the final value of
the set.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Make a strategy that applies the elements of ss pairwise to the children of the subject term, returning a new term if all of the strategies succeed, otherwise failing.
Make a strategy that applies the elements of ss pairwise to the
children of the subject term, returning a new term if all of the
strategies succeed, otherwise failing. The constructor of the new
term is the same as that of the original term and the children
are the results of the strategies. If the length of ss
is not
the same as the number of children, then congruence(ss)
fails.
If the argument strategies succeed on children producing the same
terms (by eq
for references and by ==
for other values), then the
overall strategy returns the subject term.
This operation works on instances of Product
values.
Implementation of congruence
for Product
values.
Implementation of congruence
for Product
values.
Count function results.
Count function results. Run the function f
as a top-down query on
the subject term. Sum the integer values returned by f
from all
applications.
Count function results.
Count function results. Run the function f
as a top-down query on
the subject term. Sum the integer values returned by f
from all
applications.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
A strategy that always succeeds with the subject term unchanged (i.
A strategy that always succeeds with the subject term unchanged (i.e.,
this is the identity strategy) with the side-effect that the subject
term is printed to the given emitter, prefixed by the string s
. The
emitter defaults to one that writes to standard output.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.doloop
Construct a strategy that applies s
at least once and then repeats s
while r
succeeds.
Construct a strategy that applies s
at least once and then repeats s
while r
succeeds. This operator is called do-while
in the Stratego
library.
A unit for topdownS
, bottomupS
and downupS
.
A unit for topdownS
, bottomupS
and downupS
. For example, topdown(s)
is equivalent to topdownS(s, dontstop)
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.downup
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.downup
Construct a strategy that applies s1
in a top-down, prefix fashion
and s2
in a bottom-up, postfix fashion to the subject term.
Construct a strategy that applies s1
in a top-down, prefix fashion
and s2
in a bottom-up, postfix fashion to the subject term.
Construct a strategy that applies s
in a combined top-down and
bottom-up fashion (i.
Construct a strategy that applies s
in a combined top-down and
bottom-up fashion (i.e., both prefix and postfix) to the subject
term.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.downupS
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.downupS
Construct a strategy that applies s1
in a top-down, prefix fashion
and s2
in a bottom-up, postfix fashion to the subject term but stops
when the strategy produced by stop
succeeds.
Construct a strategy that applies s1
in a top-down, prefix fashion
and s2
in a bottom-up, postfix fashion to the subject term but stops
when the strategy produced by stop
succeeds. stop
is given the whole
strategy itself as its argument.
Construct a strategy that applies s
in a combined top-down and
bottom-up fashion (i.
Construct a strategy that applies s
in a combined top-down and
bottom-up fashion (i.e., both prefix and postfix) to the subject
but stops when the strategy produced by stop
succeeds. stop
is
given the whole strategy itself as its argument.
The duplicator used by the generic traversals.
The duplicator used by the generic traversals. Needs to be defined as a method so we can override it in other rewriting modules.
A strategy that tests whether the two sub-terms of a pair of terms are equal.
A strategy that tests whether the two sub-terms of a pair of terms are equal.
Construct a strategy that tests whether the two sub-terms of a pair of terms are equal.
Construct a strategy that tests whether the two sub-terms of a
pair of terms are equal. Synonym for eq
.
Apply the function at every term in t
in a top-down, left-to-right order.
Apply the function at every term in t
in a top-down, left-to-right order.
Collect the resulting T
values by accumulating them using f
with initial
left value v
. Return the final value of the accumulation.
Apply the function at every term in t
in a top-down, left-to-right order.
Apply the function at every term in t
in a top-down, left-to-right order.
Collect the resulting T
values by accumulating them using f
with initial
left value v
. Return the final value of the accumulation.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.everywhere
Same as everywheretd
.
Same as everywheretd
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.everywherebu
Construct a strategy that applies s
at all terms in a bottom-up fashion
regardless of failure.
Construct a strategy that applies s
at all terms in a bottom-up fashion
regardless of failure. Terms for which the strategy fails are left
unchanged.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.everywheretd
Construct a strategy that applies s
at all terms in a top-down fashion
regardless of failure.
Construct a strategy that applies s
at all terms in a top-down fashion
regardless of failure. Terms for which the strategy fails are left
unchanged.
A strategy that always fails.
A strategy that always fails.
Is the name a
fresh (not free) in a term?
Free variables in an term.
Make a unique name using an old name as the base.
A strategy that always succeeds.
A strategy that always succeeds.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.innermost
Construct a strategy that applies s
repeatedly to the innermost
(i.
Construct a strategy that applies s
repeatedly to the innermost
(i.e., lowest and left-most) (sub-)term to which it applies.
Stop with the subject term if s
doesn't apply anywhere.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.innermost2
An alternative version of innermost
.
An alternative version of innermost
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.ior
ior(s1, s2)
implements inclusive OR, that is, the
inclusive choice of s1
and s2
.
ior(s1, s2)
implements inclusive OR, that is, the
inclusive choice of s1
and s2
. It first tries s1
. If
that fails it applies s2
(just like s1 <+ s2
). However,
when s1
succeeds it also tries to apply s2
.
Is the function anyf
defined at the domain value t
? Allows for case
that anyf
may actually have a more specific domain and t
may not be
of the domain type.
Is the function anyf
defined at the domain value t
? Allows for case
that anyf
may actually have a more specific domain and t
may not be
of the domain type. Relies on implementation that does a cast at the
beginning of the apply
for a partial function literal.
Construct a strategy that succeeds if the current term has at least one direct subterm.
Construct a strategy that succeeds if the current term has at least one direct subterm.
Construct a strategy that succeeds if the current term has no direct subterms.
Construct a strategy that succeeds if the current term has no direct subterms.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a sub-term of y
but is not equal to y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a sub-term of y
but is not equal to y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a super-term of y
but is not equal to y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a super-term of y
but is not equal to y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a sub-term of y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a sub-term of y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a superterm of y
.
Construct a strategy that succeeds when applied to a pair (x,y)
if x
is a superterm of y
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.lastly
Applies s
followed by f
whether s
failed or not.
Applies s
followed by f
whether s
failed or not.
This operator is called finally
in the Stratego library.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.leaves
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.leaves
Construct a strategy that applies to all of the leaves of the
subject term, using isleaf
as the leaf predicate, skipping
subterms for which skip
when applied to the result succeeds.
Construct a strategy that applies to all of the leaves of the
subject term, using isleaf
as the leaf predicate, skipping
subterms for which skip
when applied to the result succeeds.
Construct a strategy that applies to all of the leaves of the
subject term, using isleaf
as the leaf predicate.
Construct a strategy that applies to all of the leaves of the
subject term, using isleaf
as the leaf predicate.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Create a logging strategy based on a strategy s
.
Create a logging strategy based on a strategy s
. The returned strategy
succeeds or fails exactly as s
does, but also prints the provided message,
the subject term, the success or failure status, and on success, the result
term, to the provided emitter (default: standard error). s
is evaluated
at most once.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Create a logging strategy based on a strategy s
.
Create a logging strategy based on a strategy s
. The returned strategy
succeeds or fails exactly as s
does, but if s
fails, also prints the
provided message and the subject term to the provided emitter (default:
standard error). s
is evaluated at most once.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.loop
Construct a strategy that while r
succeeds applies s
.
Construct a strategy that while r
succeeds applies s
. This operator
is called while
in the Stratego library.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.loopiter
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.loopiter
Construct a strategy that applies s(i)
for each integer i
from low
to
high
(inclusive).
Construct a strategy that applies s(i)
for each integer i
from low
to
high
(inclusive). This operator is called for
in the Stratego library.
Construct a strategy that repeats application of s
while r
fails, after
initialization with i
.
Construct a strategy that repeats application of s
while r
fails, after
initialization with i
. This operator is called for
in the Stratego
library.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.loopnot
Construct a strategy that while r
does not succeed applies s
.
Construct a strategy that while r
does not succeed applies s
. This
operator is called while-not
in the Stratego library.
Make an arbitrary value c
into a term child, checking that it worked
properly.
Make an arbitrary value c
into a term child, checking that it worked
properly. Object references will be returned unchanged; other values
will be boxed.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.manybu
Construct a strategy that applies s
as many times as possible, but
at least once, in bottom up order.
Construct a strategy that applies s
as many times as possible, but
at least once, in bottom up order.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.manytd
Construct a strategy that applies s
as many times as possible, but
at least once, in top down order.
Construct a strategy that applies s
as many times as possible, but
at least once, in top down order.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.map
Construct a strategy that applies s
to each element of a sequence,
returning a new sequence of the results if all of the applications
succeed, otherwise fail.
Construct a strategy that applies s
to each element of a sequence,
returning a new sequence of the results if all of the applications
succeed, otherwise fail. If all of the applications succeed
without change, return the input sequence.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Return a strategy that behaves as s
does, but memoises its arguments and
results.
Return a strategy that behaves as s
does, but memoises its arguments and
results. In other words, if memo(s)
is called on a term t
twice, the
second time will return the same result as the first, without having to
invoke s
. For best results, it is important that s
should have no side
effects. s
is evaluated at most once.
Make a strategy with the given name and body f
.
Make a strategy with the given name and body f
. By default, make a
basic strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.not
Construct a strategy that applies s
, then fails if s
succeeded or, if s
failed, succeeds with the subject term unchanged, I.
Construct a strategy that applies s
, then fails if s
succeeded or, if s
failed, succeeds with the subject term unchanged, I.e., it tests if
s
applies, but has no effect on the subject term.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.oncebu
Construct a strategy that applies s
in a bottom-up fashion to one
subterm at each level, stopping as soon as it succeeds once (at
any level).
Construct a strategy that applies s
in a bottom-up fashion to one
subterm at each level, stopping as soon as it succeeds once (at
any level).
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.oncetd
Construct a strategy that applies s
in a top-down fashion to one
subterm at each level, stopping as soon as it succeeds once (at
any level).
Construct a strategy that applies s
in a top-down fashion to one
subterm at each level, stopping as soon as it succeeds once (at
any level).
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Traversal to one child.
Traversal to one child. Construct a strategy that applies s
to the term
children of the subject term. Assume that c
is the
first child on which s succeeds. Then stop applying s
to the children and
succeed, forming a new term from the constructor of the original term and
the original children, except that c
is replaced by the result of applying
s
to c
. In the event that the strategy fails on all children, then fail.
If there are no children, fail. If s
succeeds on the one child producing
the same term (by eq
for references and by ==
for other values), then
the overall strategy returns the subject term.
This operation works on instances of finite Rewritable
, Product
, Map
and Traversable
values, checked for in that order.
Children of a Rewritable
(resp. Product
, collection) value are processed
in the order returned by the value's deconstruct
(resp. productElement
,
foreach
) method.
s
is evaluated at most once.
Implementation of one
for Map
values.
Implementation of one
for Map
values.
Implementation of one
for Product
values.
Implementation of one
for Product
values.
Implementation of one
for Rewritable
values.
Implementation of one
for Rewritable
values.
Implementation of one
for Traversable
values.
Implementation of one
for Traversable
values.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Construct a strategy from an option value o
.
Construct a strategy from an option value o
. The strategy succeeds
or fails depending on whether o
is a Some or None, respectively.
If o
is a Some
, then the subject term is changed to the term that
is wrapped by the Some
. o
is evaluated at most once.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.or
or(s1, s2)
is similar to ior(s1, s2)
, but the application
of the strategies is only tested.
or(s1, s2)
is similar to ior(s1, s2)
, but the application
of the strategies is only tested.
Construct a strategy that applies s
repeatedly in a top-down fashion
stopping each time as soon as it succeeds once (at any level).
Construct a strategy that applies s
repeatedly in a top-down fashion
stopping each time as soon as it succeeds once (at any level). The
outermost fails when s
fails to apply to any (sub-)term.
Perform a paramorphism over a value.
Perform a paramorphism over a value. This is a fold in which the
recursive step may refer to the recursive component of the value
and the results of folding over the children. When the function f
is called, the first parameter is the value and the second is a
sequence of the values that f
has returned for the children. his
will work on any value, but will only decompose values that are
supported by the Term
generic term deconstruction. This operation
is similar to that used in the Uniplate library.
Define a term query by a partial function f
.
Define a term query by a partial function f
. The query always succeeds
with no effect on the subject term but applies the given partial function
f
to the subject term. In other words, the strategy runs f
for its
side-effects. If the subject term is not a T
or the function is not
defined at the subject term, the strategy fails.
Due to the type erasure performed on Scala programs the type test
will be imprecise for some types. E.g., it is not possible to tell
the difference between List[Int]
and List[String]
.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Define a term query by a function f
.
Define a term query by a function f
. The query always succeeds with
no effect on the subject term but applies the given (possibly partial)
function f
to the subject term. In other words, the strategy runs
f
for its side-effects.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.reduce
Construct a strategy that applies s
repeatedly to subterms
until it fails on all of them.
Construct a strategy that applies s
repeatedly to subterms
until it fails on all of them.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeat
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeat
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeat
Construct a strategy that applies s
repeatedly exactly n
times.
Construct a strategy that applies s
repeatedly exactly n
times. If
s
fails at some point during the n applications, the entire strategy
fails. The result of the strategy is that of the nth application of
s
.
Construct a strategy that repeatedly applies s
until it fails and
then terminates with application of r
.
Construct a strategy that repeatedly applies s
until it fails and
then terminates with application of r
.
Construct a strategy that applies s
repeatedly until it fails.
Construct a strategy that applies s
repeatedly until it fails.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeat1
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeat1
Construct a strategy that repeatedly applies s
(at least once) and
terminates with application of c
.
Construct a strategy that repeatedly applies s
(at least once) and
terminates with application of c
.
Construct a strategy that repeatedly applies s
(at least once).
Construct a strategy that repeatedly applies s
(at least once).
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.repeatuntil
Construct a strategy that repeatedly applies s
until c
succeeds.
Construct a strategy that repeatedly applies s
until c
succeeds.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.restore
Construct a strategy that applies s
, then applies the restoring action
rest
if s
fails (and then fail).
Construct a strategy that applies s
, then applies the restoring action
rest
if s
fails (and then fail). Otherwise, let the result of s
stand.
Typically useful if s
performs side effects that should be restored or
undone when s
fails.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.restorealways
Construct a strategy that applies s
, then applies the restoring action
rest
regardless of the success or failure of s
.
Construct a strategy that applies s
, then applies the restoring action
rest
regardless of the success or failure of s
. The whole strategy
preserves the success or failure of s
. Typically useful if s
performs
side effects that should be restored always, e.g., when maintaining scope
information.
Rewrite a term.
Rewrite a term. Apply the strategy s
to a term returning the result term
if s
succeeds, otherwise return the original term.
Define a rewrite rule using a partial function f
defined on the type
T
.
Define a rewrite rule using a partial function f
defined on the type
T
. If the subject term is a T
and the function is defined at the
subject term, then the strategy succeeds with the return value of the
function applied to the subject term. Otherwise, the strategy fails.
Due to the type erasure performed on Scala programs the type test
will be imprecise for some types. E.g., it is not possible to tell
the difference between List[Int]
and List[String]
.
As for rule
but specifies the name for the constructed strategy.
As for rule
but specifies the name for the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Define a rewrite rule using a function f
that returns a term.
Define a rewrite rule using a function f
that returns a term.
The rule always succeeds with the return value of the function.
Define a rewrite rule using a function f
defined on type T
that returns
a strategy.
Define a rewrite rule using a function f
defined on type T
that returns
a strategy. If the subject term is a T
and the function is defined at the
subject term, the rule applies the function to the subject term to get a
strategy which is then applied again to the subject term. In other words,
the function is only used for effects such as pattern matching. The whole
thing also fails if f
is not defined at the term in the first place.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Traversal to as many children as possible, but at least one.
Traversal to as many children as possible, but at least one. Construct a
strategy that applies s
to the term children of the subject term.
If s
succeeds on any of the children, then succeed,
forming a new term from the constructor of the original term and the result
of s
for each succeeding child, with other children unchanged. In the event
that the strategy fails on all children, then fail. If there are no
children, fail. If s
succeeds on children producing the same terms (by eq
for references and by ==
for other values), then the overall strategy
returns the subject term.
This operation works on instances of finite Rewritable
, Product
, Map
and
Traversable
values, checked for in that order.
Children of a Rewritable
(resp. Product
, collection) value are processed
in the order returned by the value's deconstruct
(resp. productElement
,
foreach
) method.
s
is evaluated at most once.
Implementation of some
for Map
values.
Implementation of some
for Map
values.
Implementation of some
for Product
values.
Implementation of some
for Product
values.
Implementation of some
for Rewritable
values.
Implementation of some
for Rewritable
values.
Implementation of some
for Traversable
values.
Implementation of some
for Traversable
values.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.somebu
Construct a strategy that applies s
in a bottom-up fashion to some
subterms at each level, stopping as soon as it succeeds once (at
any level).
Construct a strategy that applies s
in a bottom-up fashion to some
subterms at each level, stopping as soon as it succeeds once (at
any level).
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.somedownup
Construct a strategy that applies s
in a top-down, prefix fashion
stopping at a frontier where s
succeeds on some children.
Construct a strategy that applies s
in a top-down, prefix fashion
stopping at a frontier where s
succeeds on some children. s
is then
applied in a bottom-up, postfix fashion to the result.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.sometd
Construct a strategy that applies s
in a top-down fashion to some
subterms at each level, stopping as soon as it succeeds once (at
any level).
Construct a strategy that applies s
in a top-down fashion to some
subterms at each level, stopping as soon as it succeeds once (at
any level).
Make a strategy from a partial function f
defined on the type T
.
Make a strategy from a partial function f
defined on the type T
.
If the subject term is a T
and the function is defined at the
subject term, then the function return value when applied to the
subject term determines whether the strategy succeeds or fails.
If the subject term is not a T
or the function is not defined at
the subject term, the strategy fails.
Due to the type erasure performed on Scala programs the type test
will be imprecise for some types. E.g., it is not possible to tell
the difference between List[Int]
and List[String]
.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
Make a strategy from a function f
.
Make a strategy from a function f
. The function return value
determines whether the strategy succeeds or fails.
Substitution of t1
for free occurrences of n
in a term.
Swap two names (given by tr
) throughout a term t
.
Construct a strategy that succeeds only if the subject term matches
the given term t
.
Construct a strategy that succeeds only if the subject term matches
the given term t
.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version without the name
argument but specifies the name for
the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.test
Construct a strategy that tests whether strategy s
succeeds,
restoring the original term on success.
Construct a strategy that tests whether strategy s
succeeds,
restoring the original term on success. A synonym for where
.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.topdown
Construct a strategy that applies s
in a top-down, prefix fashion
to the subject term.
Construct a strategy that applies s
in a top-down, prefix fashion
to the subject term.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.topdownS
Construct a strategy that applies s
in a top-down, prefix fashion
to the subject term but stops when the strategy produced by stop
succeeds.
Construct a strategy that applies s
in a top-down, prefix fashion
to the subject term but stops when the strategy produced by stop
succeeds. stop
is given the whole strategy itself as its argument.
Counter to use to produce unique names.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
As for the version in RewriterCore
without the name
argument but
specifies the name for the constructed strategy.
RewriterCore.where
Construct a strategy that tests whether strategy s
succeeds,
restoring the original term on success.
Construct a strategy that tests whether strategy s
succeeds,
restoring the original term on success. This is similar
to Stratego's where
, except that in this version any effects on
bindings are not visible outside s
.
An extension of strategy-based term rewriting with special support for nominal rewriting along the lines of FreshML and the FreshLib library for Haskell. See Scrap your Nameplate, James Cheney, ICFP 2005 for a description of the ideas and the FreshLib library.