|
sdr 0.7 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.cscott.sdr.calls.ast.AstNode
net.cscott.sdr.calls.ast.SeqCall
net.cscott.sdr.calls.ast.Apply
public class Apply
Apply represents a invocation of a call or concept, with
zero or more arguments. The call field of the
Apply gives an expression for the call (which can be
converted to a Call object with CallDB.lookup(String) or to
an Evaluator using Expr.evaluate(Class, DanceState)). Note
that 'and' is a concept used to sequentially join calls: the caller's
"slip and slide" would be represented as:
and(slip, slide) (Apply (Expr and 'slip 'slide))The children of this node represent the arguments. Numeric or matcher arguments are represented as text beneath a "literal" expression, to distinguish them from similarly-named functions which might be evaluated to yield a Call value. For example, "twice (trade and roll)" is:
_fractional(2, _roll(trade)) (Apply _fractional '2 (Expr _roll 'trade))
js> a = new Apply(new Expr("and", Expr.literal("slip"), Expr.literal("slide"))) (Apply (Expr and 'slip 'slide)) js> a.toShortString() and(slip, slide) js> importPackage(net.cscott.sdr.util) js> a = new Apply(new Expr("_fractional", Expr.literal(Fraction.TWO), > new Expr("_roll", Expr.literal("trade")))) (Apply (Expr _fractional '2 (Expr _roll 'trade))) js> a.toShortString() _fractional(2, _roll(trade))
| Field Summary | |
|---|---|
Expr |
call
|
| Fields inherited from class net.cscott.sdr.calls.ast.AstNode |
|---|
type |
| Constructor Summary | |
|---|---|
Apply(Expr call)
|
|
| Method Summary | ||
|---|---|---|
|
accept(TransformVisitor<T> v,
T t)
Visitor pattern implementation for transformations. |
|
|
accept(ValueVisitor<RESULT,CLOSURE> v,
CLOSURE cl)
Visitor pattern implementation for computations. |
|
String |
argsToString()
|
|
Apply |
build(Expr call)
Factory: creates new Apply only if it would differ from this. |
|
Evaluator |
evaluator(DanceState ds)
|
|
boolean |
isIndeterminate()
True if the result of SeqCall.parts() can not be used for
fractionalization. |
|
static Apply |
makeApply(String callName)
|
|
Expr |
parts()
How many 'parts' are represented by this SeqCall. |
|
String |
toShortString()
Emit an apply in the form it appears in the call definition lists. |
|
| Methods inherited from class net.cscott.sdr.calls.ast.AstNode |
|---|
toString, valueOf |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final Expr call
| Constructor Detail |
|---|
public Apply(Expr call)
| Method Detail |
|---|
public Expr parts()
SeqCallSeqCall. Should
be Expr.literal(Fraction.ONE) for all but Part.
parts in class SeqCallpublic boolean isIndeterminate()
SeqCallSeqCall.parts() can not be used for
fractionalization.
isIndeterminate in class SeqCall
public <T> SeqCall accept(TransformVisitor<T> v,
T t)
AstNodeAstNode accepts a TransformVisitor and a
value, and returns an instance of its own type (ie,
Seq.accept(tv, "A") returns a Seq).
The 't' parameter is a closure.
accept in class SeqCall
public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v,
CLOSURE cl)
AstNodeAstNode accepts a ValueVisitor and a closure,
and returns an object of the appropriate result type.
accept in class AstNodepublic String argsToString()
argsToString in class AstNode
public Evaluator evaluator(DanceState ds)
throws BadCallException
BadCallExceptionpublic String toShortString()
public static Apply makeApply(String callName)
public Apply build(Expr call)
|
sdr 0.7 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||