trait RewriterCore extends AnyRef
Core implementation of strategy-based rewriting. Implement and construct basic strategies and rewrite rules, plus basic library combinators.
- Source
- RewriterCore.scala
- Alphabetic
- By Inheritance
- RewriterCore
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
all(name: String, s: ⇒ Strategy): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
all(s: Strategy): Strategy
Traversal to all children.
Traversal to all children. Construct a strategy that applies
sto all term children of the subject term. Ifssucceeds on all of the children, then succeed, forming a new term from the constructor of the original term and the result ofsfor each child. Ifsfails on any child, fail. If there are no children, succeed. Ifssucceeds on all children producing the same terms (byeqfor references and by==for other values), then the overall strategy returns the subject term. This operation works on finiteRewritable,Product,MapandTraversablevalues, checked for in that order. Children of aRewritable(resp. Product, collection) value are processed in the order returned by the value's deconstruct (resp.productElement,foreach) method.sis evaluated at most once. -
def
allMap[CC[V, W] <: Map[V, W]](s: Strategy, t: CC[Any, Any])(implicit cbf: CanBuildFrom[CC[Any, Any], (Any, Any), CC[Any, Any]]): Option[CC[Any, Any]]
Implementation of
allforMapvalues. -
def
allProduct(s: Strategy, p: Product): Option[Any]
Implementation of
allforProductvalues. -
def
allRewritable(s: Strategy, r: Rewritable): Option[Any]
Implementation of
allforRewritablevalues. -
def
allTraversable[CC[U] <: Traversable[U]](s: Strategy, t: CC[Any])(implicit cbf: CanBuildFrom[CC[Any], Any, CC[Any]]): Option[CC[Any]]
Implementation of
allforTraversablevalues. -
macro
def
allbu(s: Strategy): Strategy
Construct a strategy that applies
sin a bottom-up fashion to all subterms at each level, stopping at a frontier where s succeeds. -
macro
def
alldownup2(s1: Strategy, s2: Strategy): Strategy
Construct a strategy that applies
s1in a top-down, prefix fashion stopping at a frontier wheres1succeeds.Construct a strategy that applies
s1in a top-down, prefix fashion stopping at a frontier wheres1succeeds.s2is applied in a bottom-up, postfix fashion to the result. -
macro
def
alltd(s: Strategy): Strategy
Construct a strategy that applies
sin a top-down fashion, stopping at a frontier where s succeeds. -
macro
def
alltdfold(s1: Strategy, s2: Strategy): Strategy
Construct a strategy that applies
s1in a top-down, prefix fashion stopping at a frontier wheres1succeeds.Construct a strategy that applies
s1in a top-down, prefix fashion stopping at a frontier wheres1succeeds.s2is applied in a bottom-up, postfix fashion to the results of the recursive calls. -
macro
def
and(s1: Strategy, s2: Strategy): Strategy
and(s1, s2)appliess1ands2to the subject term and succeeds if both succeed.and(s1, s2)appliess1ands2to the subject term and succeeds if both succeed.s2will always be applied, i.e., and is not a short-circuit operator -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
macro
def
attempt(s: Strategy): Strategy
Construct a strategy that applies
s, yielding the result ofsif it succeeds, otherwise leave the original subject term unchanged.Construct a strategy that applies
s, yielding the result ofsif it succeeds, otherwise leave the original subject term unchanged. In Stratego library this strategy is calledtry. -
macro
def
bottomup(s: Strategy): Strategy
Construct a strategy that applies
sin a bottom-up, postfix fashion to the subject term. -
macro
def
bottomupS(s: Strategy, stop: (⇒ Strategy) ⇒ Strategy): Strategy
Construct a strategy that applies
sin a bottom-up, postfix fashion to the subject term but stops when the strategy produced bystopsucceeds.Construct a strategy that applies
sin a bottom-up, postfix fashion to the subject term but stops when the strategy produced bystopsucceeds.stopis given the whole strategy itself as its argument. -
macro
def
breadthfirst(s: Strategy): Strategy
Construct a strategy that applies
sin breadth first order.Construct a strategy that applies
sin breadth first order. This strategy does not applysto the root of the subject term.It is called
breadthfirstto 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. -
def
build(name: String, t: ⇒ Any): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
build(t: Any): 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 termtis evaluated at most once. -
def
child(name: String, i: Int, s: ⇒ Strategy): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
child(i: Int, s: Strategy): Strategy
Traversal to a single child.
Traversal to a single child. Construct a strategy that applies
sto the ith child of the subject term (counting from one). Ifssucceeds on the ith child producingt, then succeed, forming a new term that is the same as the original term except that the ith child is nowt. Ifsfails on the ith child or the subject term does not have an ith child, then fail.child(i, s)is equivalent to Stratego'si(s)operator. Ifssucceeds on the ith child producing the same term (byeqfor references and by==for other values), then the overall strategy returns the subject term. This operation works for instances ofProductor finiteSeqvalues.sis evaluated at most once. -
def
childProduct(s: Strategy, i: Int, p: Product): Option[Any]
Implementation of
childforProductvalues. -
def
childSeq[CC[U] <: Seq[U]](s: Strategy, i: Int, t: CC[Any])(implicit cbf: CanBuildFrom[CC[Any], Any, CC[Any]]): Option[CC[Any]]
Implementation of
childforSeqvalues. -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
macro
def
collect[CC[X] <: Traversable[X], U](f: ==>[Any, U])(implicit cbf: CanBuildFrom[CC[Any], U, CC[U]]): (Any) ⇒ CC[U]
Collect query results in a traversable collection.
Collect query results in a traversable collection. Run the function
fas a top-down left-to-right query on the subject term. Each application offreturns a single value. All of these values are accumulated in the collection. -
macro
def
collectall[CC[X] <: Traversable[X], U](f: ==>[Any, CC[U]])(implicit cbf: CanBuildFrom[CC[Any], U, CC[U]]): (Any) ⇒ CC[U]
Collect query results in a traversable collection.
Collect query results in a traversable collection. Run the function
fas a top-down left-to-right query on the subject term. Each application offreturns a collection of values. All of these values are accumulated in the collection. -
def
congruence(name: String, ss: Strategy*): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
congruence(ss: Strategy*): 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
ssis not the same as the number of children, thencongruence(ss)fails. If the argument strategies succeed on children producing the same terms (byeqfor references and by==for other values), then the overall strategy returns the subject term. This operation works on instances ofProductvalues. -
def
congruenceProduct(p: Product, ss: Strategy*): Option[Any]
Implementation of
congruenceforProductvalues. -
macro
def
count(f: ==>[Any, Int]): (Any) ⇒ Int
Count function results.
Count function results. Run the function
fas a top-down query on the subject term. Sum the integer values returned byffrom all applications. -
def
debug(name: String, msg: String, emitter: Emitter): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
debug(msg: String, emitter: Emitter = new OutputEmitter): Strategy
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.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. -
macro
def
doloop(s: Strategy, r: Strategy): Strategy
Construct a strategy that applies
sat least once and then repeatsswhilersucceeds.Construct a strategy that applies
sat least once and then repeatsswhilersucceeds. This operator is calleddo-whilein the Stratego library. -
macro
def
downup(s1: Strategy, s2: Strategy): Strategy
Construct a strategy that applies
s1in a top-down, prefix fashion ands2in a bottom-up, postfix fashion to the subject term. -
macro
def
downup(s: Strategy): Strategy
Construct a strategy that applies
sin a combined top-down and bottom-up fashion (i.e., both prefix and postfix) to the subject term. -
macro
def
downupS(s1: Strategy, s2: Strategy, stop: (⇒ Strategy) ⇒ Strategy): Strategy
Construct a strategy that applies
s1in a top-down, prefix fashion ands2in a bottom-up, postfix fashion to the subject term but stops when the strategy produced bystopsucceeds.Construct a strategy that applies
s1in a top-down, prefix fashion ands2in a bottom-up, postfix fashion to the subject term but stops when the strategy produced bystopsucceeds.stopis given the whole strategy itself as its argument. -
macro
def
downupS(s: Strategy, stop: (⇒ Strategy) ⇒ Strategy): Strategy
Construct a strategy that applies
sin a combined top-down and bottom-up fashion (i.e., both prefix and postfix) to the subject but stops when the strategy produced bystopsucceeds.Construct a strategy that applies
sin a combined top-down and bottom-up fashion (i.e., both prefix and postfix) to the subject but stops when the strategy produced bystopsucceeds.stopis given the whole strategy itself as its argument. -
def
dup[T <: Product](t: T, children: Seq[AnyRef]): T
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.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
macro
def
everything[T](v: T)(f: (T, T) ⇒ T)(g: ==>[Any, T])(t: Any): T
Apply the function at every term in
tin a top-down, left-to-right order.Apply the function at every term in
tin a top-down, left-to-right order. Collect the resultingTvalues by accumulating them usingfwith initial left valuev. Return the final value of the accumulation. -
macro
def
everywhere(s: Strategy): Strategy
Same as
everywheretd. -
macro
def
everywherebu(s: Strategy): Strategy
Construct a strategy that applies
sat all terms in a bottom-up fashion regardless of failure.Construct a strategy that applies
sat all terms in a bottom-up fashion regardless of failure. Terms for which the strategy fails are left unchanged. -
macro
def
everywheretd(s: Strategy): Strategy
Construct a strategy that applies
sat all terms in a top-down fashion regardless of failure.Construct a strategy that applies
sat all terms in a top-down fashion regardless of failure. Terms for which the strategy fails are left unchanged. -
val
fail: Strategy
A strategy that always fails.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
val
id: Strategy
A strategy that always succeeds.
-
macro
def
innermost(s: Strategy): Strategy
Construct a strategy that applies
srepeatedly to the innermost (i.e., lowest and left-most) (sub-)term to which it applies.Construct a strategy that applies
srepeatedly to the innermost (i.e., lowest and left-most) (sub-)term to which it applies. Stop with the subject term ifsdoesn't apply anywhere. -
macro
def
innermost2(s: Strategy): Strategy
An alternative version of
innermost. -
macro
def
ior(s1: Strategy, s2: Strategy): Strategy
ior(s1, s2)implements inclusive OR, that is, the inclusive choice ofs1ands2.ior(s1, s2)implements inclusive OR, that is, the inclusive choice ofs1ands2. It first triess1. If that fails it appliess2(just likes1 <+ s2). However, whens1succeeds it also tries to applys2. -
def
isDefinedAtArg[T](anyf: ==>[Any, T], t: Any): Boolean
Is the function
anyfdefined at the domain valuet? Allows for case thatanyfmay actually have a more specific domain andtmay not be of the domain type.Is the function
anyfdefined at the domain valuet? Allows for case thatanyfmay actually have a more specific domain andtmay not be of the domain type. Relies on implementation that does a cast at the beginning of theapplyfor a partial function literal. -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
macro
def
lastly(s: Strategy, f: Strategy): Strategy
Applies
sfollowed byfwhethersfailed or not.Applies
sfollowed byfwhethersfailed or not. This operator is calledfinallyin the Stratego library. -
macro
def
leaves(s: Strategy, isleaf: Strategy, skip: (Strategy) ⇒ Strategy): Strategy
Construct a strategy that applies to all of the leaves of the subject term, using
isleafas the leaf predicate, skipping subterms for whichskipwhen applied to the result succeeds. -
macro
def
leaves(s: Strategy, isleaf: Strategy): Strategy
Construct a strategy that applies to all of the leaves of the subject term, using
isleafas the leaf predicate. -
def
log(name: String, s: ⇒ Strategy, msg: String, emitter: Emitter): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
log(s: Strategy, msg: String, emitter: Emitter = new ErrorEmitter): 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 assdoes, 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).sis evaluated at most once. -
def
logfail[T](name: String, s: ⇒ Strategy, msg: String, emitter: Emitter): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
logfail[T](s: Strategy, msg: String, emitter: Emitter = new ErrorEmitter): 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 assdoes, but ifsfails, also prints the provided message and the subject term to the provided emitter (default: standard error).sis evaluated at most once. -
macro
def
loop(r: Strategy, s: Strategy): Strategy
Construct a strategy that while
rsucceeds appliess.Construct a strategy that while
rsucceeds appliess. This operator is calledwhilein the Stratego library. -
macro
def
loopiter(s: (Int) ⇒ Strategy, low: Int, high: Int): Strategy
Construct a strategy that applies
s(i)for each integerifromlowtohigh(inclusive).Construct a strategy that applies
s(i)for each integerifromlowtohigh(inclusive). This operator is calledforin the Stratego library. -
macro
def
loopiter(i: Strategy, r: Strategy, s: Strategy): Strategy
Construct a strategy that repeats application of
swhilerfails, after initialization withi.Construct a strategy that repeats application of
swhilerfails, after initialization withi. This operator is calledforin the Stratego library. -
macro
def
loopnot(r: Strategy, s: Strategy): Strategy
Construct a strategy that while
rdoes not succeed appliess.Construct a strategy that while
rdoes not succeed appliess. This operator is calledwhile-notin the Stratego library. -
def
makechild(c: Any): AnyRef
Make an arbitrary value
cinto a term child, checking that it worked properly.Make an arbitrary value
cinto a term child, checking that it worked properly. Object references will be returned unchanged; other values will be boxed.- Attributes
- protected
-
macro
def
manybu(s: Strategy): Strategy
Construct a strategy that applies
sas many times as possible, but at least once, in bottom up order. -
macro
def
manytd(s: Strategy): Strategy
Construct a strategy that applies
sas many times as possible, but at least once, in top down order. -
macro
def
map(s: Strategy): Strategy
Construct a strategy that applies
sto 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
sto 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. -
def
memo(name: String, s: ⇒ Strategy): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
memo(s: Strategy): Strategy
Return a strategy that behaves as
sdoes, but memoises its arguments and results.Return a strategy that behaves as
sdoes, but memoises its arguments and results. In other words, ifmemo(s)is called on a termttwice, the second time will return the same result as the first, without having to invokes. For best results, it is important thatsshould have no side effects.sis evaluated at most once. -
def
mkStrategy(name: String, f: (Any) ⇒ Option[Any]): Strategy
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. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
macro
def
not(s: Strategy): Strategy
Construct a strategy that applies
s, then fails ifssucceeded or, ifsfailed, succeeds with the subject term unchanged, I.e., it tests ifsapplies, but has no effect on the subject term. -
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
macro
def
oncebu(s: Strategy): Strategy
Construct a strategy that applies
sin a bottom-up fashion to one subterm at each level, stopping as soon as it succeeds once (at any level). -
macro
def
oncetd(s: Strategy): Strategy
Construct a strategy that applies
sin a top-down fashion to one subterm at each level, stopping as soon as it succeeds once (at any level). -
def
one(name: String, s: ⇒ Strategy): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
one(s: Strategy): Strategy
Traversal to one child.
Traversal to one child. Construct a strategy that applies
sto the term children of the subject term. Assume thatcis the first child on which s succeeds. Then stop applyingsto the children and succeed, forming a new term from the constructor of the original term and the original children, except thatcis replaced by the result of applyingstoc. In the event that the strategy fails on all children, then fail. If there are no children, fail. Ifssucceeds on the one child producing the same term (byeqfor references and by==for other values), then the overall strategy returns the subject term. This operation works on instances of finiteRewritable,Product,MapandTraversablevalues, checked for in that order. Children of aRewritable(resp.Product, collection) value are processed in the order returned by the value'sdeconstruct(resp.productElement,foreach) method.sis evaluated at most once. -
def
oneMap[CC[V, W] <: Map[V, W]](s: Strategy, t: CC[Any, Any])(implicit cbf: CanBuildFrom[CC[Any, Any], (Any, Any), CC[Any, Any]]): Option[CC[Any, Any]]
Implementation of
oneforMapvalues. -
def
oneProduct(s: Strategy, p: Product): Option[Any]
Implementation of
oneforProductvalues. -
def
oneRewritable(s: Strategy, r: Rewritable): Option[Any]
Implementation of
oneforRewritablevalues. -
def
oneTraversable[CC[U] <: Traversable[U]](s: Strategy, t: CC[Any])(implicit cbf: CanBuildFrom[CC[Any], Any, CC[Any]]): Option[CC[Any]]
Implementation of
oneforTraversablevalues. -
def
option(name: String, o: ⇒ Option[Any]): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
option(o: Option[Any]): Strategy
Construct a strategy from an option value
o.Construct a strategy from an option value
o. The strategy succeeds or fails depending on whetherois a Some or None, respectively. Ifois aSome, then the subject term is changed to the term that is wrapped by theSome.ois evaluated at most once. -
macro
def
or(s1: Strategy, s2: Strategy): Strategy
or(s1, s2)is similar toior(s1, s2), but the application of the strategies is only tested. -
macro
def
outermost(s: Strategy): Strategy
Construct a strategy that applies
srepeatedly in a top-down fashion stopping each time as soon as it succeeds once (at any level).Construct a strategy that applies
srepeatedly in a top-down fashion stopping each time as soon as it succeeds once (at any level). The outermost fails whensfails to apply to any (sub-)term. -
def
para[T](f: (Any, Seq[T]) ⇒ T): (Any) ⇒ T
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
fis called, the first parameter is the value and the second is a sequence of the values thatfhas returned for the children. his will work on any value, but will only decompose values that are supported by theTermgeneric term deconstruction. This operation is similar to that used in the Uniplate library. -
macro
def
query[T](f: ==>[T, Unit]): Strategy
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 functionfto the subject term. In other words, the strategy runsffor its side-effects. If the subject term is not aTor 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]andList[String]. -
def
queryWithName[T](name: String, f: ==>[T, Unit]): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
def
queryf(name: String, f: (Any) ⇒ Unit): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
queryf(f: (Any) ⇒ Unit): 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) functionfto the subject term. In other words, the strategy runsffor its side-effects. -
macro
def
reduce(s: Strategy): Strategy
Construct a strategy that applies
srepeatedly to subterms until it fails on all of them. -
macro
def
repeat(s: Strategy, n: Int): Strategy
Construct a strategy that applies
srepeatedly exactlyntimes.Construct a strategy that applies
srepeatedly exactlyntimes. Ifsfails at some point during the n applications, the entire strategy fails. The result of the strategy is that of the nth application ofs. -
macro
def
repeat(s: Strategy, r: Strategy): Strategy
Construct a strategy that repeatedly applies
suntil it fails and then terminates with application ofr. -
macro
def
repeat(s: Strategy): Strategy
Construct a strategy that applies
srepeatedly until it fails. -
macro
def
repeat1(s: Strategy, r: Strategy): Strategy
Construct a strategy that repeatedly applies
s(at least once) and terminates with application ofc. -
macro
def
repeat1(s: Strategy): Strategy
Construct a strategy that repeatedly applies
s(at least once). -
macro
def
repeatuntil(s: Strategy, r: Strategy): Strategy
Construct a strategy that repeatedly applies
suntilcsucceeds. -
macro
def
restore(s: Strategy, rest: Strategy): Strategy
Construct a strategy that applies
s, then applies the restoring actionrestifsfails (and then fail).Construct a strategy that applies
s, then applies the restoring actionrestifsfails (and then fail). Otherwise, let the result ofsstand. Typically useful ifsperforms side effects that should be restored or undone whensfails. -
macro
def
restorealways(s: Strategy, rest: Strategy): Strategy
Construct a strategy that applies
s, then applies the restoring actionrestregardless of the success or failure ofs.Construct a strategy that applies
s, then applies the restoring actionrestregardless of the success or failure ofs. The whole strategy preserves the success or failure ofs. Typically useful ifsperforms side effects that should be restored always, e.g., when maintaining scope information. -
macro
def
rule[T](f: ==>[T, T]): Strategy
Define a rewrite rule using a partial function
fdefined on the typeT.Define a rewrite rule using a partial function
fdefined on the typeT. If the subject term is aTand 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]andList[String]. -
def
ruleWithName[T](name: String, f: ==>[T, T]): Strategy
As for
rulebut specifies the name for the constructed strategy. -
def
rulef(name: String, f: (Any) ⇒ Any): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
rulef(f: (Any) ⇒ Any): Strategy
Define a rewrite rule using a function
fthat returns a term.Define a rewrite rule using a function
fthat returns a term. The rule always succeeds with the return value of the function. -
macro
def
rulefs[T](f: ==>[T, Strategy]): Strategy
Define a rewrite rule using a function
fdefined on typeTthat returns a strategy.Define a rewrite rule using a function
fdefined on typeTthat returns a strategy. If the subject term is aTand 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 iffis not defined at the term in the first place. -
def
rulefsWithName[T](name: String, f: ==>[T, Strategy]): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
def
some(name: String, s: ⇒ Strategy): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
some(s: Strategy): 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
sto the term children of the subject term. Ifssucceeds on any of the children, then succeed, forming a new term from the constructor of the original term and the result ofsfor 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. Ifssucceeds on children producing the same terms (byeqfor references and by==for other values), then the overall strategy returns the subject term. This operation works on instances of finiteRewritable,Product,MapandTraversablevalues, checked for in that order. Children of aRewritable(resp.Product, collection) value are processed in the order returned by the value'sdeconstruct(resp.productElement,foreach) method.sis evaluated at most once. -
def
someMap[CC[V, W] <: Map[V, W]](s: Strategy, t: CC[Any, Any])(implicit cbf: CanBuildFrom[CC[Any, Any], (Any, Any), CC[Any, Any]]): Option[CC[Any, Any]]
Implementation of
someforMapvalues. -
def
someProduct(s: Strategy, p: Product): Option[Any]
Implementation of
someforProductvalues. -
def
someRewritable(s: Strategy, r: Rewritable): Option[Any]
Implementation of
someforRewritablevalues. -
def
someTraversable[CC[U] <: Traversable[U]](s: Strategy, t: CC[Any])(implicit cbf: CanBuildFrom[CC[Any], Any, CC[Any]]): Option[CC[Any]]
Implementation of
someforTraversablevalues. -
macro
def
somebu(s: Strategy): Strategy
Construct a strategy that applies
sin a bottom-up fashion to some subterms at each level, stopping as soon as it succeeds once (at any level). -
macro
def
somedownup(s: Strategy): Strategy
Construct a strategy that applies
sin a top-down, prefix fashion stopping at a frontier wheressucceeds on some children.Construct a strategy that applies
sin a top-down, prefix fashion stopping at a frontier wheressucceeds on some children.sis then applied in a bottom-up, postfix fashion to the result. -
macro
def
sometd(s: Strategy): Strategy
Construct a strategy that applies
sin a top-down fashion to some subterms at each level, stopping as soon as it succeeds once (at any level). -
macro
def
strategy[T](f: ==>[T, Option[T]]): Strategy
Make a strategy from a partial function
fdefined on the typeT.Make a strategy from a partial function
fdefined on the typeT. If the subject term is aTand 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 aTor 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]andList[String]. -
def
strategyWithName[T](name: String, f: ==>[T, Option[T]]): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
def
strategyf(name: String, f: (Any) ⇒ Option[Any]): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
strategyf(f: (Any) ⇒ Option[Any]): 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. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
macro
def
term[T](t: T): Strategy
Construct a strategy that succeeds only if the subject term matches the given term
t. -
def
termWithName[T](name: String, t: T): Strategy
As for the version without the
nameargument but specifies the name for the constructed strategy. -
macro
def
test(s: Strategy): Strategy
Construct a strategy that tests whether strategy
ssucceeds, restoring the original term on success.Construct a strategy that tests whether strategy
ssucceeds, restoring the original term on success. A synonym forwhere. -
def
toString(): String
- Definition Classes
- AnyRef → Any
-
macro
def
topdown(s: Strategy): Strategy
Construct a strategy that applies
sin a top-down, prefix fashion to the subject term. -
macro
def
topdownS(s: Strategy, stop: (⇒ Strategy) ⇒ Strategy): Strategy
Construct a strategy that applies
sin a top-down, prefix fashion to the subject term but stops when the strategy produced bystopsucceeds.Construct a strategy that applies
sin a top-down, prefix fashion to the subject term but stops when the strategy produced bystopsucceeds.stopis given the whole strategy itself as its argument. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
macro
def
where(s: Strategy): Strategy
Construct a strategy that tests whether strategy
ssucceeds, restoring the original term on success.Construct a strategy that tests whether strategy
ssucceeds, restoring the original term on success. This is similar to Stratego'swhere, except that in this version any effects on bindings are not visible outsides. -
object
Duplicator
General product duplication functionality.
General product duplication functionality. This object is a function that returns a product that applies the same constructor as the product
t, but with the given children instead oft's children. The function fails if a constructor cannot be found, there are the wrong number of new children, or if one of the new children is not of the appropriate type. -
object
Term
Generic term deconstruction.