class skInterpreter : public skExecutable

This class parses and executes Simkin script, and holds a list of global variables

Inheritance:

skInterpreter < skExecutable


Public Methods

skMethodDefNode* parseString(const skString& location, const skString& code)
this function parses the script in the code variable and returns a parse tree if there are no syntax errors
skMethodDefNode* parseExternalParams(const skString& location, skStringList& paramNames, const skString& code)
this function parses the script in the code variable and returns a parse tree if there are no syntax errors
void executeString(const skString& location, skExecutable * obj, const skString& code, skRValueArray& args, skRValue& return_value, skMethodDefNode ** parseTree)
this function parses and executes script which is assumed to belong to the object passed in
void executeStringExternalParams(const skString& location, skExecutable * obj, skStringList& paramNames, const skString& code, skRValueArray& args, skRValue& r, skMethodDefNode ** keepParseTree)
this function parses and executes script with externally declared parameters which is assumed to belong to the object passed in
void executeParseTree(const skString& location, skExecutable * obj, skMethodDefNode * parseTree, skRValueArray& args, skRValue& return_value)
this function executes some script that has already been parsed into a parse tree
void addGlobalVariable(const skString& name, skRValue value)
this method adds a global variable to the list held by this interpreter
void removeGlobalVariable(const skString& name)
this method removes a global variable from the list held by this interpreter
bool findGlobalVariable(const skString& name, skRValue& return_value)
this method finds the value of a global variable by name
bool setValue(const skString& s, const skString& attribute, const skRValue& v)
this method is used to set the Tracing variable in the interpreter
static skInterpreter* getInterpreter()
this method returns the global interpreter which was previously set with setInterpreter
static void setInterpreter(skInterpreter *)
this method constructs the global interpreter used by the process
skInterpreter()
Constructor - adds the interpreter as a global variable with the name "Interpreter"
~skInterpreter()
Destructor - deletes the global variable list

Inherited from skExecutable:

Public Methods

virtual int executableType() const
virtual int intValue() const
virtual bool boolValue() const
virtual char charValue() const
virtual skString strValue() const
virtual float floatValue() const
virtual bool getValue(const skString& field_name, const skString& attribute, skRValue& value)
virtual bool method(const skString& method_name, skRValueArray& arguments, skRValue& return_value)
virtual bool equals(skExecutable * other_object) const

Documentation

This class parses and executes Simkin script, and holds a list of global variables.

There is one global Interpreter object which you should set up at the start, although others can also be created.

skMethodDefNode* parseString(const skString& location, const skString& code)
this function parses the script in the code variable and returns a parse tree if there are no syntax errors. If there are syntax errors the function throws an skParseException object
Throws:
skParseException - if a syntax error is encountered
Returns:
returns a parse tree, if the syntax was valid. The caller must free this tree.
Parameters:
location - - a string describing where this code is located, this will appear in any error messages
code - - a string of Simkin code, which includes the parameter declarations

skMethodDefNode* parseExternalParams(const skString& location, skStringList& paramNames, const skString& code)
this function parses the script in the code variable and returns a parse tree if there are no syntax errors. It assumes that the script does *not* contain parameters and enclosing braces. If there are syntax errors the function throws an skParseException object
Throws:
skParseException - if a syntax error is encountered
Returns:
returns a parse tree, if the syntax was valid. The caller must free this tree.
Parameters:
location - - a string describing where this code is located, this will appear in any error messages
paramNames - - a list of parameter names (hence the name "ExternalParams"
code - - a string of Simkin code, which does *not* include the parameter declarations

void executeString(const skString& location, skExecutable * obj, const skString& code, skRValueArray& args, skRValue& return_value, skMethodDefNode ** parseTree)
this function parses and executes script which is assumed to belong to the object passed in
Throws:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the script is running
Parameters:
location - - a textual description of the location of the script (this appears in error messages)
obj - - the executable object which "owns" the script
args - - an array of arguments to the function, which are passed as parameters to the script
code - - a string of Simkin script, including parameter declarations
return_value - - an RValue which receives the result of the method call
parseTree - - if you supply this pointer, the parse tree is assigned to it, and you must delete it yourself. Without the parameter the parse tree will be deleted by the interpreter. The parse tree can be used in a cache and passed to executeParseTree later.

void executeStringExternalParams(const skString& location, skExecutable * obj, skStringList& paramNames, const skString& code, skRValueArray& args, skRValue& r, skMethodDefNode ** keepParseTree)
this function parses and executes script with externally declared parameters which is assumed to belong to the object passed in
Throws:
skParseException - if a syntax error is encountered
skRuntimeException - if an error occurs while the script is running
Parameters:
location - - a textual description of the location of the script (this appears in error messages)
obj - - the executable object which "owns" the script
paramNames - - a list of parameter names (hence the name "ExternalParams"
args - - an array of arguments to the function, which are passed as parameters to the script
code - - a string of Simkin script, which does *not* include parameter declarations
return_value - - an RValue which receives the result of the method call
parseTree - - if you supply this pointer, the parse tree is assigned to it, and you must delete it yourself. Without the parameter the parse tree will be deleted by the interpreter. The parse tree can be used in a cache and passed to executeParseTree later.

void executeParseTree(const skString& location, skExecutable * obj, skMethodDefNode * parseTree, skRValueArray& args, skRValue& return_value)
this function executes some script that has already been parsed into a parse tree.
Throws:
skRuntimeException - if an error occurs while the script is running
Parameters:
location - - a textual description of the location of the script (this appears in error messages)
obj - - the executable object which "owns" the script
parseTree - - a parse tree that has been generated by one of the parse or execute functions of the Interpreter
args - - an array of arguments to the function, which are passed as parameters to the script
return_value - - an RValue which receives the result of the method call

void addGlobalVariable(const skString& name, skRValue value)
this method adds a global variable to the list held by this interpreter. If the variable already has a value, it is replaced with the new one
Parameters:
name - - the name of the global variable
value - - the value of the global variable, which can be any RValue

void removeGlobalVariable(const skString& name)
this method removes a global variable from the list held by this interpreter
Parameters:
name - - the name of the global variable

bool findGlobalVariable(const skString& name, skRValue& return_value)
this method finds the value of a global variable by name
Returns:
true if the variable was found, otherwise false
Parameters:
name - - the name of the global variable
return_value - - an RValue which receives the value of the variable

bool setValue(const skString& s, const skString& attribute, const skRValue& v)
this method is used to set the Tracing variable in the interpreter. This will show method calls as the script is executed In Simkin call Interpreter.Tracing=true

static skInterpreter* getInterpreter()
this method returns the global interpreter which was previously set with setInterpreter

static void setInterpreter(skInterpreter *)
this method constructs the global interpreter used by the process

skInterpreter()
Constructor - adds the interpreter as a global variable with the name "Interpreter"

~skInterpreter()
Destructor - deletes the global variable list


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de