sdr 0.5

net.cscott.sdr.calls
Class Call

java.lang.Object
  extended by net.cscott.sdr.calls.Call

public abstract class Call
extends Object

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, selectors, or other calls) to result in a Comp AST tree. Complex calls may also specify a custom Evaluator to use on the result of the application.

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

Constructor Summary
Call()
           
 
Method Summary
abstract  Comp apply(Apply ast)
          Evaluates this call with the arguments given in the Apply node, returning a Comp.
 boolean equals(Object o)
           
abstract  Evaluator getEvaluator(Apply ast)
          Returns the Evaluator to use on the result of an application, or null to use the Evaluator.Standard evaluator.
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 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.


getProgram

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


apply

public abstract Comp apply(Apply ast)
Evaluates this call with the arguments given in the Apply node, returning a Comp. Note that the callName field of ast should match this.getName(), and the length of the list in the args field should be at least this.getMinNumberOfArguments().


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.


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(Apply ast)
Returns the Evaluator to use on the result of an application, or null to use the Evaluator.Standard evaluator. (Call processors can determine that a call is safe to expand via application if the return value is null; otherwise, it should be considered 'opaque' and requires use of the custom Evaluator.)

Parameters:
ast - identical to the ast argument of apply(Apply)

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.5

Copyright © 2006-2009 C. Scott Ananian