sdr 0.7

net.cscott.sdr.calls.ast
Class Expr

java.lang.Object
  extended by net.cscott.sdr.calls.ast.AstNode
      extended by net.cscott.sdr.calls.ast.Expr

public class Expr
extends AstNode

Expr represents an expression to be computed at evaluation time. The value of an Expr may depend on the DanceState at the time it is evaluated.


Field Summary
 List<Expr> args
           
 String atom
           
 
Fields inherited from class net.cscott.sdr.calls.ast.AstNode
type
 
Constructor Summary
Expr(String atom, Expr... args)
           
Expr(String atom, List<Expr> args)
           
 
Method Summary
<T> Expr
accept(TransformVisitor<T> v, T t)
          Visitor pattern implementation for transformations.
<RESULT,CLOSURE>
RESULT
accept(ValueVisitor<RESULT,CLOSURE> v, CLOSURE cl)
          Visitor pattern implementation for computations.
 String argsToString()
           
 Expr build(String atom, List<Expr> args)
          Factory: creates new Expr only if it would differ from this.
<T> T
evaluate(Class<T> type, DanceState ds)
          Evaluate the Expr in the given DanceState to yield a result of the requested type.
 boolean isConstant(Class<?> type)
          Returns true iff the value of this Expr is independent of the DanceState.
static Expr literal(Fraction f)
           
static Expr literal(String s)
           
 String toShortString()
          Emit an apply in the form it appears in the call definition lists.
 String toString()
          Output AST tree in lisp-like notation.
 
Methods inherited from class net.cscott.sdr.calls.ast.AstNode
valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

atom

public final String atom

args

public final List<Expr> args
Constructor Detail

Expr

public Expr(String atom,
            List<Expr> args)

Expr

public Expr(String atom,
            Expr... args)
Method Detail

literal

public static Expr literal(String s)

literal

public static Expr literal(Fraction f)

evaluate

public final <T> T evaluate(Class<T> type,
                            DanceState ds)
                 throws ExprFunc.EvaluationException
Evaluate the Expr in the given DanceState to yield a result of the requested type.

Throws:
ExprFunc.EvaluationException

isConstant

public final boolean isConstant(Class<?> type)
Returns true iff the value of this Expr is independent of the DanceState.


accept

public <T> Expr accept(TransformVisitor<T> v,
                       T t)
Description copied from class: AstNode
Visitor pattern implementation for transformations. Each AstNode 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.

Specified by:
accept in class AstNode

accept

public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v,
                                      CLOSURE cl)
Description copied from class: AstNode
Visitor pattern implementation for computations. Each AstNode accepts a ValueVisitor and a closure, and returns an object of the appropriate result type.

Specified by:
accept in class AstNode

argsToString

public String argsToString()
Overrides:
argsToString in class AstNode

toString

public String toString()
Description copied from class: AstNode
Output AST tree in lisp-like notation.

Overrides:
toString in class AstNode

toShortString

public String toShortString()
Emit an apply in the form it appears in the call definition lists. (Something like Lisp M-expressions.)


build

public Expr build(String atom,
                  List<Expr> args)
Factory: creates new Expr only if it would differ from this.


sdr 0.7

Copyright © 2006-2009 C. Scott Ananian