Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::ScriptEngine Class Reference

Simple script engine able. More...

#include <ScriptEngine.h>

Inheritance diagram for sf::ScriptEngine:
Collaboration diagram for sf::ScriptEngine:

Public Types

enum  EArithError {
  aeCurrent = -1 , aeSuccess = 0 , aeStringTooLong , aeUnexpectedEnd ,
  aeUnexpectedCharacter , aeUnexpectedIdentifier , aeExpectedRightParenthesis , aeExpectedLeftParenthesis ,
  aeExpectedDelimiter , aeExpectedFunction , aeExpectedIdentifier , aeUnknownFunction ,
  aeUnknownConstant , aeUnknownVariable , aeUnknownSymbol , aeUnknownIdentifier ,
  aeUnknownObjectMember , aeAssignConstant , aeMaxIdentifierLength , aeTooManyParameters ,
  aeTooFewParameters , aeMultipleDeclaration , aeUnexpectedKeyword , aeDivisionByZero ,
  aeLabelNotFound , aeIpStack , aeExternalKeyword , aeScriptTimeout ,
  aeFunctionError , aeNotLValue , aeNotObject , aeCompilerImplementationError
}
 Errors when compiling a script. More...
 
- Public Types inherited from sf::ScriptObject
enum  EIdentifier {
  idUnknown = 0 , idConstant , idVariable , idFunction ,
  idTypedef , idKeyword
}
 Keyword identifiers. More...
 
typedef std::string::size_type pos_type
 Source position type.
 
typedef ssize_t ip_type
 Instruction pointer type.
 

Public Member Functions

 ScriptEngine ()
 Default constructor.
 
bool calculate (const std::string &script, Value &result)
 Calculates the passed script.
 
EArithError getError () const
 Gets the error value of this instance.
 
std::string getErrorReason () const
 Gets the associated error reason string.
 
bool setError (EArithError error_value, const std::string &reason=std::string())
 Sets the error value for this instance.
 
const char * getErrorText (EArithError error_value=EArithError::aeCurrent) const
 
pos_type getPos () const
 Gets the current position.
 
virtual strings getInfoNames () const
 Gets names of info structures in lines.
 
const IdInfogetInfo (const std::string &name) const override
 Functions to be overloaded in derived classes to add functions, parameters, constants and keywords.
 
virtual strings getIdentifiers (EIdentifier id) const
 Gets a list of available identifiers.
 
- Public Member Functions inherited from sf::ScriptObject
 ScriptObject (const char *type_name, ScriptObject *parent=nullptr)
 
virtual ~ScriptObject ()=default
 Virtual destructor which can be overloaded to clean up objects.
 
virtual std::string getStatusText ()
 Gets the status text of this object for debugging purposes.
 
int getRefCount () const
 Gets the reference count.
 
 operator Value () const
 Cast operator to be able to return this instance as a Value.
 
std::string getTypeName () const
 Returns the type name Set at the constructor.
 
ScriptObjectgetParent ()
 Gets the script object owner.
 
const ScriptObjectgetParent () const
 Gets the script object owner.
 
ScriptObjectcastToObject (const Value &value)
 Casts a sf::Value::vitCustom typed sf::Value to a ScriptObject typed pointer.
 

Protected Member Functions

bool getSetValue (const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override
 Gets and sets a value using a returned Info structure.
 
bool isAlpha (char ch)
 Determines if the passed character is an alpha one.
 
- Protected Member Functions inherited from sf::ScriptObject
void makeParent (ScriptObject *so)
 Makes this object the owner of the other object.
 
void setParent (ScriptObject *parent)
 Sets the owner to the pass script object.
 

Additional Inherited Members

- Static Public Member Functions inherited from sf::ScriptObject
static const IdInfogetInfoUnknown ()
 Returns the static Info structure for unknowns.
 
static sf::TClassRegistration< ScriptObject, ScriptObject::ParametersInterface ()
 

Detailed Description

Simple script engine able.

Member Enumeration Documentation

◆ EArithError

Errors when compiling a script.

Enumerator
aeCurrent 

Used default for retrieving the current error text.

aeSuccess 

Success and no errors encountered.

aeStringTooLong 

String is too long.

aeUnexpectedEnd 

Unexpected end.

aeUnexpectedCharacter 

Unexpected character.

aeUnexpectedIdentifier 

Unexpected identifier.

aeExpectedRightParenthesis 

A right parenthesis was expected at the end.

aeExpectedLeftParenthesis 

A left parenthesis was expected at the end.

aeExpectedDelimiter 

Expected delimiter ';'.

aeExpectedFunction 

Expected function.

aeExpectedIdentifier 

Expected identifier.

aeUnknownFunction 

Unknown function.

aeUnknownConstant 

Unknown constant.

aeUnknownVariable 

Unknown variable.

aeUnknownSymbol 

Unknown symbol.

aeUnknownIdentifier 

Unknown identifier.

aeUnknownObjectMember 

Unknown object member.

aeAssignConstant 

Cannot assign a value to a constant.

aeMaxIdentifierLength 

Identifier length exceeded.

aeTooManyParameters 

Too many parameters in function.

aeTooFewParameters 

Too few parameters in function.

aeMultipleDeclaration 

Multiple declaration.

aeUnexpectedKeyword 

Unexpected keyword.

aeDivisionByZero 

Division by zero.

aeLabelNotFound 

Label not found.

aeIpStack 

IP stack error.

aeExternalKeyword 

Malformed Additional statement.

aeScriptTimeout 

Script took to long to execute.

aeFunctionError 

Function error.

aeNotLValue 

Not a left value.

aeNotObject 

Identifier references NOT an object.

aeCompilerImplementationError 

Compiler implementation fault.

Constructor & Destructor Documentation

◆ ScriptEngine()

sf::ScriptEngine::ScriptEngine ( )

Default constructor.

Member Function Documentation

◆ calculate()

bool sf::ScriptEngine::calculate ( const std::string &  script,
Value result 
)

Calculates the passed script.

◆ getError()

EArithError sf::ScriptEngine::getError ( ) const
inline

Gets the error value of this instance.

◆ getErrorReason()

std::string sf::ScriptEngine::getErrorReason ( ) const

Gets the associated error reason string.

◆ getErrorText()

const char * sf::ScriptEngine::getErrorText ( EArithError  error_value = EArithError::aeCurrent) const

Returns the arithmetic error.

Parameters
error_value
Returns
Error text.

◆ getIdentifiers()

virtual strings sf::ScriptEngine::getIdentifiers ( EIdentifier  id) const
virtual

Gets a list of available identifiers.

Used for syntax high lighting for example or code completion.

Reimplemented in sf::ScriptInterpreter.

◆ getInfo()

const IdInfo * sf::ScriptEngine::getInfo ( const std::string &  name) const
overridevirtual

Functions to be overloaded in derived classes to add functions, parameters, constants and keywords.

Gets identifier information Can be virtual overloaded in derived class to add function names

Implements sf::ScriptObject.

Reimplemented in sf::ScriptInterpreter.

◆ getInfoNames()

virtual strings sf::ScriptEngine::getInfoNames ( ) const
virtual

Gets names of info structures in lines.

Reimplemented in sf::GiiScriptInterpreter, and sf::ScriptInterpreter.

◆ getPos()

pos_type sf::ScriptEngine::getPos ( ) const
inline

Gets the current position.

◆ getSetValue()

bool sf::ScriptEngine::getSetValue ( const IdInfo info,
Value value,
Value::vector_type params,
bool  flag_set 
)
overrideprotectedvirtual

Gets and sets a value using a returned Info structure.

Returns
True if request was answered.

Implements sf::ScriptObject.

Reimplemented in sf::ScriptInterpreter.

◆ isAlpha()

bool sf::ScriptEngine::isAlpha ( char  ch)
protected

Determines if the passed character is an alpha one.

◆ setError()

bool sf::ScriptEngine::setError ( EArithError  error_value,
const std::string &  reason = std::string() 
)

Sets the error value for this instance.


The documentation for this class was generated from the following file: