|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrlgamekit.interpreter.Interpreter
public class Interpreter
A (slow) interpreter framework for an extensible scripting language. All functions of the language and all details of the language must be implemented in the Functions class or a subclass of it. This is neither complete nor stable and only provided as a preview of a possible scripting interpreter to be part of the roguelike game kit. The goal is to have a very simple languge of lines like command arguments - the commands must match method names in the Functions class, and the arguments are interpreted by the functions themselves. A Tokenizer class is provided to split the arguments into more meaningful Tokens.
Functions,
Tokenizer,
Token| Constructor Summary | |
|---|---|
Interpreter()
Create a new interpreter. |
|
| Method Summary | |
|---|---|
void |
runCommand(int lineNumber,
java.lang.String call,
java.lang.String argument)
Run a command from a script line. |
void |
runLine(int lineNumber,
java.lang.String line)
Interpret (run) a single line from a script. |
void |
runScript(java.util.List<java.lang.String> script)
Interpret (run) a script. |
void |
runScript(java.lang.String[] script)
Interpret (run) a script. |
void |
setFunctions(Functions functions)
Set user defined functions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Interpreter()
| Method Detail |
|---|
public void setFunctions(Functions functions)
functions - public void runScript(java.lang.String[] script)
script - All lines of the scriptpublic void runScript(java.util.List<java.lang.String> script)
script - All lines of the script
public void runLine(int lineNumber,
java.lang.String line)
lineNumber - the line numberline - the script code line
public void runCommand(int lineNumber,
java.lang.String call,
java.lang.String argument)
lineNumber - the number of the line in the script.
Only used for reporting errors, can be set to
any number if executing single commands.call - the command nameargument - the arguments of the command as string
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||