Yate
ExpEvaluator Class Reference

An expression parser and evaluator. More...

#include <yatescript.h>

Inheritance diagram for ExpEvaluator:
DebugEnabler

Public Types

enum  Parser { C , SQL }
 
enum  Opcode {
  OpcNone = 0 , OpcNull , OpcPush , OpcDrop ,
  OpcDup , OpcSwap , OpcRot , OpcOver ,
  OpcAdd , OpcSub , OpcMul , OpcDiv ,
  OpcMod , OpcNeg , OpcIncPre , OpcDecPre ,
  OpcIncPost , OpcDecPost , OpcAnd , OpcOr ,
  OpcXor , OpcNot , OpcShl , OpcShr ,
  OpcLAnd , OpcLOr , OpcLXor , OpcLNot ,
  OpcCat , OpcReM , OpcReIM , OpcReNm ,
  OpcReINm , OpcLike , OpcILike , OpcNLike ,
  OpcNIlike , OpcEq , OpcNe , OpcGt ,
  OpcLt , OpcGe , OpcLe , OpcCond ,
  OpcAs , OpcField , OpcFunc , OpcLabel ,
  OpcCopy , OpcNullish , OpcAssign = 0x0100 , OpcPrivate = 0x1000
}
 

Public Member Functions

 ExpEvaluator (const TokenDict *operators=0, const TokenDict *unaryOps=0)
 
 ExpEvaluator (Parser style)
 
 ExpEvaluator (const ExpEvaluator &original)
 
virtual ~ExpEvaluator ()
 
int compile (ParsePoint &expr, GenObject *context=0)
 
bool evaluate (ObjList *results, GenObject *context=0) const
 
bool evaluate (ObjList &results, GenObject *context=0) const
 
int evaluate (NamedList &results, unsigned int index=0, const char *prefix=0, GenObject *context=0) const
 
int evaluate (Array &results, unsigned int index, GenObject *context=0) const
 
bool simplify ()
 
bool inError () const
 
unsigned int lineNumber () const
 
virtual bool null () const
 
void dump (const ObjList &codes, String &res, bool lineNo=false) const
 
virtual void dump (String &res, bool lineNo=false) const
 
String dump (const ObjList &codes, bool lineNo=false) const
 
String dump (bool lineNo=false) const
 
const TokenDictoperators () const
 
const TokenDictunaryOps () const
 
ExpExtenderextender () const
 
void extender (ExpExtender *ext)
 
virtual ExpOperationpopValue (ObjList &stack, GenObject *context=0) const
 
virtual bool runOperation (ObjList &stack, const ExpOperation &oper, GenObject *context=0) const
 
virtual bool runAllFields (ObjList &stack, GenObject *context=0) const
 
- Public Member Functions inherited from DebugEnabler
 DebugEnabler (int level=TelEngine::debugLevel(), bool enabled=true)
 
int debugLevel () const
 
int debugLevel (int level)
 
bool debugEnabled () const
 
void debugEnabled (bool enable)
 
const char * debugName () const
 
bool debugAt (int level) const
 
bool debugChained () const
 
void debugChain (const DebugEnabler *chain=0)
 
void debugCopy (const DebugEnabler *original=0)
 

Static Public Member Functions

static unsigned int getLineOf (ExpOperation *op1, ExpOperation *op2=0, ExpOperation *op3=0)
 
static void pushOne (ObjList &stack, ExpOperation *oper)
 
static ExpOperationpopOne (ObjList &stack)
 
static ExpOperationpopAny (ObjList &stack)
 

Protected Member Functions

virtual char skipWhites (ParsePoint &expr)
 
Opcode getOperator (const char *&expr, const TokenDict *operators, bool caseInsensitive=false) const
 
virtual bool keywordLetter (char c) const
 
virtual bool keywordDigit (char c) const
 
virtual bool keywordChar (char c) const
 
virtual int getKeyword (const char *str) const
 
bool gotError (const char *error=0, const char *text=0, unsigned int line=0) const
 
bool gotError (const char *error=0, const char *text=0, unsigned int line=0)
 
bool gotError (const char *error, unsigned int line) const
 
bool gotError (const char *error, unsigned int line)
 
virtual void formatLineNo (String &buf, unsigned int line) const
 
bool runCompile (ParsePoint &expr, char stop, GenObject *nested=0)
 
virtual bool runCompile (ParsePoint &expr, const char *stop=0, GenObject *nested=0)
 
virtual char skipComments (ParsePoint &expr, GenObject *context=0)
 
virtual int preProcess (ParsePoint &expr, GenObject *context=0)
 
virtual Opcode getOperator (ParsePoint &expr)
 
virtual Opcode getUnaryOperator (ParsePoint &expr)
 
virtual Opcode getPostfixOperator (ParsePoint &expr, int precedence=0)
 
virtual const char * getOperator (Opcode oper) const
 
virtual int getPrecedence (Opcode oper) const
 
virtual bool getRightAssoc (Opcode oper) const
 
virtual bool getSeparator (ParsePoint &expr, bool remove)
 
virtual bool getInstruction (ParsePoint &expr, char stop=0, GenObject *nested=0)
 
virtual bool getOperand (ParsePoint &expr, bool endOk=true, int precedence=0)
 
virtual bool getSimple (ParsePoint &expr, bool constOnly=false)
 
virtual bool getNumber (ParsePoint &expr)
 
virtual bool getString (ParsePoint &expr)
 
virtual bool getFunction (ParsePoint &expr)
 
virtual bool getString (const char *&expr, String &str)
 
virtual bool getEscape (const char *&expr, String &str, char sep)
 
virtual bool getField (ParsePoint &expr)
 
void addOpcode (ExpOperation *oper, unsigned int line=0)
 
ExpOperationaddOpcode (Opcode oper, bool barrier=false, unsigned int line=0)
 
ExpOperationaddOpcode (Opcode oper, int64_t value, bool barrier=false)
 
ExpOperationaddOpcode (const String &value)
 
ExpOperationaddOpcode (int64_t value)
 
ExpOperationaddOpcode (bool value)
 
ExpOperationaddOpcode (Opcode oper, const String &name, int64_t value=0, bool barrier=false, unsigned int line=0)
 
ExpOperationpopOpcode ()
 
virtual bool trySimplify ()
 
virtual bool runEvaluate (const ObjList &opcodes, ObjList &stack, GenObject *context=0) const
 
virtual bool runEvaluate (const ObjVector &opcodes, ObjList &stack, GenObject *context=0, unsigned int index=0) const
 
virtual bool runEvaluate (ObjList &stack, GenObject *context=0) const
 
virtual bool runFunction (ObjList &stack, const ExpOperation &oper, GenObject *context=0) const
 
virtual bool runField (ObjList &stack, const ExpOperation &oper, GenObject *context=0) const
 
virtual bool runAssign (ObjList &stack, const ExpOperation &oper, GenObject *context=0) const
 
virtual void dump (const ExpOperation &oper, String &res, bool lineNo=false) const
 
- Protected Member Functions inherited from DebugEnabler
void debugName (const char *name)
 

Static Protected Member Functions

static char condLower (char chr, bool makeLower)
 

Protected Attributes

const TokenDictm_operators
 
const TokenDictm_unaryOps
 
ObjList m_opcodes
 
ObjListm_lastOpcode
 
bool m_inError
 
unsigned int m_lineNo
 

Friends

class ParsePoint
 

Detailed Description

An expression parser and evaluator.

A class used to build stack based (posifix) expression parsers and evaluators

Member Enumeration Documentation

◆ Opcode

enum Opcode

Operation codes

◆ Parser

enum Parser

Parsing styles

Constructor & Destructor Documentation

◆ ExpEvaluator() [1/3]

ExpEvaluator ( const TokenDict * operators = 0,
const TokenDict * unaryOps = 0 )
explicit

Constructs an evaluator from an operator dictionary

Parameters
operatorsPointer to operator dictionary, longest strings first
unaryOpsPointer to unary operators dictionary, longest strings first

References operators(), and unaryOps().

Referenced by ExpEvaluator().

◆ ExpEvaluator() [2/3]

ExpEvaluator ( Parser style)
explicit

Constructs an evaluator from a parser style

Parameters
styleStyle of parsing to use

◆ ExpEvaluator() [3/3]

ExpEvaluator ( const ExpEvaluator & original)

Copy constructor

Parameters
originalEvaluator to copy the operation list from

References ExpEvaluator().

◆ ~ExpEvaluator()

virtual ~ExpEvaluator ( )
virtual

Destructor

Member Function Documentation

◆ addOpcode() [1/7]

ExpOperation * addOpcode ( bool value)
protected

Add a boolean constant to the expression

Parameters
valueBoolean value to add, will be pushed on execution
Returns
Newly added operation

◆ addOpcode() [2/7]

ExpOperation * addOpcode ( const String & value)
protected

Add a string constant to the expression

Parameters
valueString value to add, will be pushed on execution
Returns
Newly added operation

◆ addOpcode() [3/7]

void addOpcode ( ExpOperation * oper,
unsigned int line = 0 )
protected

Add an aready built operation to the expression and set its line number

Parameters
operOperation to add
lineLine number where operation was compiled, zero to used parsing point

◆ addOpcode() [4/7]

ExpOperation * addOpcode ( int64_t value)
protected

Add an integer constant to the expression

Parameters
valueInteger value to add, will be pushed on execution
Returns
Newly added operation

◆ addOpcode() [5/7]

ExpOperation * addOpcode ( Opcode oper,
bool barrier = false,
unsigned int line = 0 )
protected

Add a simple operator to the expression

Parameters
operOperator code to add
barrierTrue to create an evaluator stack barrier
lineLine number where operation was compiled, zero to used parsing point
Returns
Newly added operation

◆ addOpcode() [6/7]

ExpOperation * addOpcode ( Opcode oper,
const String & name,
int64_t value = 0,
bool barrier = false,
unsigned int line = 0 )
protected

Add a function or field to the expression

Parameters
operOperator code to add, must be OpcField or OpcFunc
nameName of the field or function, case sensitive
valueNumerical value used as parameter count to functions
barrierTrue to create an exavuator stack barrier
lineLine number where operation was compiled, zero to used parsing point
Returns
Newly added operation

◆ addOpcode() [7/7]

ExpOperation * addOpcode ( Opcode oper,
int64_t value,
bool barrier = false )
protected

Add a simple operator to the expression

Parameters
operOperator code to add
value64 bit nteger value to add
barrierTrue to create an evaluator stack barrier
Returns
Newly added operation

◆ compile()

int compile ( ParsePoint & expr,
GenObject * context = 0 )

Parse and compile an expression

Parameters
exprParsing context to compile
contextPointer to arbitrary object to be passed to called methods
Returns
Number of expressions compiled, zero on error

◆ condLower()

static char condLower ( char chr,
bool makeLower )
inlinestaticprotected

Helper method to conditionally convert to lower case

Parameters
chrCharacter to convert
makeLowerTrue to convert chr to lower case
Returns
Converted character or original if conversion not requested

◆ dump() [1/5]

String dump ( bool lineNo = false) const
inline

Dump the postfix expression according to current operators dictionary

Parameters
lineNoTrue to include line numbers
Returns
String representation of operations

References dump().

◆ dump() [2/5]

virtual void dump ( const ExpOperation & oper,
String & res,
bool lineNo = false ) const
protectedvirtual

Dump a single operation according to current operators dictionary

Parameters
operOperation to dump
resResult string representation of operations
lineNoTrue to include line numbers

◆ dump() [3/5]

String dump ( const ObjList & codes,
bool lineNo = false ) const
inline

Dump a list of operations according to current operators dictionary

Parameters
codesList of operation codes
lineNoTrue to include line numbers
Returns
String representation of operations

References dump().

◆ dump() [4/5]

void dump ( const ObjList & codes,
String & res,
bool lineNo = false ) const

Dump a list of operations according to current operators dictionary

Parameters
codesList of operation codes
resResult string representation of operations
lineNoTrue to include line numbers

Referenced by dump(), and dump().

◆ dump() [5/5]

virtual void dump ( String & res,
bool lineNo = false ) const
virtual

Dump the postfix expression according to current operators dictionary

Parameters
resResult string representation of operations
lineNoTrue to include line numbers

◆ evaluate() [1/4]

int evaluate ( Array & results,
unsigned int index,
GenObject * context = 0 ) const

Evaluate the expression, return computed results

Parameters
resultsArray of result rows to populate
indexIndex of result row, zero to just set column headers
contextPointer to arbitrary object to be passed to called methods
Returns
Number of result columns, -1 on failure

◆ evaluate() [2/4]

int evaluate ( NamedList & results,
unsigned int index = 0,
const char * prefix = 0,
GenObject * context = 0 ) const

Evaluate the expression, return computed results

Parameters
resultsList of parameters to populate with results row
indexIndex of result row, zero to not include an index
prefixPrefix to prepend to parameter names
contextPointer to arbitrary object to be passed to called methods
Returns
Number of result columns, -1 on failure

◆ evaluate() [3/4]

bool evaluate ( ObjList & results,
GenObject * context = 0 ) const
inline

Evaluate the expression, return computed results

Parameters
resultsList to fill with results row
contextPointer to arbitrary object to be passed to called methods
Returns
True if expression evaluation succeeded, false on failure

References evaluate().

◆ evaluate() [4/4]

bool evaluate ( ObjList * results,
GenObject * context = 0 ) const

Evaluate the expression, optionally return results

Parameters
resultsList to fill with results row
contextPointer to arbitrary object to be passed to called methods
Returns
True if expression evaluation succeeded, false on failure

Referenced by evaluate().

◆ extender() [1/2]

ExpExtender * extender ( ) const
inline

Retrieve the internally used expression extender

Returns
Pointer to the extender in use, NULL if none

◆ extender() [2/2]

void extender ( ExpExtender * ext)

Set the expression extender to use in evaluation

Parameters
extPointer to the extender to use, NULL to remove current

◆ formatLineNo()

virtual void formatLineNo ( String & buf,
unsigned int line ) const
protectedvirtual

Formats a line number to display in error messages

Parameters
bufString buffer used to return the value
lineLine number to format

◆ getEscape()

virtual bool getEscape ( const char *& expr,
String & str,
char sep )
protectedvirtual

Helper method - get an escaped component of a string

Parameters
exprPointer past escape character, gets advanced on success
strString in which the result is returned
sepString separator character
Returns
True if succeeded

◆ getField()

virtual bool getField ( ParsePoint & expr)
protectedvirtual

Get a field keyword, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
True if succeeded, must add the operand internally

◆ getFunction()

virtual bool getFunction ( ParsePoint & expr)
protectedvirtual

Get a function call, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
True if succeeded, must add the operand internally

◆ getInstruction()

virtual bool getInstruction ( ParsePoint & expr,
char stop = 0,
GenObject * nested = 0 )
protectedvirtual

Get an instruction or block, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
stopOptional character expected after the instruction
nestedUser defined object passed from nested parsing
Returns
True if succeeded, must add the operands internally

◆ getKeyword()

virtual int getKeyword ( const char * str) const
protectedvirtual

Helper method to count characters making a keyword

Parameters
strPointer to text without whitespaces in front
Returns
Length of the keyword, 0 if a valid keyword doesn't follow

◆ getLineOf()

static unsigned int getLineOf ( ExpOperation * op1,
ExpOperation * op2 = 0,
ExpOperation * op3 = 0 )
static

Retrieve the line number from one to three operands

Parameters
op1First operand
op2Optional second operand
op3Optional third operand
Returns
Line number at compile time, zero if not found

◆ getNumber()

virtual bool getNumber ( ParsePoint & expr)
protectedvirtual

Get a numerical operand, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
True if succeeded, must add the operand internally

◆ getOperand()

virtual bool getOperand ( ParsePoint & expr,
bool endOk = true,
int precedence = 0 )
protectedvirtual

Get an operand, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
endOkConsider reaching the end of string a success
precedenceThe precedence of the previous operator
Returns
True if succeeded, must add the operand internally

◆ getOperator() [1/3]

Opcode getOperator ( const char *& expr,
const TokenDict * operators,
bool caseInsensitive = false ) const
protected

Helper method to return next operator in the parsed text

Parameters
exprPointer to text to parse, gets advanced if succeeds
operatorsPointer to operators table to use
caseInsensitiveMatch case-insensitive if set
Returns
Operator code, OpcNone on failure

References operators().

◆ getOperator() [2/3]

virtual const char * getOperator ( Opcode oper) const
protectedvirtual

Helper method to get the canonical name of an operator

Parameters
operOperator code
Returns
name of the operator, NULL if it doesn't have one

◆ getOperator() [3/3]

virtual Opcode getOperator ( ParsePoint & expr)
protectedvirtual

Returns next operator in the parsed text

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
Operator code, OpcNone on failure

◆ getPostfixOperator()

virtual Opcode getPostfixOperator ( ParsePoint & expr,
int precedence = 0 )
protectedvirtual

Returns next unary postfix operator in the parsed text

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
precedenceThe precedence of the previous operator
Returns
Operator code, OpcNone on failure

◆ getPrecedence()

virtual int getPrecedence ( Opcode oper) const
protectedvirtual

Get the precedence of an operator

Parameters
operOperator code
Returns
Precedence of the operator, zero (lowest) if unknown

◆ getRightAssoc()

virtual bool getRightAssoc ( Opcode oper) const
protectedvirtual

Get the associativity of an operator

Parameters
operOperator code
Returns
True if the operator is right-to-left associative, false if left-to-right

◆ getSeparator()

virtual bool getSeparator ( ParsePoint & expr,
bool remove )
protectedvirtual

Check if we are at an expression separator and optionally skip past it

Parameters
exprCurrent parsing context to check, advances on expression to be compiled if asked to remove separator
removeTrue to skip past the found separator
Returns
True if a separator was found

◆ getSimple()

virtual bool getSimple ( ParsePoint & expr,
bool constOnly = false )
protectedvirtual

Get an inline simple type, usually string or number

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
constOnlyReturn only inline constants
Returns
True if succeeded, must add the operand internally

◆ getString() [1/2]

virtual bool getString ( const char *& expr,
String & str )
protectedvirtual

Helper method - get a string, advance parsing pointer past it

Parameters
exprPointer to string separator, gets advanced on success
strString in which the result is returned
Returns
True if succeeded

◆ getString() [2/2]

virtual bool getString ( ParsePoint & expr)
protectedvirtual

Get a string operand, advance parsing pointer past it

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
True if succeeded, must add the operand internally

◆ getUnaryOperator()

virtual Opcode getUnaryOperator ( ParsePoint & expr)
protectedvirtual

Returns next unary operator in the parsed text

Parameters
exprCurrent parsing context, advances on expression to be compiled if it succeeds
Returns
Operator code, OpcNone on failure

◆ gotError() [1/4]

bool gotError ( const char * error,
unsigned int line )
inlineprotected

Helper method to set error flag and display debugging errors internally

Parameters
errorText of the error
lineNumber of line generating the error, zero for parsing errors
Returns
Always returns false

References gotError().

◆ gotError() [2/4]

bool gotError ( const char * error,
unsigned int line ) const
inlineprotected

Helper method to display debugging errors internally

Parameters
errorText of the error
lineNumber of line generating the error, zero for parsing errors
Returns
Always returns false

References gotError().

◆ gotError() [3/4]

bool gotError ( const char * error = 0,
const char * text = 0,
unsigned int line = 0 )
protected

Helper method to set error flag and display debugging errors internally

Parameters
errorText of the error
textOptional text that caused the error
lineNumber of line generating the error, zero for parsing errors
Returns
Always returns false

◆ gotError() [4/4]

bool gotError ( const char * error = 0,
const char * text = 0,
unsigned int line = 0 ) const
protected

Helper method to display debugging errors internally

Parameters
errorText of the error
textOptional text that caused the error
lineNumber of line generating the error, zero for parsing errors
Returns
Always returns false

Referenced by gotError(), and gotError().

◆ inError()

bool inError ( ) const
inline

Check if a parse or compile error was encountered

Returns
True if the evaluator encountered an error

References m_inError.

◆ keywordChar()

virtual bool keywordChar ( char c) const
protectedvirtual

Check if a character can be part of a keyword or identifier

Parameters
cCharacter to check
Returns
True if the character can be part of a keyword or identifier

◆ keywordDigit()

virtual bool keywordDigit ( char c) const
protectedvirtual

Check if a character can be can be a digit character in a keyword or identifier

Parameters
cCharacter to check
Returns
True if the character can be part of a keyword or identifier

◆ keywordLetter()

virtual bool keywordLetter ( char c) const
protectedvirtual

Check if a character can be a letter character in a keyword or identifier

Parameters
cCharacter to check
Returns
True if the character can be part of a keyword or identifier

◆ lineNumber()

unsigned int lineNumber ( ) const
inline

Retrieve the number of line currently being parsed

Returns
Number of current parsed line, 1 is the first line

References m_lineNo.

◆ null()

virtual bool null ( ) const
virtual

Check if the expression is empty (no operands or operators)

Returns
True if the expression is completely empty

◆ operators()

const TokenDict * operators ( ) const
inline

Retrieve the internally used operator dictionary

Returns
Pointer to operators dictionary in use

References m_operators.

Referenced by ExpEvaluator(), and getOperator().

◆ popAny()

static ExpOperation * popAny ( ObjList & stack)
static

Pops any operand (including barriers) off an evaluation stack

Parameters
stackEvaluation stack to remove the operand from
Returns
Operator removed from stack, NULL if stack underflow

◆ popOne()

static ExpOperation * popOne ( ObjList & stack)
static

Pops an operand off an evaluation stack, does not pop a barrier

Parameters
stackEvaluation stack to remove the operand from
Returns
Operator removed from stack, NULL if stack underflow

◆ popOpcode()

ExpOperation * popOpcode ( )
protected

Remove from the code and return the last operation

Returns
Operation removed from end of code, NULL if no operations remaining

◆ popValue()

virtual ExpOperation * popValue ( ObjList & stack,
GenObject * context = 0 ) const
virtual

Pops and evaluate the value of an operand off an evaluation stack, does not pop a barrier

Parameters
stackEvaluation stack to remove the operand from
contextPointer to arbitrary object to be passed to called methods
Returns
Value removed from stack, NULL if stack underflow or field not evaluable

◆ preProcess()

virtual int preProcess ( ParsePoint & expr,
GenObject * context = 0 )
protectedvirtual

Process top-level preprocessor directives

Parameters
exprCurrent parsing context, advances on expression to be compiled
contextPointer to arbitrary object to be passed to called methods
Returns
Number of expressions compiled, negative if no more directives

◆ pushOne()

static void pushOne ( ObjList & stack,
ExpOperation * oper )
static

Push an operand on an evaluation stack

Parameters
stackEvaluation stack to remove the operand from
operOperation to push on stack, NULL will not be pushed

◆ runAllFields()

virtual bool runAllFields ( ObjList & stack,
GenObject * context = 0 ) const
virtual

Convert all fields on the evaluation stack to their values

Parameters
stackEvaluation stack to evaluate fields from
contextPointer to arbitrary object to be passed to called methods
Returns
True if all fields on the stack were evaluated properly

◆ runAssign()

virtual bool runAssign ( ObjList & stack,
const ExpOperation & oper,
GenObject * context = 0 ) const
protectedvirtual

Try to assign a value to a single field

Parameters
stackEvaluation stack in use
operField to assign to, contains the field name and new value
contextPointer to arbitrary object to be passed to called methods
Returns
True if assignment succeeded

◆ runCompile() [1/2]

bool runCompile ( ParsePoint & expr,
char stop,
GenObject * nested = 0 )
protected

Runs the parser and compiler for one (sub)expression

Parameters
exprCurrent parsing context, advances on expression to be compiled
stopOptional character expected after the expression
nestedUser defined object to pass for nested parsing
Returns
True if one expression was compiled and a separator follows

◆ runCompile() [2/2]

virtual bool runCompile ( ParsePoint & expr,
const char * stop = 0,
GenObject * nested = 0 )
protectedvirtual

Runs the parser and compiler for one (sub)expression

Parameters
exprCurrent parsing context, advances on expression to be compiled
stopOptional list of possible characters expected after the expression
nestedUser defined object to pass for nested parsing
Returns
True if one expression was compiled and a separator follows

◆ runEvaluate() [1/3]

virtual bool runEvaluate ( const ObjList & opcodes,
ObjList & stack,
GenObject * context = 0 ) const
protectedvirtual

Try to evaluate a list of operation codes

Parameters
opcodesList of operation codes to evaluate
stackEvaluation stack in use, results are left on stack
contextPointer to arbitrary object to be passed to called methods
Returns
True if evaluation succeeded

◆ runEvaluate() [2/3]

virtual bool runEvaluate ( const ObjVector & opcodes,
ObjList & stack,
GenObject * context = 0,
unsigned int index = 0 ) const
protectedvirtual

Try to evaluate a vector of operation codes

Parameters
opcodesObjVector of operation codes to evaluate
stackEvaluation stack in use, results are left on stack
contextPointer to arbitrary object to be passed to called methods
indexIndex in operation codes to start evaluation from
Returns
True if evaluation succeeded

◆ runEvaluate() [3/3]

virtual bool runEvaluate ( ObjList & stack,
GenObject * context = 0 ) const
protectedvirtual

Try to evaluate the expression

Parameters
stackEvaluation stack in use, results are left on stack
contextPointer to arbitrary object to be passed to called methods
Returns
True if evaluation succeeded

◆ runField()

virtual bool runField ( ObjList & stack,
const ExpOperation & oper,
GenObject * context = 0 ) const
protectedvirtual

Try to evaluate a single field

Parameters
stackEvaluation stack in use, field value must be pushed on it
operField to evaluate
contextPointer to arbitrary object to be passed to called methods
Returns
True if evaluation succeeded

◆ runFunction()

virtual bool runFunction ( ObjList & stack,
const ExpOperation & oper,
GenObject * context = 0 ) const
protectedvirtual

Try to evaluate a single function

Parameters
stackEvaluation stack in use, parameters are popped off this stack and results are pushed back on stack
operFunction to evaluate
contextPointer to arbitrary object to be passed to called methods
Returns
True if evaluation succeeded

◆ runOperation()

virtual bool runOperation ( ObjList & stack,
const ExpOperation & oper,
GenObject * context = 0 ) const
virtual

Try to evaluate a single operation

Parameters
stackEvaluation stack in use, operands are popped off this stack and results are pushed back on stack
operOperation to execute
contextPointer to arbitrary object to be passed to called methods
Returns
True if evaluation succeeded

◆ simplify()

bool simplify ( )
inline

Simplify the expression, performs constant folding

Returns
True if the expression was simplified

References trySimplify().

◆ skipComments()

virtual char skipComments ( ParsePoint & expr,
GenObject * context = 0 )
protectedvirtual

Skip over comments and whitespaces

Parameters
exprCurrent parsing context, advances on expression to be compiled
contextPointer to arbitrary object to be passed to called methods
Returns
First character after comments or whitespaces where expr points

◆ skipWhites()

virtual char skipWhites ( ParsePoint & expr)
protectedvirtual

Method to skip over whitespaces, count parsed lines too

Parameters
exprCurrent parsing context, advances on expression to be compiled
Returns
First character after whitespaces where expr points

◆ trySimplify()

virtual bool trySimplify ( )
protectedvirtual

Try to apply simplification to the expression

Returns
True if the expression was simplified

Referenced by simplify().

◆ unaryOps()

const TokenDict * unaryOps ( ) const
inline

Retrieve the internally used unary operators dictionary

Returns
Pointer to unary operators dictionary in use

References m_unaryOps.

Referenced by ExpEvaluator().

Member Data Documentation

◆ m_inError

bool m_inError
protected

Flag that we encountered a parse or compile error

Referenced by inError().

◆ m_lastOpcode

ObjList* m_lastOpcode
protected

Internally used for faster appending to the operator codes list

◆ m_lineNo

unsigned int m_lineNo
protected

Current line index

Referenced by lineNumber().

◆ m_opcodes

ObjList m_opcodes
protected

Internally used list of operands and operator codes

◆ m_operators

const TokenDict* m_operators
protected

Internally used operator dictionary

Referenced by operators().

◆ m_unaryOps

const TokenDict* m_unaryOps
protected

Internally used unary operators dictionary

Referenced by unaryOps().


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