rlgamekit.interpreter
Class Functions

java.lang.Object
  extended by rlgamekit.interpreter.Functions

public class Functions
extends java.lang.Object

A function collection for the interpreted language. Subclass this to add new functions for your project. The method names of this class (or subclass) must match the command names from the scripting language to be interpreted.


Field Summary
protected  int currentLine
          Keep track of current line in script, to report errors on a per-line basis.
protected  java.util.HashMap<java.lang.String,java.lang.String> symbols
          Symbol table.
protected  Tokenizer tokenizer
          Helper to turn a line of parameters into a list of tokens
 
Constructor Summary
Functions()
           
 
Method Summary
 void add(java.lang.String line)
          Example: Add numeric token values and set result to a variable
 void append(java.lang.String line)
          Example: Append token values to a variable
 void div(java.lang.String line)
          Example: Divide numeric token values and set result to a variable
 void echo(java.lang.String line)
          Example: Echo some values to the standard output channel
 void mul(java.lang.String line)
          Example: Multiply numeric token values and set result to a variable
protected  void reportError(java.lang.String message)
          Report an error.
 void set(java.lang.String line)
          Example: Set a variable to a value
 void sub(java.lang.String line)
          Example: Subtract numeric token values and set result to a variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenizer

protected Tokenizer tokenizer
Helper to turn a line of parameters into a list of tokens


symbols

protected java.util.HashMap<java.lang.String,java.lang.String> symbols
Symbol table. The variable's values are kept here. Key is the variable name, value the variable's current value.


currentLine

protected int currentLine
Keep track of current line in script, to report errors on a per-line basis.

Constructor Detail

Functions

public Functions()
Method Detail

set

public void set(java.lang.String line)
Example: Set a variable to a value

Parameters:
line - The line from the script with the variable name and value

append

public void append(java.lang.String line)
Example: Append token values to a variable

Parameters:
line - The line from the script

add

public void add(java.lang.String line)
Example: Add numeric token values and set result to a variable

Parameters:
line - The line from the script

sub

public void sub(java.lang.String line)
Example: Subtract numeric token values and set result to a variable

Parameters:
line - The line from the script

mul

public void mul(java.lang.String line)
Example: Multiply numeric token values and set result to a variable

Parameters:
line - The line from the script

div

public void div(java.lang.String line)
Example: Divide numeric token values and set result to a variable

Parameters:
line - The line from the script

echo

public void echo(java.lang.String line)
Example: Echo some values to the standard output channel

Parameters:
line - The line from the script

reportError

protected void reportError(java.lang.String message)
Report an error. Subclasses may need to redefine this for their needs.

Parameters:
message - The message to report.