sdr 0.7

net.cscott.sdr.calls
Class Call

java.lang.Object
  extended by net.cscott.sdr.calls.ExprFunc<Evaluator>
      extended by net.cscott.sdr.calls.Call
Direct Known Subclasses:
Finish.PartSelectorCall

public abstract class Call
extends ExprFunc<Evaluator>

The Call class includes 'simple calls' (like HINGE) which take no arguments, 'complex calls' (like SQUARE THRU) which take a numerical argument, and 'concepts' (like AS COUPLES) which take another call or calls as arguments. These are not distinguished here: the important thing is that any call can be *applied* to zero or more arguments (numbers, matchers, or other calls) to result in an Evaluator (and sometimes, if Evaluator.hasSimpleExpansion() is true, to a Comp AST tree).

Version:
$Id: Call.java,v 1.7 2006-10-21 00:54:31 cananian Exp $
Author:
C. Scott Ananian

Nested Class Summary
 
Nested classes/interfaces inherited from class net.cscott.sdr.calls.ExprFunc
ExprFunc.EvaluationException
 
Constructor Summary
Call()
           
 
Method Summary
 boolean equals(Object o)
           
 Evaluator evaluate(Class<? super Evaluator> type, DanceState ds, List<Expr> args)
          Implementation of ExprFunc interface: this Call can be evaluated to yield an Evaluator.
abstract  List<Expr> getDefaultArguments()
          Return argument defaults, if there are any for this call.
abstract  Evaluator getEvaluator(DanceState ds, List<Expr> args)
          Returns the Evaluator to use on the result of an application.
abstract  int getMinNumberOfArguments()
          Return the number of arguments which should, at minimum, be given to this Call.
abstract  String getName()
          The name of this call, in our internal jargon.
abstract  Program getProgram()
          The program to which this particular call or concept belongs.
abstract  Rule getRule()
          Returns the grammar rule applicable to this call, or null, if there is none (ie, this is an internal call).
 int hashCode()
           
static Call makeSimpleCall(String name, Program program, Comp def, Rule rule)
          Create a Call object for a 'simple call' which takes no arguments.
 String toString()
           
 
Methods inherited from class net.cscott.sdr.calls.ExprFunc
isConstant
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Call

public Call()
Method Detail

getName

public abstract String getName()
The name of this call, in our internal jargon. This is not guaranteed to be identical to the wording a caller would use; we do some reordering and rewording to make our internal representation regular and unambigous.

Specified by:
getName in class ExprFunc<Evaluator>

getProgram

public abstract Program getProgram()
The program to which this particular call or concept belongs.


getMinNumberOfArguments

public abstract int getMinNumberOfArguments()
Return the number of arguments which should, at minimum, be given to this Call. Usually this is the exact number of arguments required, but some combining calls (like 'and') can take an arbitrary number of arguments.


getDefaultArguments

public abstract List<Expr> getDefaultArguments()
Return argument defaults, if there are any for this call. The list may contain any number of entries (including 0). Arguments off the end of the returned list, as well as arguments whose corresponding entry in the list is null, have no default.


getRule

public abstract Rule getRule()
Returns the grammar rule applicable to this call, or null, if there is none (ie, this is an internal call).


getEvaluator

public abstract Evaluator getEvaluator(DanceState ds,
                                       List<Expr> args)
                                throws ExprFunc.EvaluationException
Returns the Evaluator to use on the result of an application. The Evaluator.hasSimpleExpansion() method of the Evaluator will return true if this call can be simply expanded; use the Evaluator.simpleExpansion() method to obtain the expansion. Otherwise the call should be considered 'opaque' and requires use of the custom Evaluator.)

Parameters:
args - identical to the args argument of ExprFunc.evaluate(Class, DanceState, List).
Throws:
ExprFunc.EvaluationException

evaluate

public final Evaluator evaluate(Class<? super Evaluator> type,
                                DanceState ds,
                                List<Expr> args)
                         throws ExprFunc.EvaluationException
Implementation of ExprFunc interface: this Call can be evaluated to yield an Evaluator.

Specified by:
evaluate in class ExprFunc<Evaluator>
Throws:
ExprFunc.EvaluationException - on type mismatch or other unexpected conditions.

toString

public final String toString()
Overrides:
toString in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

makeSimpleCall

public static Call makeSimpleCall(String name,
                                  Program program,
                                  Comp def,
                                  Rule rule)
Create a Call object for a 'simple call' which takes no arguments.


sdr 0.7

Copyright © 2006-2009 C. Scott Ananian