net.cscott.sdr.calls.ast
Class Apply
java.lang.Object
net.cscott.sdr.calls.ast.AstNode
net.cscott.sdr.calls.ast.SeqCall
net.cscott.sdr.calls.ast.Apply
public class Apply
- extends SeqCall
Apply
represents a invocation of a call or concept, with zero or more
arguments. The callName
field of the Apply
gives the name of the call (which can be converted to a Call
object
with CallDB.lookup(String)
). Note that 'and' is a concept used to
sequentially join calls: the caller's "slip and slide" would be represented
as:
#(APPLY["and"] #(APPLY["slip"]) #(APPLY["slide"]))
The children of this node represent the arguments. Numerical or selector
arguments are represented as text in another Apply (since we don't know the
proper types); for example "twice (trade and roll)" is:
#(APPLY["_fractional"] #(APPLY["2"]) #(APPLY["roll"] #(APPLY["trade"])))
Convenience methods are provided to convert numerical or string arguments
when implementing Call.apply(Apply)
.
- Version:
- $Id: Apply.java,v 1.9 2006-10-19 21:00:09 cananian Exp $
- Author:
- C. Scott Ananian
Fields inherited from class net.cscott.sdr.calls.ast.AstNode |
type |
Method Summary |
|
accept(TransformVisitor<T> v,
T t)
|
|
accept(ValueVisitor<RESULT,CLOSURE> v,
CLOSURE cl)
|
String |
argsToString()
|
Apply |
build(String callName,
List<Apply> args)
Factory: creates new Apply only if it would differ from this. |
Comp |
expand()
|
Apply |
getArg(int n)
|
Fraction |
getNumberArg(int n)
|
String |
getStringArg(int n)
|
static Apply |
makeApply(String callName)
|
static Apply |
makeApply(String conceptName,
Apply... subCalls)
|
static Apply |
makeApply(String callName,
Fraction number)
|
static Apply |
makeApply(String callName,
Fraction number,
Apply arg2)
|
static Apply |
makeApply(String callName,
Fraction number,
String s)
|
callName
public final String callName
args
public final List<Apply> args
Apply
public Apply(String callName,
List<Apply> args)
accept
public <T> SeqCall accept(TransformVisitor<T> v,
T t)
- Specified by:
accept
in class SeqCall
accept
public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v,
CLOSURE cl)
- Specified by:
accept
in class AstNode
argsToString
public String argsToString()
- Overrides:
argsToString
in class AstNode
expand
public Comp expand()
throws BadCallException
- Throws:
BadCallException
getArg
public Apply getArg(int n)
getNumberArg
public Fraction getNumberArg(int n)
getStringArg
public String getStringArg(int n)
makeApply
public static Apply makeApply(String callName)
makeApply
public static Apply makeApply(String callName,
Fraction number)
makeApply
public static Apply makeApply(String callName,
Fraction number,
String s)
makeApply
public static Apply makeApply(String callName,
Fraction number,
Apply arg2)
makeApply
public static Apply makeApply(String conceptName,
Apply... subCalls)
build
public Apply build(String callName,
List<Apply> args)
- Factory: creates new Apply only if it would differ from this.
Copyright (c) 2006 C. Scott Ananian