sdr 0.21

net.cscott.sdr.calls.ast
Class Apply

java.lang.Object
  extended by net.cscott.sdr.calls.ast.AstNode
      extended by net.cscott.sdr.calls.ast.SeqCall
          extended by 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

Field Summary
 List<Apply> args
           
 String callName
           
 
Fields inherited from class net.cscott.sdr.calls.ast.AstNode
type
 
Constructor Summary
Apply(String callName, List<Apply> args)
           
 
Method Summary
<T> SeqCall
accept(TransformVisitor<T> v, T t)
           
<RESULT,CLOSURE>
RESULT
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)
           
 
Methods inherited from class net.cscott.sdr.calls.ast.AstNode
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

callName

public final String callName

args

public final List<Apply> args
Constructor Detail

Apply

public Apply(String callName,
             List<Apply> args)
Method Detail

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.


sdr 0.21

Copyright (c) 2006 C. Scott Ananian