edu.neu.ccs.parser
Class AbstractParser.Procedure

java.lang.Object
  |
  +--edu.neu.ccs.parser.AbstractParser.Procedure
Enclosing class:
AbstractParser

public abstract static class AbstractParser.Procedure
extends Object

Class encapsulating a procedure and its corresponding String symbol for use with a parser.

Since:
1.0
See Also:
Parser

Field Summary
 int arguments
          The number of arguments expected by this procedure.
 String name
          The name representing this procedure.
 
Constructor Summary
AbstractParser.Procedure(String name, int arguments)
          Constructs a procedure with the given identifier and number of expected arguments.
 
Method Summary
protected  void checkArgs(Object[] args)
          Throws a ParseExpection if either the args are null or the length of args is not equal to arguments.
protected  void checkArgsAsNumeric(Object[] args)
          Throws a ParseExpection if either the args are null or the length of args is not equal to arguments or the elements in args are not of type XNumber.
abstract  Object procedureCall(Object[] args)
          Applies this procedure using the provided array of argument values and returns the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public String name
The name representing this procedure.


arguments

public int arguments
The number of arguments expected by this procedure.

Constructor Detail

AbstractParser.Procedure

public AbstractParser.Procedure(String name,
                                int arguments)
Constructs a procedure with the given identifier and number of expected arguments.

Parameters:
arguments - the expected number of arguments
Method Detail

procedureCall

public abstract Object procedureCall(Object[] args)
                              throws ParseException
Applies this procedure using the provided array of argument values and returns the result. Replaces the method named procedureCalled.

Parameters:
args - the array of argument values
ParseException
Since:
2.2

checkArgs

protected void checkArgs(Object[] args)
                  throws ParseException
Throws a ParseExpection if either the args are null or the length of args is not equal to arguments. The functionality of the 2.1 version of this method is now captured in checkArgsAsNumeric.

Parameters:
args - the array of argument values
ParseException
Since:
2.2
See Also:
checkArgsAsNumeric(Object[])

checkArgsAsNumeric

protected void checkArgsAsNumeric(Object[] args)
                           throws ParseException
Throws a ParseExpection if either the args are null or the length of args is not equal to arguments or the elements in args are not of type XNumber.

Parameters:
args - the array of argument values
ParseException
Since:
2.2
See Also:
checkArgs(Object[])