NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
mu::ParserBase Class Referenceabstract

Mathematical expressions parser (base parser engine). More...

#include <muParserBase.h>

Inheritance diagram for mu::ParserBase:
Collaboration diagram for mu::ParserBase:

Classes

class  change_dec_sep
 A facet class used to change decimal and thousands separator. More...
 

Public Types

typedef ParserError exception_type
 Type of the error class. More...
 

Public Member Functions

void ActivateLoopMode (unsigned int _nLoopLength)
 Activates the loop mode and prepares the internal arrays for storing the necessary data. More...
 
void DeactivateLoopMode ()
 Deactivates the loop mode and resets the internal arrays. More...
 
void SetIndex (unsigned int _nLoopElement)
 Activates the selected position in the internally stored bytecode. More...
 
void SetCompiling (bool _bCompiling=true)
 Activate the compiling step for the parser. More...
 
bool IsCompiling ()
 Returns true, if the parser is currently in compiling step. More...
 
void CacheCurrentAccess (const CachedDataAccess &_access)
 Store the passed data access for this position internally. More...
 
size_t HasCachedAccess ()
 Evaluate, whether there are any cached data accesses for this position. More...
 
void DisableAccessCaching ()
 Disable the data access caching for this position. More...
 
bool CanCacheAccess ()
 Check, whether the current position can cache any data accesses. More...
 
const CachedDataAccessGetCachedAccess (size_t nthAccess)
 Returns the cached data access for the passed position. More...
 
void CacheCurrentEquation (const std::string &sEquation)
 Caches the passed equation for this position. More...
 
const std::string & GetCachedEquation () const
 Returns the stored equation for this position. More...
 
void CacheCurrentTarget (const std::string &sEquation)
 Caches the passed target equation for this position. More...
 
const std::string & GetCachedTarget () const
 Returns the stored target equation for this position. More...
 
int IsValidByteCode (unsigned int _nthLoopElement=-1, unsigned int _nthPartEquation=0)
 This member function returns, whether the current equation is already parsed and there's a valid bytecode for it. More...
 
bool ActiveLoopMode () const
 Check, whether the loop mode is active. This function returns true even if the loop mode is paused. More...
 
bool IsLockedPause () const
 Check, whether the pause mode is locked. More...
 
void LockPause (bool _bLock=true)
 This member function locks the pause mode so that it cannot be accidentally activated. More...
 
void PauseLoopMode (bool _bPause=true)
 This member function pauses the loop mode, so that the new assigned equation does not invalidate already parsed equations. More...
 
bool IsAlreadyParsed (StringView sNewEquation)
 This member function checks, whether the passed expression is already parsed, so that the parsing step may be omitted. More...
 
bool IsNotLastStackItem () const
 Check, whether there are more elements on the parsing stack remaining. More...
 
 ParserBase ()
 Constructor. More...
 
 ParserBase (const ParserBase &a_Parser)
 Copy constructor. More...
 
ParserBaseoperator= (const ParserBase &a_Parser)
 Assignement operator. More...
 
virtual ~ParserBase ()
 
value_type Eval ()
 Single-value wrapper around the vectorized overload of this member function. More...
 
value_typeEval (int &nStackSize)
 Evaluate an expression containing comma seperated subexpressions. More...
 
void Eval (value_type *results, int nBulkSize)
 This member function evaluates the expression in parallel. Is not used at the moment. More...
 
void SetExpr (StringView a_sExpr)
 Set the expression. Triggers first time calculation thus the creation of the bytecode and scanning of used variables. More...
 
void SetVarFactory (facfun_type a_pFactory, void *pUserData=NULL)
 Set a function that can create variable pointer for unknown expression variables. More...
 
void SetDecSep (char_type cDecSep)
 Set the decimal separator. More...
 
void SetThousandsSep (char_type cThousandsSep=0)
 Sets the thousands operator. More...
 
void ResetLocale ()
 Resets the locale. More...
 
void EnableOptimizer (bool a_bIsOn=true)
 Enable or disable the formula optimization feature. More...
 
void EnableBuiltInOprt (bool a_bIsOn=true)
 Enable or disable the built in binary operators. More...
 
bool HasBuiltInOprt () const
 Query status of built in variables. More...
 
void AddValIdent (identfun_type a_pCallback)
 Add a value parsing function. More...
 
template<typename T >
void DefineFun (const string_type &a_strName, T a_pFun, bool optimizeAway=true)
 Define a parser function without arguments. More...
 
void DefineOprt (const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, EOprtAssociativity a_eAssociativity=oaLEFT, bool optimizeAway=true)
 Define a binary operator. More...
 
void DefineConst (const string_type &a_sName, value_type a_fVal)
 Add a user defined constant. More...
 
void DefineStrConst (const string_type &a_sName, const string_type &a_strVal)
 Define a new string constant. More...
 
void DefineVar (const string_type &a_sName, value_type *a_fVar)
 Add a user defined variable. More...
 
void DefinePostfixOprt (const string_type &a_strFun, fun_type1 a_pOprt, bool optimizeAway=true)
 Add a user defined operator. More...
 
void DefineInfixOprt (const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool optimizeAway=true)
 Add a user defined operator. More...
 
void ClearVar ()
 Clear all user defined variables. More...
 
void ClearFun ()
 Clear all functions. More...
 
void ClearConst ()
 Clear all user defined constants. More...
 
void ClearInfixOprt ()
 Clear the user defined Prefix operators. More...
 
void ClearPostfixOprt ()
 Clear all user defined postfix operators. More...
 
void ClearOprt ()
 Clear all user defined binary operators. More...
 
void RemoveVar (const string_type &a_strVarName)
 Remove a variable from internal storage. More...
 
const varmap_typeGetUsedVar ()
 Return a map containing the used variables only. More...
 
const varmap_typeGetVar () const
 Return a map containing the used variables only. More...
 
const valmap_typeGetConst () const
 Return a map containing all parser constants. More...
 
const string_typeGetExpr () const
 Retrieve the formula. More...
 
const funmap_typeGetFunDef () const
 Return prototypes of all parser functions. More...
 
const std::map< std::string, std::vector< mu::value_type > > & GetVectors () const
 
string_type GetVersion (EParserVersionInfo eInfo=pviFULL) const
 Returns the version of muparser. More...
 
const char_type ** GetOprtDef () const
 Get the default symbols used for the built in operators. More...
 
void DefineNameChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of functions, variables, constants. More...
 
void DefineOprtChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of binary operators and postfix operators. More...
 
void DefineInfixOprtChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of infix operators. More...
 
const char_typeValidNameChars () const
 Virtual function that defines the characters allowed in name identifiers. More...
 
const char_typeValidOprtChars () const
 Virtual function that defines the characters allowed in operator definitions. More...
 
const char_typeValidInfixOprtChars () const
 Virtual function that defines the characters allowed in infix operator definitions. More...
 
void SetArgSep (char_type cArgSep)
 Set argument separator. More...
 
char_type GetArgSep () const
 Get the argument separator character. More...
 
void Error (EErrorCodes a_iErrc, int a_iPos=(int) mu::string_type::npos, const string_type &a_strTok=string_type()) const
 Create an error containing the parse error position. More...
 
void Error (EErrorCodes a_iErrc, const string_type &a_Expr, int a_iPos=(int) mu::string_type::npos, const string_type &a_strTok=string_type()) const
 Create an error containing the parse error position. More...
 
string_type CreateTempVectorVar (const std::vector< mu::value_type > &vVar)
 This member function copies the passed vector into the internal storage referencing it with a auto-generated variable name. More...
 
void SetVectorVar (const std::string &sVarName, const std::vector< mu::value_type > &vVar, bool bAddVectorType=false)
 This member function copies the passed vector into the internal storage referencing it with the passed name. More...
 
std::vector< mu::value_type > * GetVectorVar (const std::string &sVarName)
 This member function returns a pointer to the vector stored internally. More...
 
void UpdateVectorVar (const std::string &sVarName)
 This member function updates the corresponding variable of a vector with the previously newly assigned value. More...
 
void ClearVectorVars (bool bIgnoreProcedureVects=false)
 This member function cleares the internal vector storage. More...
 
bool ContainsVectorVars (StringView sExpr, bool ignoreSingletons)
 This member function checks, whether the passed expression contains a vector. More...
 

Static Public Member Functions

static void EnableDebugDump (bool bDumpCmd, bool bDumpStack)
 Enable the dumping of bytecode amd stack content on the console. More...
 

Public Attributes

std::map< std::string, std::string > * mVarMapPntr
 
std::list< mu::value_type * > m_lDataStorage
 

Protected Member Functions

void Init ()
 Initialize user defined functions. More...
 
virtual void InitCharSets ()=0
 
virtual void InitFun ()=0
 
virtual void InitConst ()=0
 
virtual void InitOprt ()=0
 
virtual void OnDetectVar (string_type *pExpr, int &nStart, int &nEnd)
 

Static Protected Attributes

static const char_typec_DefaultOprt []
 Identifiers for built in binary operators. More...
 
static std::locale s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.'))
 The locale used by the parser. More...
 
static bool g_DbgDumpCmdCode = false
 
static bool g_DbgDumpStack = false
 

Private Types

typedef void(ParserBase::* ParseFunction) ()
 Typedef for the parse functions. More...
 
typedef std::vector< string_typestringbuf_type
 Type for a vector of strings. More...
 
typedef ParserTokenReader token_reader_type
 Typedef for the token reader. More...
 
typedef ParserToken< value_type, string_typetoken_type
 Type used for parser tokens. More...
 

Private Member Functions

void replaceLocalVars (std::string &sLine)
 This member function replaces var occurences with the names of local variables. More...
 
bool checkDelimiter (StringView sLine)
 This member function checks, whether the passed string is delimited on both sides. More...
 
MutableStringView compileVectors (MutableStringView sExpr)
 This function pre-evaluates all vectors, which are contained in the expression passed through sExpr. More...
 
bool compileVectorsInMultiArgFunc (MutableStringView &sExpr, size_t &nPos)
 This private function will try to find a surrounding multi-argument function, resolve the arguments, apply the function and store the result as a new vector. More...
 
size_t FindMultiArgFunc (StringView sExpr, size_t nPos, std::string &sMultArgFunc)
 This function searches for the first multi-argument function found in the passed expression. More...
 
void compileVectorExpansion (MutableStringView sSubExpr, const std::string &sVectorVarName)
 This function evaluates the vector expansion, e.g. "{1:4}" = {1, 2, 3, 4}. More...
 
void expandVector (mu::value_type dFirst, const mu::value_type &dLast, const mu::value_type &dIncrement, std::vector< mu::value_type > &vResults)
 This function expands the vector. Private member used by ParserBase::compileVectorExpansion(). More...
 
void evaluateTemporaryVectors (const VectorEvaluation &vectEval, int nStackSize)
 This member function evaluates the temporary vector expressions and assigns their results to their corresponding target vector. More...
 
string_type getNextVarObject (std::string &sArgList, bool bCut)
 This member function returns the next comma-separated expression object from the passed argument list. More...
 
string_type getNextVectorVarIndex ()
 This member function returns the next free vector index, which can be used to create a new temporary vector. More...
 
void Assign (const ParserBase &a_Parser)
 Copy state of a parser object to this. More...
 
void InitTokenReader ()
 Initialize the token reader. More...
 
void ReInit ()
 Reset parser to string parsing mode and clear internal buffers. More...
 
ExpressionTargetgetTarget () const
 Simple state-considering wrapper around the ExpressionTarget structure. More...
 
void AddCallback (const string_type &a_strName, const ParserCallback &a_Callback, funmap_type &a_Storage, const char_type *a_szCharSet)
 Add a function or operator callback to the parser. More...
 
void ApplyRemainingOprt (ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal) const
 Apply a binary operator. More...
 
void ApplyBinOprt (ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal) const
 Performs the necessary steps to write code for the execution of binary operators into the bytecode. More...
 
void ApplyIfElse (ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal) const
 
void ApplyFunc (ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal, int iArgCount) const
 Apply a function token. More...
 
token_type ApplyStrFunc (const token_type &a_FunTok, const std::vector< token_type > &a_vArg) const
 Execute a function that takes a single string argument. More...
 
int GetOprtPrecedence (const token_type &a_Tok) const
 Get operator priority. More...
 
EOprtAssociativity GetOprtAssociativity (const token_type &a_Tok) const
 Get operator priority. More...
 
void CreateRPN ()
 
void ParseString ()
 One of the two main parse functions. More...
 
void ParseCmdCode ()
 Parse the command code. More...
 
void ParseCmdCodeBulk (int nOffset, int nThreadID)
 Evaluate the RPN. More...
 
void ParseCmdCodeBulkParallel (size_t nVectorLength)
 OpenMP optimized parallel bytecode executor. More...
 
void CheckName (const string_type &a_strName, const string_type &a_CharSet) const
 Check if a name contains invalid characters. More...
 
void CheckOprt (const string_type &a_sName, const ParserCallback &a_Callback, const string_type &a_szCharSet) const
 Check if a name contains invalid characters. More...
 
void StackDump (const ParserStack< token_type > &a_stVal, const ParserStack< token_type > &a_stOprt) const
 Dump stack content. More...
 

Private Attributes

ParseFunction m_pParseFormula
 Pointer to the parser function. More...
 
State m_compilingState
 
ExpressionTarget m_compilingTarget
 
StateStacks m_stateStacks
 
Statem_state
 
valbuf_type m_buffer
 
vectormap_type mVectorVars
 Maximum number of threads spawned by OpenMP when using the bulk mode. More...
 
unsigned int nthLoopElement
 
unsigned int nthLoopPartEquation
 
unsigned int nCurrVectorIndex
 
bool bMakeLoopByteCode
 
bool bPauseLoopByteCode
 
bool bPauseLock
 
bool bCompiling
 
int nMaxThreads
 
stringbuf_type m_vStringBuf
 String buffer, used for storing string function arguments. More...
 
stringbuf_type m_vStringVarBuf
 
std::unique_ptr< token_reader_typem_pTokenReader
 Managed pointer to the token reader object. More...
 
funmap_type m_FunDef
 Map of function names and pointers. More...
 
funmap_type m_PostOprtDef
 Postfix operator callbacks. More...
 
funmap_type m_InfixOprtDef
 unary infix operator. More...
 
funmap_type m_OprtDef
 Binary operator callbacks. More...
 
valmap_type m_ConstDef
 user constants. More...
 
strmap_type m_StrVarDef
 user defined string constants More...
 
varmap_type m_VarDef
 user defind variables. More...
 
bool m_bBuiltInOp
 Flag that can be used for switching built in operators on and off. More...
 
string_type m_sNameChars
 Charset for names. More...
 
string_type m_sOprtChars
 Charset for postfix/ binary operator tokens. More...
 
string_type m_sInfixOprtChars
 Charset for infix operator tokens. More...
 
int m_nIfElseCounter
 Internal counter for keeping track of nested if-then-else clauses. More...
 
const std::string EMPTYSTRING
 

Friends

class ParserTokenReader
 

Detailed Description

Mathematical expressions parser (base parser engine).

Author
(C) 2012 Ingo Berg

This is the implementation of a bytecode based mathematical expressions parser. The formula will be parsed from string and converted into a bytecode. Future calculations will be done with the bytecode instead the formula string resulting in a significant performance increase. Complementary to a set of internally implemented functions the parser is able to handle user defined functions and variables.

Definition at line 68 of file muParserBase.h.

Member Typedef Documentation

◆ exception_type

Type of the error class.

Included for backwards compatibility.

Definition at line 96 of file muParserBase.h.

◆ ParseFunction

typedef void(ParserBase::* mu::ParserBase::ParseFunction) ()
private

Typedef for the parse functions.

The parse function do the actual work. The parser exchanges the function pointer to the parser function depending on which state it is in. (i.e. bytecode parser vs. string parser)

Definition at line 79 of file muParserBase.h.

◆ stringbuf_type

typedef std::vector<string_type> mu::ParserBase::stringbuf_type
private

Type for a vector of strings.

Definition at line 82 of file muParserBase.h.

◆ token_reader_type

Typedef for the token reader.

Definition at line 85 of file muParserBase.h.

◆ token_type

Type used for parser tokens.

Definition at line 88 of file muParserBase.h.

Constructor & Destructor Documentation

◆ ParserBase() [1/2]

mu::ParserBase::ParserBase ( )

Constructor.

Exceptions
ParserExceptionif a_szFormula is null.

Definition at line 227 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLock, bPauseLoopByteCode, InitTokenReader(), m_compilingState, m_state, mVarMapPntr, nCurrVectorIndex, nMaxThreads, nthLoopElement, and nthLoopPartEquation.

Here is the call graph for this function:

◆ ParserBase() [2/2]

mu::ParserBase::ParserBase ( const ParserBase a_Parser)

Copy constructor.

Tha parser can be safely copy constructed but the bytecode is reset during copy construction.

Definition at line 264 of file muParserBase.cpp.

References Assign(), bMakeLoopByteCode, bPauseLock, bPauseLoopByteCode, m_compilingState, m_pTokenReader, m_state, mVarMapPntr, nMaxThreads, and nthLoopElement.

Here is the call graph for this function:

◆ ~ParserBase()

mu::ParserBase::~ParserBase ( )
virtual

Definition at line 296 of file muParserBase.cpp.

References m_lDataStorage.

Member Function Documentation

◆ ActivateLoopMode()

void mu::ParserBase::ActivateLoopMode ( unsigned int  _nLoopLength)

Activates the loop mode and prepares the internal arrays for storing the necessary data.

Parameters
_nLoopLengthunsigned int
Returns
void

Definition at line 3096 of file muParserBase.cpp.

References bCompiling, bMakeLoopByteCode, DeactivateLoopMode(), g_DbgDumpStack, m_stateStacks, nCurrVectorIndex, nthLoopElement, nthLoopPartEquation, NumeReKernel::print(), and mu::StateStacks::resize().

Referenced by FlowCtrl::eval().

Here is the call graph for this function:

◆ ActiveLoopMode()

bool mu::ParserBase::ActiveLoopMode ( ) const

Check, whether the loop mode is active. This function returns true even if the loop mode is paused.

Returns
bool

Definition at line 3356 of file muParserBase.cpp.

References bMakeLoopByteCode.

Referenced by FlowCtrl::eval(), Procedure::ProcCalc(), and FlowCtrl::reset().

◆ AddCallback()

void mu::ParserBase::AddCallback ( const string_type a_strName,
const ParserCallback a_Callback,
funmap_type a_Storage,
const char_type a_szCharSet 
)
private

Add a function or operator callback to the parser.

Definition at line 537 of file muParserBase.cpp.

References CheckOprt(), mu::ecINVALID_FUN_PTR, mu::ecNAME_CONFLICT, Error(), mu::ParserCallback::GetAddr(), m_FunDef, m_InfixOprtDef, m_OprtDef, m_PostOprtDef, and ReInit().

Referenced by DefineFun(), DefineInfixOprt(), DefineOprt(), and DefinePostfixOprt().

Here is the call graph for this function:

◆ AddValIdent()

void mu::ParserBase::AddValIdent ( identfun_type  a_pCallback)

Add a value parsing function.

When parsing an expression muParser tries to detect values in the expression string using different valident callbacks. Thuis it's possible to parse for hex values, binary values and floating point values.

Definition at line 520 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by mu::Parser::Parser(), and mu::ParserInt::ParserInt().

◆ ApplyBinOprt()

void mu::ParserBase::ApplyBinOprt ( ParserStack< token_type > &  a_stOpt,
ParserStack< token_type > &  a_stVal 
) const
private

Performs the necessary steps to write code for the execution of binary operators into the bytecode.

Definition at line 1547 of file muParserBase.cpp.

References _nrT, mu::ParserByteCode::AddAssignOp(), mu::ParserByteCode::AddOp(), ApplyFunc(), mu::cmASSIGN, mu::cmOPRT_BIN, mu::cmVAR, mu::ecOPRT_TYPE_CONFLICT, mu::ecUNEXPECTED_OPERATOR, Error(), mu::ParserToken< TBase, TString >::GetType(), mu::State::m_byteCode, m_compilingState, m_pTokenReader, MUP_ASSERT, mu::ParserStack< TValueType >::pop(), mu::ParserStack< TValueType >::push(), mu::ParserStack< TValueType >::size(), mu::ParserStack< TValueType >::top(), and mu::tpSTR.

Referenced by ApplyRemainingOprt(), and CreateRPN().

Here is the call graph for this function:

◆ ApplyFunc()

void mu::ParserBase::ApplyFunc ( ParserStack< token_type > &  a_stOpt,
ParserStack< token_type > &  a_stVal,
int  a_iArgCount 
) const
private

Apply a function token.

Parameters
iArgCountint Number of Arguments actually gathered used only for multiarg functions.
Postcondition
The result is pushed to the value stack
The function token is removed from the stack
Exceptions
exception_typeif Argument count does not mach function requirements.

Definition at line 1428 of file muParserBase.cpp.

References mu::ParserByteCode::AddBulkFun(), mu::ParserByteCode::AddFun(), ApplyStrFunc(), mu::cmFUNC, mu::cmFUNC_BULK, mu::cmFUNC_STR, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmOPRT_POSTFIX, mu::ecINTERNAL_ERROR, mu::ecTOO_FEW_PARAMS, mu::ecTOO_MANY_PARAMS, mu::ecVAL_EXPECTED, mu::ParserStack< TValueType >::empty(), Error(), mu::ParserToken< TBase, TString >::GetArgCount(), mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserToken< TBase, TString >::GetFuncAddr(), mu::ParserToken< TBase, TString >::GetType(), mu::ParserToken< TBase, TString >::IsOptimizable(), mu::State::m_byteCode, m_compilingState, m_pTokenReader, mu::ParserStack< TValueType >::pop(), mu::ParserStack< TValueType >::push(), mu::ParserToken< TBase, TString >::SetVal(), mu::ParserStack< TValueType >::top(), and mu::tpSTR.

Referenced by ApplyBinOprt(), ApplyRemainingOprt(), and CreateRPN().

Here is the call graph for this function:

◆ ApplyIfElse()

void mu::ParserBase::ApplyIfElse ( ParserStack< token_type > &  a_stOpt,
ParserStack< token_type > &  a_stVal 
) const
private

◆ ApplyRemainingOprt()

void mu::ParserBase::ApplyRemainingOprt ( ParserStack< token_type > &  stOpt,
ParserStack< token_type > &  stVal 
) const
private

Apply a binary operator.

Parameters
a_stOptThe operator stack
a_stValThe value stack

Definition at line 1587 of file muParserBase.cpp.

References ApplyBinOprt(), ApplyFunc(), ApplyIfElse(), mu::cmADD, mu::cmASSIGN, mu::cmBO, mu::cmDIV, mu::cmELSE, mu::cmEQ, mu::cmGE, mu::cmGT, mu::cmIF, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmPOW, mu::cmSUB, mu::ecINTERNAL_ERROR, Error(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserStack< TValueType >::size(), and mu::ParserStack< TValueType >::top().

Referenced by CreateRPN().

Here is the call graph for this function:

◆ ApplyStrFunc()

ParserBase::token_type mu::ParserBase::ApplyStrFunc ( const token_type a_FunTok,
const std::vector< token_type > &  a_vArg 
) const
private

Execute a function that takes a single string argument.

Parameters
a_FunTokFunction token.
Exceptions
exception_typeIf the function token is not a string function

Definition at line 1379 of file muParserBase.cpp.

References mu::ParserByteCode::AddStrFun(), mu::cmSTRING, mu::ecINTERNAL_ERROR, mu::ecSTRING_EXPECTED, mu::ecVAL_EXPECTED, Error(), mu::ParserToken< TBase, TString >::GetArgCount(), mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserToken< TBase, TString >::GetFuncAddr(), mu::State::m_byteCode, m_compilingState, m_pTokenReader, and mu::ParserToken< TBase, TString >::SetVal().

Referenced by ApplyFunc().

Here is the call graph for this function:

◆ Assign()

void mu::ParserBase::Assign ( const ParserBase a_Parser)
private

Copy state of a parser object to this.

Clears Variables and Functions of this parser. Copies the states of all internal variables. Resets parse function to string parse mode.

Parameters
a_Parserthe source object.

Definition at line 325 of file muParserBase.cpp.

References m_bBuiltInOp, m_compilingState, m_ConstDef, m_FunDef, m_InfixOprtDef, m_nIfElseCounter, m_OprtDef, m_PostOprtDef, m_pTokenReader, m_sInfixOprtChars, m_sNameChars, m_sOprtChars, m_StrVarDef, m_VarDef, m_vStringBuf, m_vStringVarBuf, and ReInit().

Referenced by operator=(), and ParserBase().

Here is the call graph for this function:

◆ CacheCurrentAccess()

void mu::ParserBase::CacheCurrentAccess ( const CachedDataAccess _access)

Store the passed data access for this position internally.

Parameters
_accessconst CachedDataAccess&
Returns
void

Definition at line 3191 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, and nthLoopElement.

Referenced by handleMafDataAccess(), and replaceDataEntities().

◆ CacheCurrentEquation()

void mu::ParserBase::CacheCurrentEquation ( const std::string &  sEquation)

Caches the passed equation for this position.

Parameters
sEquationconst string&
Returns
void

Definition at line 3272 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, and nthLoopElement.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

◆ CacheCurrentTarget()

void mu::ParserBase::CacheCurrentTarget ( const std::string &  sEquation)

Caches the passed target equation for this position.

Parameters
sEquationconst string&
Returns
void

Definition at line 3303 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, and nthLoopElement.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

◆ CanCacheAccess()

bool mu::ParserBase::CanCacheAccess ( )

Check, whether the current position can cache any data accesses.

Returns
bool

Definition at line 3238 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, and nthLoopElement.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

◆ checkDelimiter()

bool mu::ParserBase::checkDelimiter ( StringView  sLine)
private

This member function checks, whether the passed string is delimited on both sides.

Parameters
sLineStringView
Returns
bool

Definition at line 3704 of file muParserBase.cpp.

References StringViewBase::back(), StringViewBase::front(), and mu::isDelim().

Referenced by compileVectors(), ContainsVectorVars(), and replaceLocalVars().

Here is the call graph for this function:

◆ CheckName()

void mu::ParserBase::CheckName ( const string_type a_sName,
const string_type a_szCharSet 
) const
private

Check if a name contains invalid characters.

Exceptions
ParserExceptionif the name contains invalid charakters.

Definition at line 595 of file muParserBase.cpp.

References mu::ecINVALID_NAME, and Error().

Referenced by DefineConst(), DefineStrConst(), and DefineVar().

Here is the call graph for this function:

◆ CheckOprt()

void mu::ParserBase::CheckOprt ( const string_type a_sName,
const ParserCallback a_Callback,
const string_type a_szCharSet 
) const
private

Check if a name contains invalid characters.

Exceptions
ParserExceptionif the name contains invalid charakters.

Definition at line 570 of file muParserBase.cpp.

References mu::cmOPRT_INFIX, mu::cmOPRT_POSTFIX, mu::ecINVALID_INFIX_IDENT, mu::ecINVALID_NAME, mu::ecINVALID_POSTFIX_IDENT, Error(), and mu::ParserCallback::GetCode().

Referenced by AddCallback().

Here is the call graph for this function:

◆ ClearConst()

void mu::ParserBase::ClearConst ( )

Clear all user defined constants.

Both numeric and string constants will be removed from the internal storage.

Postcondition
Resets the parser to string parsing mode.
Exceptions
nothrow

Definition at line 2515 of file muParserBase.cpp.

References m_ConstDef, m_StrVarDef, and ReInit().

Referenced by mu::Test::ParserTester::TestNames().

Here is the call graph for this function:

◆ ClearFun()

void mu::ParserBase::ClearFun ( )

Clear all functions.

Postcondition
Resets the parser to string parsing mode.
Exceptions
nothrow

Definition at line 2502 of file muParserBase.cpp.

References m_FunDef, and ReInit().

Here is the call graph for this function:

◆ ClearInfixOprt()

void mu::ParserBase::ClearInfixOprt ( )

Clear the user defined Prefix operators.

Postcondition
Resets the parser to string parser mode.
Exceptions
nothrow

Definition at line 2549 of file muParserBase.cpp.

References m_InfixOprtDef, and ReInit().

Here is the call graph for this function:

◆ ClearOprt()

void mu::ParserBase::ClearOprt ( )

Clear all user defined binary operators.

Postcondition
Resets the parser to string parsing mode.
Exceptions
nothrow

Definition at line 2538 of file muParserBase.cpp.

References m_OprtDef, and ReInit().

Here is the call graph for this function:

◆ ClearPostfixOprt()

void mu::ParserBase::ClearPostfixOprt ( )

Clear all user defined postfix operators.

Postcondition
Resets the parser to string parsing mode.
Exceptions
nothrow

Definition at line 2527 of file muParserBase.cpp.

References m_PostOprtDef, and ReInit().

Referenced by mu::Test::ParserTester::TestNames().

Here is the call graph for this function:

◆ ClearVar()

void mu::ParserBase::ClearVar ( )

Clear all user defined variables.

Exceptions
nothrow

Resets the parser to string parsing mode by calling ReInit.

Definition at line 2461 of file muParserBase.cpp.

References m_VarDef, and ReInit().

Here is the call graph for this function:

◆ ClearVectorVars()

void mu::ParserBase::ClearVectorVars ( bool  bIgnoreProcedureVects = false)

This member function cleares the internal vector storage.

Parameters
bIgnoreProcedureVectsbool
Returns
void

Definition at line 3619 of file muParserBase.cpp.

References mu::ExpressionTarget::clear(), m_compilingTarget, mVectorVars, and RemoveVar().

Referenced by FlowCtrl::eval(), NumeReKernel::MainLoop(), Procedure::ProcCalc(), and FlowCtrl::reset().

Here is the call graph for this function:

◆ compileVectorExpansion()

void mu::ParserBase::compileVectorExpansion ( MutableStringView  sSubExpr,
const std::string &  sVectorVarName 
)
private

This function evaluates the vector expansion, e.g. "{1:4}" = {1, 2, 3, 4}.

Parameters
sSubExprMutableStringView
sVectorVarNameconst std::string&
Returns
void

Definition at line 779 of file muParserBase.cpp.

References mu::VectorEvaluation::create(), mu::ecUNEXPECTED_CONDITIONAL, Eval(), getAllArguments(), getMatchingParenthesis(), StringViewBase::length(), m_compilingState, mu::State::m_vectEval, SetExpr(), MutableStringView::subview(), and StringViewBase::to_string().

Referenced by compileVectors().

Here is the call graph for this function:

◆ compileVectors()

MutableStringView mu::ParserBase::compileVectors ( MutableStringView  sExpr)
private

This function pre-evaluates all vectors, which are contained in the expression passed through sExpr.

Parameters
sExprMutableStringView containing the expression
Returns
MutableStringView

Definition at line 664 of file muParserBase.cpp.

References checkDelimiter(), compileVectorExpansion(), compileVectorsInMultiArgFunc(), mu::VectorEvaluation::create(), mu::ExpressionTarget::create(), CreateTempVectorVar(), Eval(), StringViewBase::find(), StringViewBase::find_first_not_of(), getMatchingParenthesis(), getTarget(), isDelimiter(), StringViewBase::length(), m_compilingState, m_pTokenReader, mu::State::m_vectEval, mVectorVars, MutableStringView::replace(), SetExpr(), SetVectorVar(), and MutableStringView::subview().

Referenced by SetExpr().

Here is the call graph for this function:

◆ compileVectorsInMultiArgFunc()

bool mu::ParserBase::compileVectorsInMultiArgFunc ( MutableStringView sExpr,
size_t &  nPos 
)
private

This private function will try to find a surrounding multi-argument function, resolve the arguments, apply the function and store the result as a new vector.

Parameters
sExprMutableStringView&
nPossize_t&
Returns
bool

Definition at line 918 of file muParserBase.cpp.

References mu::VectorEvaluation::create(), CreateTempVectorVar(), Eval(), FindMultiArgFunc(), getMatchingParenthesis(), StringViewBase::length(), m_compilingState, mu::State::m_vectEval, MutableStringView::replace(), SetExpr(), and MutableStringView::subview().

Referenced by compileVectors().

Here is the call graph for this function:

◆ ContainsVectorVars()

bool mu::ParserBase::ContainsVectorVars ( StringView  sExpr,
bool  ignoreSingletons 
)

This member function checks, whether the passed expression contains a vector.

Parameters
sExprStringView
ignoreSingletonsbool
Returns
bool

Definition at line 3663 of file muParserBase.cpp.

References checkDelimiter(), StringViewBase::find(), func, mVectorVars, and StringView::subview().

Referenced by NumeRe::StringParser::evaluateStack(), handleMafDataAccess(), and SetExpr().

Here is the call graph for this function:

◆ CreateRPN()

void mu::ParserBase::CreateRPN ( )
private

Definition at line 2137 of file muParserBase.cpp.

References mu::ParserByteCode::AddIfElse(), mu::ParserByteCode::AddVal(), mu::ParserByteCode::AddVar(), ApplyBinOprt(), ApplyFunc(), ApplyRemainingOprt(), mu::ParserByteCode::AsciiDump(), mu::cmADD, mu::cmARG_SEP, mu::cmASSIGN, mu::cmBC, mu::cmBO, mu::cmDIV, mu::cmELSE, mu::cmEND, mu::cmEQ, mu::cmFUNC, mu::cmFUNC_BULK, mu::cmFUNC_STR, mu::cmGE, mu::cmGT, mu::cmIF, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmOPRT_POSTFIX, mu::cmPOW, mu::cmSTRING, mu::cmSUB, mu::cmVAL, mu::cmVAR, mu::ecEMPTY_EXPRESSION, mu::ecINTERNAL_ERROR, mu::ecMISPLACED_COLON, mu::ecMISSING_ELSE_CLAUSE, mu::ecSTR_RESULT, mu::ecUNEXPECTED_ARG, mu::ecUNEXPECTED_ARG_SEP, mu::ecUNEXPECTED_EOF, mu::ParserStack< TValueType >::empty(), Error(), mu::ParserByteCode::Finalize(), g_DbgDumpCmdCode, g_DbgDumpStack, mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserByteCode::GetMaxStackSize(), GetOprtAssociativity(), GetOprtPrecedence(), mu::ParserToken< TBase, TString >::GetVal(), mu::ParserToken< TBase, TString >::GetVar(), mu::State::m_byteCode, m_compilingState, m_nIfElseCounter, mu::State::m_numResults, m_pTokenReader, mu::State::m_stackBuffer, m_vStringBuf, MUP_ASSERT, mVectorVars, nMaxThreads, mu::oaLEFT, mu::oaRIGHT, mu::ParserStack< TValueType >::pop(), NumeReKernel::print(), mu::ParserStack< TValueType >::push(), mu::ParserToken< TBase, TString >::SetIdx(), SetVectorVar(), mu::ParserStack< TValueType >::size(), mu::ParserStack< TValueType >::top(), and mu::tpDBL.

Referenced by Eval(), and ParseString().

Here is the call graph for this function:

◆ CreateTempVectorVar()

string_type mu::ParserBase::CreateTempVectorVar ( const std::vector< mu::value_type > &  vVar)

This member function copies the passed vector into the internal storage referencing it with a auto-generated variable name.

Parameters
vVarconst std::vector<mu::value_type>&
Returns
string_type

Definition at line 3524 of file muParserBase.cpp.

References getNextVectorVarIndex(), and SetVectorVar().

Referenced by compileVectors(), compileVectorsInMultiArgFunc(), NumeRe::StringParser::createStringOutput(), NumeRe::StringParser::eval(), NumeReKernel::executePlugins(), getDataElements(), NumeRe::StringParser::parseStringsInIndices(), Procedure::procedureInterface(), Procedure::replaceReturnVal(), CommandLineParser::setReturnValue(), tableMethod_binsof(), tableMethod_counteq(), tableMethod_cov(), tableMethod_findCols(), tableMethod_index(), tableMethod_pcorr(), tableMethod_rank(), tableMethod_scorr(), tableMethod_zscore(), and windowCommand().

Here is the call graph for this function:

◆ DeactivateLoopMode()

void mu::ParserBase::DeactivateLoopMode ( )

Deactivates the loop mode and resets the internal arrays.

Returns
void

Definition at line 3122 of file muParserBase.cpp.

References bCompiling, bMakeLoopByteCode, mu::StateStacks::clear(), g_DbgDumpStack, m_compilingState, m_state, m_stateStacks, nCurrVectorIndex, nthLoopElement, nthLoopPartEquation, and NumeReKernel::print().

Referenced by ActivateLoopMode(), FlowCtrl::reset(), and NumeReKernel::resetAfterError().

Here is the call graph for this function:

◆ DefineConst()

void mu::ParserBase::DefineConst ( const string_type a_sName,
value_type  a_fVal 
)

Add a user defined constant.

Parameters
[in]a_sNameThe name of the constant.
[in]a_fValthe value of the constant.
Postcondition
Will reset the Parser to string parsing mode.
Exceptions
ParserExceptionin case the name contains invalid signs.

Definition at line 1213 of file muParserBase.cpp.

References CheckName(), m_ConstDef, ReInit(), and ValidNameChars().

Referenced by NumeReKernel::defineConst(), mu::Test::ParserTester::EqnTest(), mu::Test::ParserTester::EqnTestInt(), and mu::Parser::InitConst().

Here is the call graph for this function:

◆ DefineFun()

template<typename T >
void mu::ParserBase::DefineFun ( const string_type a_strName,
a_pFun,
bool  optimizeAway = true 
)
inline

Define a parser function without arguments.

Parameters
a_strNameName of the function
a_pFunPointer to the callback function
optimizeAwayA flag indicating this function may be optimized

Definition at line 156 of file muParserBase.h.

References AddCallback(), m_FunDef, and ValidNameChars().

Referenced by NumeReKernel::defineFunctions(), mu::ParserInt::InitFun(), mu::Parser::InitFun(), and mu::Test::ParserTester::ThrowTest().

Here is the call graph for this function:

◆ DefineInfixOprt()

void mu::ParserBase::DefineInfixOprt ( const string_type a_sName,
fun_type1  a_pFun,
int  a_iPrec = prINFIX,
bool  optimizeAway = true 
)

Add a user defined operator.

Postcondition
Will reset the Parser to string parsing mode.
Parameters
[in]a_sNameoperator Identifier
[in]a_pFunOperator callback function
[in]a_iPrecOperator Precedence (default=prSIGN)
[in]optimizeAwayTrue if operator is volatile (default=false)
See also
EPrec

Definition at line 1119 of file muParserBase.cpp.

References AddCallback(), mu::cmOPRT_INFIX, m_InfixOprtDef, and ValidInfixOprtChars().

Referenced by NumeReKernel::defineOperators(), mu::ParserInt::InitOprt(), and mu::Parser::InitOprt().

Here is the call graph for this function:

◆ DefineInfixOprtChars()

void mu::ParserBase::DefineInfixOprtChars ( const char_type a_szCharset)

Define the set of valid characters to be used in names of infix operators.

Definition at line 1048 of file muParserBase.cpp.

References m_sInfixOprtChars.

Referenced by mu::ParserInt::InitCharSets(), and mu::Parser::InitCharSets().

◆ DefineNameChars()

void mu::ParserBase::DefineNameChars ( const char_type a_szCharset)

Define the set of valid characters to be used in names of functions, variables, constants.

Definition at line 1030 of file muParserBase.cpp.

References m_sNameChars.

Referenced by mu::ParserInt::InitCharSets(), and mu::Parser::InitCharSets().

◆ DefineOprt()

void mu::ParserBase::DefineOprt ( const string_type a_sName,
fun_type2  a_pFun,
unsigned  a_iPrec = 0,
EOprtAssociativity  a_eAssociativity = oaLEFT,
bool  optimizeAway = true 
)

Define a binary operator.

Parameters
[in]a_sNameThe identifier of the operator.
[in]a_pFunPointer to the callback function.
[in]a_iPrecPrecedence of the operator.
[in]a_eAssociativityThe associativity of the operator.
[in]a_bAllowOptIf this is true the operator may be optimized away.

Adds a new Binary operator the the parser instance.

Definition at line 1141 of file muParserBase.cpp.

References AddCallback(), c_DefaultOprt, mu::cmENDIF, mu::ecBUILTIN_OVERLOAD, Error(), m_bBuiltInOp, m_OprtDef, and ValidOprtChars().

Referenced by NumeReKernel::defineOperators(), and mu::ParserInt::InitOprt().

Here is the call graph for this function:

◆ DefineOprtChars()

void mu::ParserBase::DefineOprtChars ( const char_type a_szCharset)

Define the set of valid characters to be used in names of binary operators and postfix operators.

Definition at line 1039 of file muParserBase.cpp.

References m_sOprtChars.

Referenced by mu::ParserInt::InitCharSets(), and mu::Parser::InitCharSets().

◆ DefinePostfixOprt()

void mu::ParserBase::DefinePostfixOprt ( const string_type a_sName,
fun_type1  a_pFun,
bool  optimizeAway = true 
)

Add a user defined operator.

Postcondition
Will reset the Parser to string parsing mode.

Definition at line 1087 of file muParserBase.cpp.

References AddCallback(), mu::cmOPRT_POSTFIX, m_PostOprtDef, mu::prPOSTFIX, and ValidOprtChars().

Referenced by NumeReKernel::defineOperators(), and mu::Test::ParserTester::ThrowTest().

Here is the call graph for this function:

◆ DefineStrConst()

void mu::ParserBase::DefineStrConst ( const string_type a_strName,
const string_type a_strVal 
)

Define a new string constant.

Parameters
[in]a_strNameThe name of the constant.
[in]a_strValthe value of the constant.

Definition at line 1163 of file muParserBase.cpp.

References CheckName(), mu::ecNAME_CONFLICT, Error(), m_StrVarDef, m_vStringBuf, m_vStringVarBuf, ReInit(), and ValidNameChars().

Here is the call graph for this function:

◆ DefineVar()

void mu::ParserBase::DefineVar ( const string_type a_sName,
value_type a_pVar 
)

Add a user defined variable.

Parameters
[in]a_sNamethe variable name
[in]a_pVarA pointer to the variable vaule.
Postcondition
Will reset the Parser to string parsing mode.
Exceptions
ParserExceptionin case the name contains invalid signs or a_pVar is NULL.

Definition at line 1184 of file muParserBase.cpp.

References CheckName(), mu::ecINVALID_VAR_PTR, mu::ecNAME_CONFLICT, Error(), m_ConstDef, m_VarDef, ReInit(), and ValidNameChars().

Referenced by ProcedureVarFactory::createLocalVars(), mu::Test::ParserTester::EqnTestInt(), mu::Test::ParserTester::EqnTestWithVarChange(), ProcedureVarFactory::evaluateProcedureArguments(), FlowCtrl::prepareLocalVarsAndReplace(), FlowCtrl::range_based_for_loop(), FlowCtrl::reset(), SetVectorVar(), NumeReKernel::StartUp(), mu::Test::ParserTester::TestInterface(), mu::Test::ParserTester::TestVarConst(), and mu::Test::ParserTester::ThrowTest().

Here is the call graph for this function:

◆ DisableAccessCaching()

void mu::ParserBase::DisableAccessCaching ( )

Disable the data access caching for this position.

Returns
void

Definition at line 3221 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, mu::StateStacks::clear(), m_stateStacks, and nthLoopElement.

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), NumeRe::StringParser::getDataForString(), handleCachedDataAccess(), MemoryManager::parseEvery(), replaceDataEntities(), and replaceEntityOccurence().

Here is the call graph for this function:

◆ EnableBuiltInOprt()

void mu::ParserBase::EnableBuiltInOprt ( bool  a_bIsOn = true)

Enable or disable the built in binary operators.

Exceptions
nothrow
See also
m_bBuiltInOp, ReInit()

If you disable the built in binary operators there will be no binary operators defined. Thus you must add them manually one by one. It is not possible to disable built in operators selectively. This function will Reinitialize the parser by calling ReInit().

Definition at line 2589 of file muParserBase.cpp.

References m_bBuiltInOp, and ReInit().

Referenced by mu::ParserInt::InitOprt(), and mu::Test::ParserTester::TestNames().

Here is the call graph for this function:

◆ EnableDebugDump()

void mu::ParserBase::EnableDebugDump ( bool  bDumpCmd,
bool  bDumpStack 
)
static

Enable the dumping of bytecode amd stack content on the console.

Parameters
bDumpCmdFlag to enable dumping of the current bytecode to the console.
bDumpStackFlag to enable dumping of the stack content is written to the console.

This function is for debug purposes only!

Definition at line 2573 of file muParserBase.cpp.

References g_DbgDumpCmdCode, and g_DbgDumpStack.

Referenced by cmd_set().

◆ EnableOptimizer()

void mu::ParserBase::EnableOptimizer ( bool  a_bIsOn = true)

Enable or disable the formula optimization feature.

Postcondition
Resets the parser to string parser mode.
Exceptions
nothrow

Definition at line 2560 of file muParserBase.cpp.

References mu::ParserByteCode::EnableOptimizer(), mu::State::m_byteCode, m_compilingState, and ReInit().

Referenced by mu::Test::ParserTester::EqnTest().

Here is the call graph for this function:

◆ Error() [1/2]

void mu::ParserBase::Error ( EErrorCodes  a_iErrc,
const string_type a_Expr,
int  a_iPos = (int)mu::string_type::npos,
const string_type a_sTok = string_type() 
) const

Create an error containing the parse error position.

This function will create an Parser Exception object containing the error text and its position.

Parameters
a_iErrc[in] The error code of type EErrorCodes.
a_Expr[in] The erroneous expression
a_iPos[in] The position where the error was detected.
a_strTok[in] The token string representation associated with the error.
Exceptions
ParserExceptionalways throws thats the only purpose of this function.

Definition at line 2450 of file muParserBase.cpp.

◆ Error() [2/2]

void mu::ParserBase::Error ( EErrorCodes  a_iErrc,
int  a_iPos = (int)mu::string_type::npos,
const string_type a_sTok = string_type() 
) const

Create an error containing the parse error position.

This function will create an Parser Exception object containing the error text and its position.

Parameters
a_iErrc[in] The error code of type EErrorCodes.
a_iPos[in] The position where the error was detected.
a_strTok[in] The token string representation associated with the error.
Exceptions
ParserExceptionalways throws thats the only purpose of this function.

Definition at line 2433 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by AddCallback(), ApplyBinOprt(), ApplyFunc(), ApplyRemainingOprt(), ApplyStrFunc(), CheckName(), CheckOprt(), CreateRPN(), DefineOprt(), DefineStrConst(), DefineVar(), mu::ParserTokenReader::Error(), GetOprtPrecedence(), ParseCmdCodeBulk(), ParseCmdCodeBulkParallel(), and SetExpr().

◆ Eval() [1/3]

value_type mu::ParserBase::Eval ( )

Single-value wrapper around the vectorized overload of this member function.

Returns
value_type

Definition at line 3073 of file muParserBase.cpp.

References Eval().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), NumeRe::StringFuncHandler::argumentParser(), FlowCtrl::calc(), calculatePercentageAvgAndCreateParserVariables(), FlowCtrl::compile(), compileVectorExpansion(), compileVectors(), compileVectorsInMultiArgFunc(), Plot::constructDataLegendElement(), FunctionDefinition::convertToValues(), Plot::create2dDrawing(), Plot::create3dDrawing(), createDatagrid(), Plot::createDataLegends(), ProcedureVarFactory::createLocalClusters(), ProcedureVarFactory::createLocalInlineVars(), ProcedureVarFactory::createLocalTables(), ProcedureVarFactory::createLocalVars(), createMatFromLines(), createMatFromLinesFilled(), NumeRe::StringParser::createStringOutput(), Plot::createSubPlotSet(), NumeRe::StringParser::createTerminalOutput(), mu::Parser::Diff(), differentiate(), mu::Test::ParserTester::EqnTest(), mu::Test::ParserTester::EqnTestInt(), mu::Test::ParserTester::EqnTestWithVarChange(), Eval(), NumeRe::StringParser::eval(), FlowCtrl::evalHeader(), evalMatOp(), evalPoints(), FlowCtrl::evalRangeBasedHeader(), NumeRe::StringLogicParser::evalStringLogic(), NumeRe::StringLogicParser::evalStringTernary(), evaluateExpression(), evaluateFittingParams(), evaluateNumerical(), evaluateParameterValues(), ProcedureVarFactory::evaluateProcedureArguments(), Plot::evaluateSubplot(), FlowCtrl::extractFlagsAndIndexVariables(), Plot::fillData(), findExtrema(), findExtremaInData(), findExtremaInMultiResult(), findZeroes(), findZeroesInData(), findZeroesInMultiResult(), Fitcontroller::fitctrl(), fitDataSet(), Fitcontroller::fitfunction(), Fitcontroller::fitfunctionrestricted(), Fitcontroller::fitjacobian(), Fitcontroller::fitjacobianrestricted(), StringVector::getBooleanVectorized(), getFittingParameters(), getIndices(), StringVector::getNumericalVectorized(), getParameterValue(), handleCasualIndices(), handleIndexVectors(), integrate(), integrate2d(), integrationstep_simpson(), integrationstep_trapezoidal(), localizeExtremum(), localizeZero(), NumeReKernel::MainLoop(), NumeRe::StringParser::numToString(), Odesolver::odeFunction(), parseArg(), parseCmdArg(), MemoryManager::parseEvery(), CommandLineParser::parseExprAsNumericalValues(), particleSwarmOptimizer(), Plot::Plot(), Procedure::ProcCalc(), readAndParseIntervals(), readAndParseLegacyIntervals(), Interval::refresh(), replaceEntityOccurence(), PlotData::setParams(), Odesolver::solve(), NumeRe::StringParser::storeStringResults(), NumeRe::StringParser::storeStringToDataObjects(), tableMethod_anova(), tableMethod_binsof(), tableMethod_categories(), tableMethod_categorize(), tableMethod_convert(), tableMethod_counteq(), tableMethod_cov(), tableMethod_index(), tableMethod_pcorr(), tableMethod_rank(), tableMethod_scorr(), tableMethod_typeof(), tableMethod_zscore(), taylor(), mu::Test::ParserTester::TestInterface(), and mu::Test::ParserTester::ThrowTest().

Here is the call graph for this function:

◆ Eval() [2/3]

value_type * mu::ParserBase::Eval ( int &  nStackSize)

Evaluate an expression containing comma seperated subexpressions.

This member function can be used to retrieve all results of an expression made up of multiple comma seperated subexpressions (i.e. "x+y,sin(x),cos(y)").

Parameters
nStackSizeint&
Returns
value_type*

Definition at line 2926 of file muParserBase.cpp.

References mu::ExpressionTarget::assign(), bMakeLoopByteCode, bPauseLoopByteCode, mu::ParserByteCode::ChangeVar(), mu::VectorEvaluation::EVALTYPE_NONE, evaluateTemporaryVectors(), g_DbgDumpStack, getTarget(), mu::ExpressionTarget::isValid(), m_buffer, mu::State::m_byteCode, mu::State::m_numResults, m_pParseFormula, mu::State::m_stackBuffer, m_state, m_stateStacks, mu::VectorEvaluation::m_type, mu::State::m_usedVar, mu::State::m_vectEval, max, mVectorVars, nCurrVectorIndex, nthLoopElement, nthLoopPartEquation, ParseCmdCodeBulk(), ParseCmdCodeBulkParallel(), NumeReKernel::print(), mu::printVector(), mu::StateStacks::size(), and toString().

Here is the call graph for this function:

◆ Eval() [3/3]

void mu::ParserBase::Eval ( value_type results,
int  nBulkSize 
)

This member function evaluates the expression in parallel. Is not used at the moment.

Parameters
resultsvalue_type*
nBulkSizeint
Returns
void

Definition at line 3467 of file muParserBase.cpp.

References CreateRPN(), min, nMaxThreads, and ParseCmdCodeBulk().

Here is the call graph for this function:

◆ evaluateTemporaryVectors()

void mu::ParserBase::evaluateTemporaryVectors ( const VectorEvaluation vectEval,
int  nStackSize 
)
private

This member function evaluates the temporary vector expressions and assigns their results to their corresponding target vector.

Parameters
vectEvalconst VectorEvaluation&
nStackSizeint
Returns
void

Definition at line 2828 of file muParserBase.cpp.

References mu::VectorEvaluation::EVALTYPE_MULTIARGFUNC, mu::VectorEvaluation::EVALTYPE_VECTOR, mu::VectorEvaluation::EVALTYPE_VECTOR_EXPANSION, expandVector(), mu::ParserCallback::GetAddr(), GetVectorVar(), m_buffer, mu::VectorEvaluation::m_componentDefs, m_FunDef, mu::VectorEvaluation::m_mafunc, m_state, mu::VectorEvaluation::m_targetVect, mu::VectorEvaluation::m_type, mu::State::m_vectEval, mu::parser_idxtolog(), mu::parser_logtoidx(), and UpdateVectorVar().

Referenced by Eval().

Here is the call graph for this function:

◆ expandVector()

void mu::ParserBase::expandVector ( mu::value_type  dFirst,
const mu::value_type dLast,
const mu::value_type dIncrement,
std::vector< mu::value_type > &  vResults 
)
private

This function expands the vector. Private member used by ParserBase::compileVectorExpansion().

Parameters
dFirstmu::value_type
dLastconst mu::value_type&
dIncrementconst mu::value_type&
vResultsvector<mu::value_type>&
Returns
void

Definition at line 881 of file muParserBase.cpp.

References mu::stepIsStillPossible().

Referenced by evaluateTemporaryVectors().

Here is the call graph for this function:

◆ FindMultiArgFunc()

size_t mu::ParserBase::FindMultiArgFunc ( StringView  sExpr,
size_t  nPos,
std::string &  sMultArgFunc 
)
private

This function searches for the first multi-argument function found in the passed expression.

Parameters
sExprStringView
nPossize_t
sMultArgFuncstd::string& will contain the name of the function
Returns
size_t the position of the opening parenthesis

Definition at line 967 of file muParserBase.cpp.

References StringViewBase::find_last_of(), getMatchingParenthesis(), m_FunDef, StringView::subview(), and StringViewBase::to_string().

Referenced by compileVectorsInMultiArgFunc().

Here is the call graph for this function:

◆ GetArgSep()

char_type mu::ParserBase::GetArgSep ( ) const

Get the argument separator character.

Definition at line 2608 of file muParserBase.cpp.

References m_pTokenReader.

◆ GetCachedAccess()

const CachedDataAccess & mu::ParserBase::GetCachedAccess ( size_t  nthAccess)

Returns the cached data access for the passed position.

Parameters
nthAccesssize_t
Returns
const CachedDataAccess&

Definition at line 3255 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, nthLoopElement, and mu::StateStacks::size().

Referenced by handleCachedDataAccess().

Here is the call graph for this function:

◆ GetCachedEquation()

const std::string & mu::ParserBase::GetCachedEquation ( ) const

Returns the stored equation for this position.

Returns
const std::string&

Definition at line 3286 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, EMPTYSTRING, m_stateStacks, and nthLoopElement.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), getDataElements(), and handleCachedDataAccess().

◆ GetCachedTarget()

const std::string & mu::ParserBase::GetCachedTarget ( ) const

Returns the stored target equation for this position.

Returns
const std::string&

Definition at line 3317 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, EMPTYSTRING, m_stateStacks, and nthLoopElement.

Referenced by handleCachedDataAccess().

◆ GetConst()

const valmap_type & mu::ParserBase::GetConst ( ) const

Return a map containing all parser constants.

Definition at line 1332 of file muParserBase.cpp.

References m_ConstDef.

Referenced by Procedure::getInlined(), and listConstants().

◆ GetExpr()

const string_type & mu::ParserBase::GetExpr ( ) const

Retrieve the formula.

Definition at line 1366 of file muParserBase.cpp.

References g_DbgDumpStack, mu::State::m_expr, m_state, and NumeReKernel::print().

Referenced by IsAlreadyParsed(), localizeExtremum(), localizeZero(), and SetExpr().

Here is the call graph for this function:

◆ GetFunDef()

const funmap_type & mu::ParserBase::GetFunDef ( ) const

Return prototypes of all parser functions.

Returns
m_FunDef
See also
FunProt
Exceptions
nothrow

The return type is a map of the public type funmap_type containing the prototype definitions for all numerical parser functions. String functions are not part of this map. The Prototype definition is encapsulated in objects of the class FunProt one per parser function each associated with function names via a map construct.

Definition at line 1348 of file muParserBase.cpp.

References m_FunDef.

◆ getNextVarObject()

string_type mu::ParserBase::getNextVarObject ( std::string &  sArgList,
bool  bCut 
)
private

This member function returns the next comma-separated expression object from the passed argument list.

Parameters
sArgListstd::string&
bCutbool
Returns
string_type

Definition at line 2723 of file muParserBase.cpp.

◆ getNextVectorVarIndex()

string_type mu::ParserBase::getNextVectorVarIndex ( )
private

This member function returns the next free vector index, which can be used to create a new temporary vector.

Returns
string_type

This function is called by ParserBase::CreateTempVectorVar(), which creates the actual vector.

Definition at line 2804 of file muParserBase.cpp.

References bMakeLoopByteCode, m_lDataStorage, nCurrVectorIndex, nthLoopElement, nthLoopPartEquation, and toString().

Referenced by CreateTempVectorVar().

Here is the call graph for this function:

◆ GetOprtAssociativity()

EOprtAssociativity mu::ParserBase::GetOprtAssociativity ( const token_type a_Tok) const
private

Get operator priority.

Exceptions
ParserExceptionif a_Oprt is no operator code

Definition at line 1272 of file muParserBase.cpp.

References mu::cmADD, mu::cmASSIGN, mu::cmDIV, mu::cmEQ, mu::cmGE, mu::cmGT, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmPOW, mu::cmSUB, mu::ParserToken< TBase, TString >::GetAssociativity(), mu::ParserToken< TBase, TString >::GetCode(), mu::oaLEFT, mu::oaNONE, and mu::oaRIGHT.

Referenced by CreateRPN().

Here is the call graph for this function:

◆ GetOprtDef()

const char_type ** mu::ParserBase::GetOprtDef ( ) const

Get the default symbols used for the built in operators.

See also
c_DefaultOprt

Definition at line 1021 of file muParserBase.cpp.

References c_DefaultOprt.

Referenced by mu::ParserTokenReader::IsBuiltIn(), and mu::ParserTokenReader::IsOprt().

◆ GetOprtPrecedence()

int mu::ParserBase::GetOprtPrecedence ( const token_type a_Tok) const
private

Get operator priority.

Exceptions
ParserExceptionif a_Oprt is no operator code

Definition at line 1224 of file muParserBase.cpp.

References mu::cmADD, mu::cmARG_SEP, mu::cmASSIGN, mu::cmDIV, mu::cmELSE, mu::cmEND, mu::cmEQ, mu::cmGE, mu::cmGT, mu::cmIF, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmPOW, mu::cmSUB, mu::ecINTERNAL_ERROR, Error(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserToken< TBase, TString >::GetPri(), mu::prADD_SUB, mu::prCMP, mu::prLAND, mu::prLOR, mu::prMUL_DIV, and mu::prPOW.

Referenced by CreateRPN().

Here is the call graph for this function:

◆ getTarget()

ExpressionTarget & mu::ParserBase::getTarget ( ) const
private

Simple state-considering wrapper around the ExpressionTarget structure.

Returns
ExpressionTarget&

Definition at line 431 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_compilingTarget, m_stateStacks, and nthLoopElement.

Referenced by compileVectors(), and Eval().

◆ GetUsedVar()

const varmap_type & mu::ParserBase::GetUsedVar ( )

Return a map containing the used variables only.

Definition at line 1301 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by FunctionDefinition::convertToValues(), fitDataSet(), getFittingParameters(), and mu::Test::ParserTester::TestVarConst().

◆ GetVar()

◆ GetVectors()

const std::map< std::string, std::vector< mu::value_type > > & mu::ParserBase::GetVectors ( ) const

Definition at line 1353 of file muParserBase.cpp.

References m_VarDef, and mVectorVars.

Referenced by NumeRe::StringVarFactory::evaluateStringVectors().

◆ GetVectorVar()

std::vector< mu::value_type > * mu::ParserBase::GetVectorVar ( const std::string &  sVarName)

This member function returns a pointer to the vector stored internally.

Parameters
sVarNameconst std::string&
Returns
std::vector<mu::value_type>*

Definition at line 3582 of file muParserBase.cpp.

References mVectorVars.

Referenced by evaluateTemporaryVectors(), and handleCachedDataAccess().

◆ GetVersion()

string_type mu::ParserBase::GetVersion ( EParserVersionInfo  eInfo = pviFULL) const

Returns the version of muparser.

Parameters
eInfoA flag indicating whether the full version info should be returned or not.

Format is as follows: "MAJOR.MINOR (COMPILER_FLAGS)" The COMPILER_FLAGS are returned only if eInfo==pviFULL.

Definition at line 466 of file muParserBase.cpp.

References _nrT, MUP_VERSION, MUP_VERSION_DATE, and mu::pviFULL.

◆ HasBuiltInOprt()

bool mu::ParserBase::HasBuiltInOprt ( ) const

Query status of built in variables.

Returns
m_bBuiltInOp; true if built in operators are enabled.
Exceptions
nothrow

Definition at line 2600 of file muParserBase.cpp.

References m_bBuiltInOp.

Referenced by mu::ParserTokenReader::IsBuiltIn(), and mu::ParserTokenReader::IsOprt().

◆ HasCachedAccess()

size_t mu::ParserBase::HasCachedAccess ( )

Evaluate, whether there are any cached data accesses for this position.

Returns
size_t

Definition at line 3205 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, nthLoopElement, and mu::StateStacks::size().

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), getDataElements(), and handleCachedDataAccess().

Here is the call graph for this function:

◆ Init()

void mu::ParserBase::Init ( )
protected

Initialize user defined functions.

Calls the virtual functions InitFun(), InitConst() and InitOprt().

Definition at line 1102 of file muParserBase.cpp.

References InitCharSets(), InitConst(), InitFun(), and InitOprt().

Here is the call graph for this function:

◆ InitCharSets()

virtual void mu::ParserBase::InitCharSets ( )
protectedpure virtual

Implemented in mu::ParserInt, and mu::Parser.

Referenced by Init().

◆ InitConst()

virtual void mu::ParserBase::InitConst ( )
protectedpure virtual

Implemented in mu::ParserInt, and mu::Parser.

Referenced by Init().

◆ InitFun()

virtual void mu::ParserBase::InitFun ( )
protectedpure virtual

Implemented in mu::ParserInt, and mu::Parser.

Referenced by Init().

◆ InitOprt()

virtual void mu::ParserBase::InitOprt ( )
protectedpure virtual

Implemented in mu::ParserInt, and mu::Parser.

Referenced by Init().

◆ InitTokenReader()

void mu::ParserBase::InitTokenReader ( )
private

Initialize the token reader.

Create new token reader object and submit pointers to function, operator, constant and variable definitions.

Postcondition
m_pTokenReader.get()!=0
Exceptions
nothrow

Definition at line 404 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by ParserBase().

◆ IsAlreadyParsed()

bool mu::ParserBase::IsAlreadyParsed ( StringView  sNewEquation)

This member function checks, whether the passed expression is already parsed, so that the parsing step may be omitted.

Parameters
sNewEquationStringView
Returns
bool

Definition at line 3428 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, GetExpr(), m_state, mu::State::m_valid, and StringViewBase::strip().

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), NumeReKernel::MainLoop(), Procedure::ProcCalc(), and SetExpr().

Here is the call graph for this function:

◆ IsCompiling()

bool mu::ParserBase::IsCompiling ( )

Returns true, if the parser is currently in compiling step.

Returns
bool

Definition at line 3177 of file muParserBase.cpp.

References bCompiling.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), and getDataElements().

◆ IsLockedPause()

bool mu::ParserBase::IsLockedPause ( ) const

Check, whether the pause mode is locked.

Returns
bool

Definition at line 3369 of file muParserBase.cpp.

References bPauseLock.

Referenced by FlowCtrl::eval(), Procedure::ProcCalc(), and FlowCtrl::reset().

◆ IsNotLastStackItem()

bool mu::ParserBase::IsNotLastStackItem ( ) const

Check, whether there are more elements on the parsing stack remaining.

Returns
bool

Definition at line 3448 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, m_stateStacks, nthLoopElement, nthLoopPartEquation, and mu::StateStacks::size().

Referenced by FlowCtrl::calc(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

Here is the call graph for this function:

◆ IsValidByteCode()

int mu::ParserBase::IsValidByteCode ( unsigned int  _nthLoopElement = -1,
unsigned int  _nthPartEquation = 0 
)

This member function returns, whether the current equation is already parsed and there's a valid bytecode for it.

Parameters
_nthLoopElementunsigned int
_nthPartEquationunsigned int
Returns
int

Definition at line 3336 of file muParserBase.cpp.

References bMakeLoopByteCode, m_stateStacks, nthLoopElement, and mu::StateStacks::size().

Referenced by FlowCtrl::compile().

Here is the call graph for this function:

◆ LockPause()

void mu::ParserBase::LockPause ( bool  _bLock = true)

This member function locks the pause mode so that it cannot be accidentally activated.

Parameters
_bLockbool
Returns
void

Definition at line 3384 of file muParserBase.cpp.

References bPauseLock.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

◆ OnDetectVar()

void mu::ParserBase::OnDetectVar ( string_type pExpr,
int &  nStart,
int &  nEnd 
)
protectedvirtual

Reimplemented in mu::Parser.

Definition at line 440 of file muParserBase.cpp.

References GetVar(), mVectorVars, and SetVectorVar().

Referenced by mu::ParserTokenReader::IsVarTok().

Here is the call graph for this function:

◆ operator=()

ParserBase & mu::ParserBase::operator= ( const ParserBase a_Parser)

Assignement operator.

Implemented by calling Assign(a_Parser). Self assignement is suppressed.

Parameters
a_ParserObject to copy to this.
Returns
*this
Exceptions
nothrow

Definition at line 310 of file muParserBase.cpp.

References Assign().

Here is the call graph for this function:

◆ ParseCmdCode()

void mu::ParserBase::ParseCmdCode ( )
private

Parse the command code.

See also
ParseString(...)

Command code contains precalculated stack positions of the values and the associated operators. The Stack is filled beginning from index one the value at index zero is not used at all.

Definition at line 1637 of file muParserBase.cpp.

References ParseCmdCodeBulk().

Referenced by ParseString(), and PauseLoopMode().

Here is the call graph for this function:

◆ ParseCmdCodeBulk()

void mu::ParserBase::ParseCmdCodeBulk ( int  nOffset,
int  nThreadID 
)
private

Evaluate the RPN.

Parameters
nOffsetThe offset added to variable addresses (for bulk mode)
nThreadIDOpenMP Thread id of the calling thread

Definition at line 1647 of file muParserBase.cpp.

References mu::cmADD, mu::cmASSIGN, mu::SToken::Cmd, mu::cmDIV, mu::cmELSE, mu::cmEND, mu::cmENDIF, mu::cmEQ, mu::cmFUNC, mu::cmGE, mu::cmGT, mu::cmIF, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmPOW, mu::cmSUB, mu::cmVAL, mu::cmVAR, mu::cmVARMUL, mu::cmVARPOW2, mu::cmVARPOW3, mu::cmVARPOW4, mu::cmVARPOWN, mu::ecINTERNAL_ERROR, Error(), mu::ParserByteCode::GetBase(), intPower(), mu::State::m_byteCode, mu::State::m_stackBuffer, m_state, nMaxThreads, and mu::MathImpl< T >::Pow().

Referenced by Eval(), and ParseCmdCode().

Here is the call graph for this function:

◆ ParseCmdCodeBulkParallel()

void mu::ParserBase::ParseCmdCodeBulkParallel ( size_t  nVectorLength)
private

OpenMP optimized parallel bytecode executor.

Parameters
nVectorLengthsize_t
Returns
void

Definition at line 1892 of file muParserBase.cpp.

References mu::cmADD, mu::cmASSIGN, mu::SToken::Cmd, mu::cmDIV, mu::cmELSE, mu::cmEND, mu::cmENDIF, mu::cmEQ, mu::cmFUNC, mu::cmGE, mu::cmGT, mu::cmIF, mu::cmLAND, mu::cmLE, mu::cmLOR, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmPOW, mu::cmSUB, mu::cmVAL, mu::cmVAR, mu::cmVARMUL, mu::cmVARPOW2, mu::cmVARPOW3, mu::cmVARPOW4, mu::cmVARPOWN, mu::ecINTERNAL_ERROR, Error(), mu::ParserByteCode::GetBase(), intPower(), m_buffer, mu::State::m_byteCode, mu::State::m_numResults, mu::State::m_stackBuffer, m_state, nMaxThreads, and mu::MathImpl< T >::Pow().

Referenced by Eval().

Here is the call graph for this function:

◆ ParseString()

void mu::ParserBase::ParseString ( )
private

One of the two main parse functions.

See also
ParseCmdCode(...)

Parse expression from input string. Perform syntax checking and create bytecode. After parsing the string and creating the bytecode the function pointer m_pParseFormula will be changed to the second parse routine the uses bytecode instead of string parsing.

Definition at line 2400 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, CreateRPN(), m_compilingState, mu::State::m_expr, m_pParseFormula, m_pTokenReader, m_state, m_stateStacks, mu::State::m_usedVar, nthLoopElement, nthLoopPartEquation, ParseCmdCode(), and StripSpaces().

Referenced by ReInit().

Here is the call graph for this function:

◆ PauseLoopMode()

void mu::ParserBase::PauseLoopMode ( bool  _bPause = true)

This member function pauses the loop mode, so that the new assigned equation does not invalidate already parsed equations.

Parameters
_bPausebool
Returns
void

Definition at line 3399 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, g_DbgDumpStack, m_compilingState, m_pParseFormula, m_state, m_stateStacks, nthLoopElement, nthLoopPartEquation, ParseCmdCode(), NumeReKernel::print(), and toString().

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

Here is the call graph for this function:

◆ ReInit()

void mu::ParserBase::ReInit ( )
private

Reset parser to string parsing mode and clear internal buffers.

Clear bytecode, reset the token reader.

Exceptions
nothrow

Definition at line 415 of file muParserBase.cpp.

References mu::State::clear(), m_compilingState, m_nIfElseCounter, m_pParseFormula, m_pTokenReader, m_vStringBuf, and ParseString().

Referenced by AddCallback(), Assign(), ClearConst(), ClearFun(), ClearInfixOprt(), ClearOprt(), ClearPostfixOprt(), ClearVar(), DefineConst(), DefineStrConst(), DefineVar(), EnableBuiltInOprt(), EnableOptimizer(), RemoveVar(), and SetExpr().

Here is the call graph for this function:

◆ RemoveVar()

void mu::ParserBase::RemoveVar ( const string_type a_strVarName)

Remove a variable from internal storage.

Exceptions
nothrow

Removes a variable if it exists. If the Variable does not exist nothing will be done.

Definition at line 2473 of file muParserBase.cpp.

References m_lDataStorage, m_VarDef, and ReInit().

Referenced by ClearVectorVars(), FlowCtrl::reset(), ProcedureVarFactory::reset(), and mu::Test::ParserTester::TestInterface().

Here is the call graph for this function:

◆ replaceLocalVars()

void mu::ParserBase::replaceLocalVars ( std::string &  sLine)
private

This member function replaces var occurences with the names of local variables.

Parameters
sLinestd::string&
Returns
void

Definition at line 3722 of file muParserBase.cpp.

References checkDelimiter(), and mVarMapPntr.

Referenced by SetExpr().

Here is the call graph for this function:

◆ ResetLocale()

void mu::ParserBase::ResetLocale ( )

Resets the locale.

The default locale used "." as decimal separator, no thousands separator and "," as function argument separator.

Definition at line 389 of file muParserBase.cpp.

References s_locale, and SetArgSep().

Here is the call graph for this function:

◆ SetArgSep()

void mu::ParserBase::SetArgSep ( char_type  cArgSep)

Set argument separator.

Parameters
cArgSepthe argument separator character.

Definition at line 2617 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by ResetLocale().

◆ SetCompiling()

void mu::ParserBase::SetCompiling ( bool  _bCompiling = true)

Activate the compiling step for the parser.

Parameters
_bCompilingbool
Returns
void

Definition at line 3164 of file muParserBase.cpp.

References bCompiling.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), FlowCtrl::evalHeader(), and FlowCtrl::evalRangeBasedHeader().

◆ SetDecSep()

void mu::ParserBase::SetDecSep ( char_type  cDecSep)

Set the decimal separator.

Parameters
cDecSepDecimal separator as a character value.
See also
SetThousandsSep

By default muparser uses the "C" locale. The decimal separator of this locale is overwritten by the one provided here.

Definition at line 363 of file muParserBase.cpp.

References s_locale.

◆ SetExpr()

void mu::ParserBase::SetExpr ( StringView  a_sExpr)

Set the expression. Triggers first time calculation thus the creation of the bytecode and scanning of used variables.

Parameters
a_sExprStringView
Returns
void

Definition at line 616 of file muParserBase.cpp.

References bMakeLoopByteCode, bPauseLoopByteCode, compileVectors(), ContainsVectorVars(), mu::ecMISSING_PARENS, Error(), StringViewBase::find_first_of(), GetExpr(), IsAlreadyParsed(), m_pTokenReader, m_state, mu::State::m_valid, mVarMapPntr, ReInit(), replaceLocalVars(), and StringViewBase::to_string().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), NumeRe::StringFuncHandler::argumentParser(), FlowCtrl::calc(), calculatePercentageAvgAndCreateParserVariables(), Assertion::checkAssertion(), FlowCtrl::compile(), compileVectorExpansion(), compileVectors(), compileVectorsInMultiArgFunc(), Plot::constructDataLegendElement(), FunctionDefinition::convertToValues(), Plot::create2dDrawing(), Plot::create3dDrawing(), createDatagrid(), Plot::createDataLegends(), ProcedureVarFactory::createLocalClusters(), ProcedureVarFactory::createLocalInlineVars(), ProcedureVarFactory::createLocalTables(), ProcedureVarFactory::createLocalVars(), createMatFromLines(), createMatFromLinesFilled(), NumeRe::StringParser::createStringOutput(), Plot::createSubPlotSet(), NumeRe::StringParser::createTerminalOutput(), differentiate(), mu::Test::ParserTester::EqnTestInt(), mu::Test::ParserTester::EqnTestWithVarChange(), NumeRe::StringParser::eval(), FlowCtrl::evalHeader(), evalMatOp(), evalPoints(), FlowCtrl::evalRangeBasedHeader(), NumeRe::StringLogicParser::evalStringLogic(), NumeRe::StringLogicParser::evalStringTernary(), evaluateExpression(), evaluateFittingParams(), evaluateNumerical(), evaluateParameterValues(), ProcedureVarFactory::evaluateProcedureArguments(), Plot::evaluateSubplot(), FlowCtrl::extractFlagsAndIndexVariables(), Plot::fillData(), findExtrema(), findExtremaInData(), findExtremaInMultiResult(), findZeroes(), findZeroesInData(), findZeroesInMultiResult(), Fitcontroller::fitctrl(), fitDataSet(), StringVector::getBooleanVectorized(), getFittingParameters(), getIndices(), StringVector::getNumericalVectorized(), getParameterValue(), getWindow(), handleCasualIndices(), handleIndexVectors(), integrate(), integrate2d(), localizeExtremum(), localizeZero(), NumeReKernel::MainLoop(), NumeRe::StringParser::numToString(), parseArg(), parseCmdArg(), MemoryManager::parseEvery(), CommandLineParser::parseExprAsNumericalValues(), particleSwarmOptimizer(), Plot::Plot(), Procedure::ProcCalc(), readAndParseIntervals(), readAndParseLegacyIntervals(), Interval::refresh(), refreshBoundaries(), replaceEntityOccurence(), PlotData::setParams(), Odesolver::solve(), NumeRe::StringParser::storeStringResults(), NumeRe::StringParser::storeStringToDataObjects(), tableMethod_anova(), tableMethod_binsof(), tableMethod_categories(), tableMethod_categorize(), tableMethod_convert(), tableMethod_counteq(), tableMethod_cov(), tableMethod_index(), tableMethod_pcorr(), tableMethod_rank(), tableMethod_scorr(), tableMethod_typeof(), tableMethod_zscore(), taylor(), mu::Test::ParserTester::TestInterface(), mu::Test::ParserTester::TestVarConst(), and mu::Test::ParserTester::ThrowTest().

Here is the call graph for this function:

◆ SetIndex()

void mu::ParserBase::SetIndex ( unsigned int  _nLoopElement)

Activates the selected position in the internally stored bytecode.

Parameters
_nLoopElementunsigned int
Returns
void

Definition at line 3147 of file muParserBase.cpp.

References m_state, m_stateStacks, nCurrVectorIndex, nthLoopElement, and nthLoopPartEquation.

Referenced by FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), FlowCtrl::for_loop(), FlowCtrl::if_fork(), FlowCtrl::range_based_for_loop(), FlowCtrl::switch_fork(), FlowCtrl::try_catch(), and FlowCtrl::while_loop().

◆ SetThousandsSep()

void mu::ParserBase::SetThousandsSep ( char_type  cThousandsSep = 0)

Sets the thousands operator.

Parameters
cThousandsSepThe thousands separator as a character
See also
SetDecSep

By default muparser uses the "C" locale. The thousands separator of this locale is overwritten by the one provided here.

Definition at line 377 of file muParserBase.cpp.

References s_locale.

◆ SetVarFactory()

void mu::ParserBase::SetVarFactory ( facfun_type  a_pFactory,
void *  pUserData = NULL 
)

Set a function that can create variable pointer for unknown expression variables.

Parameters
a_pFactoryA pointer to the variable factory.
pUserDataA user defined context pointer.

Definition at line 530 of file muParserBase.cpp.

References m_pTokenReader.

Referenced by NumeReKernel::StartUp().

◆ SetVectorVar()

void mu::ParserBase::SetVectorVar ( const std::string &  sVarName,
const std::vector< mu::value_type > &  vVar,
bool  bAddVectorType = false 
)

This member function copies the passed vector into the internal storage referencing it with the passed name.

Parameters
sVarNameconst std::string&
vVarconst std::vector<mu::value_type>&
bAddVectorTypebool
Returns
void

Definition at line 3548 of file muParserBase.cpp.

References DefineVar(), m_lDataStorage, m_VarDef, and mVectorVars.

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), cmd_reload(), compileVectors(), CreateRPN(), CreateTempVectorVar(), evalMatOp(), NumeReKernel::executePlugins(), handleCachedDataAccess(), handleMafDataAccess(), OnDetectVar(), parser_declareDataMatrixValuesForIndices(), parser_declareMatrixReturnValuesForIndices(), Procedure::procedureInterface(), replaceDataEntities(), and Procedure::replaceReturnVal().

Here is the call graph for this function:

◆ StackDump()

void mu::ParserBase::StackDump ( const ParserStack< token_type > &  a_stVal,
const ParserStack< token_type > &  a_stOprt 
) const
private

◆ UpdateVectorVar()

void mu::ParserBase::UpdateVectorVar ( const std::string &  sVarName)

This member function updates the corresponding variable of a vector with the previously newly assigned value.

Parameters
sVarNameconst std::string&
Returns
void

Definition at line 3600 of file muParserBase.cpp.

References GetVar(), and mVectorVars.

Referenced by evaluateTemporaryVectors(), and handleCachedDataAccess().

Here is the call graph for this function:

◆ ValidInfixOprtChars()

const char_type * mu::ParserBase::ValidInfixOprtChars ( ) const

Virtual function that defines the characters allowed in infix operator definitions.

See also
ValidNameChars, ValidOprtChars

Definition at line 1077 of file muParserBase.cpp.

References m_sInfixOprtChars.

Referenced by DefineInfixOprt(), mu::ParserTokenReader::ExtractOperatorToken(), and mu::ParserTokenReader::IsInfixOpTok().

◆ ValidNameChars()

const char_type * mu::ParserBase::ValidNameChars ( ) const

◆ ValidOprtChars()

const char_type * mu::ParserBase::ValidOprtChars ( ) const

Virtual function that defines the characters allowed in operator definitions.

See also
ValidNameChars, #ValidPrefixOprtChars

Definition at line 1067 of file muParserBase.cpp.

References m_sOprtChars.

Referenced by DefineOprt(), DefinePostfixOprt(), and mu::ParserTokenReader::IsPostOpTok().

Friends And Related Function Documentation

◆ ParserTokenReader

friend class ParserTokenReader
friend

Definition at line 71 of file muParserBase.h.

Member Data Documentation

◆ bCompiling

bool mu::ParserBase::bCompiling
private

Definition at line 348 of file muParserBase.h.

Referenced by ActivateLoopMode(), DeactivateLoopMode(), IsCompiling(), and SetCompiling().

◆ bMakeLoopByteCode

◆ bPauseLock

bool mu::ParserBase::bPauseLock
private

Definition at line 347 of file muParserBase.h.

Referenced by IsLockedPause(), LockPause(), and ParserBase().

◆ bPauseLoopByteCode

◆ c_DefaultOprt

const char_type * mu::ParserBase::c_DefaultOprt
staticprotected
Initial value:
=
{
_nrT("<="), _nrT(">="), _nrT("!="),
_nrT("=="), _nrT("<"), _nrT(">"),
_nrT("+"), _nrT("-"), _nrT("*"),
_nrT("/"), _nrT("^"), _nrT("&&"),
_nrT("||"), _nrT("="), _nrT("("),
_nrT(")"), _nrT("?"), _nrT(":"), 0
}
#define _nrT(x)
Activate this option in order to compile with OpenMP support.
Definition: muParserDef.h:62

Identifiers for built in binary operators.

When defining custom binary operators with #AddOprt(...) make sure not to choose names conflicting with these definitions.

Definition at line 227 of file muParserBase.h.

Referenced by DefineOprt(), GetOprtDef(), and StackDump().

◆ EMPTYSTRING

const std::string mu::ParserBase::EMPTYSTRING
private

Definition at line 373 of file muParserBase.h.

Referenced by GetCachedEquation(), and GetCachedTarget().

◆ g_DbgDumpCmdCode

bool mu::ParserBase::g_DbgDumpCmdCode = false
staticprotected

Definition at line 229 of file muParserBase.h.

Referenced by CreateRPN(), and EnableDebugDump().

◆ g_DbgDumpStack

bool mu::ParserBase::g_DbgDumpStack = false
staticprotected

◆ m_bBuiltInOp

bool mu::ParserBase::m_bBuiltInOp
private

Flag that can be used for switching built in operators on and off.

Definition at line 364 of file muParserBase.h.

Referenced by Assign(), DefineOprt(), EnableBuiltInOprt(), and HasBuiltInOprt().

◆ m_buffer

valbuf_type mu::ParserBase::m_buffer
mutableprivate

Definition at line 335 of file muParserBase.h.

Referenced by Eval(), evaluateTemporaryVectors(), and ParseCmdCodeBulkParallel().

◆ m_compilingState

◆ m_compilingTarget

ExpressionTarget mu::ParserBase::m_compilingTarget
mutableprivate

Definition at line 332 of file muParserBase.h.

Referenced by ClearVectorVars(), and getTarget().

◆ m_ConstDef

valmap_type mu::ParserBase::m_ConstDef
private

user constants.

Definition at line 360 of file muParserBase.h.

Referenced by Assign(), ClearConst(), DefineConst(), DefineVar(), GetConst(), and mu::ParserTokenReader::SetParent().

◆ m_FunDef

funmap_type mu::ParserBase::m_FunDef
private

Map of function names and pointers.

Definition at line 356 of file muParserBase.h.

Referenced by AddCallback(), Assign(), ClearFun(), DefineFun(), evaluateTemporaryVectors(), FindMultiArgFunc(), GetFunDef(), and mu::ParserTokenReader::SetParent().

◆ m_InfixOprtDef

funmap_type mu::ParserBase::m_InfixOprtDef
private

unary infix operator.

Definition at line 358 of file muParserBase.h.

Referenced by AddCallback(), Assign(), ClearInfixOprt(), DefineInfixOprt(), and mu::ParserTokenReader::SetParent().

◆ m_lDataStorage

std::list<mu::value_type*> mu::ParserBase::m_lDataStorage
mutable

◆ m_nIfElseCounter

int mu::ParserBase::m_nIfElseCounter
mutableprivate

Internal counter for keeping track of nested if-then-else clauses.

Definition at line 370 of file muParserBase.h.

Referenced by Assign(), CreateRPN(), and ReInit().

◆ m_OprtDef

funmap_type mu::ParserBase::m_OprtDef
private

Binary operator callbacks.

Definition at line 359 of file muParserBase.h.

Referenced by AddCallback(), Assign(), ClearOprt(), DefineOprt(), and mu::ParserTokenReader::SetParent().

◆ m_PostOprtDef

funmap_type mu::ParserBase::m_PostOprtDef
private

Postfix operator callbacks.

Definition at line 357 of file muParserBase.h.

Referenced by AddCallback(), Assign(), ClearPostfixOprt(), DefinePostfixOprt(), and mu::ParserTokenReader::SetParent().

◆ m_pParseFormula

ParseFunction mu::ParserBase::m_pParseFormula
mutableprivate

Pointer to the parser function.

Eval() calls the function whose address is stored there.

Definition at line 330 of file muParserBase.h.

Referenced by Eval(), ParseString(), PauseLoopMode(), and ReInit().

◆ m_pTokenReader

std::unique_ptr<token_reader_type> mu::ParserBase::m_pTokenReader
private

◆ m_sInfixOprtChars

string_type mu::ParserBase::m_sInfixOprtChars
private

Charset for infix operator tokens.

Definition at line 368 of file muParserBase.h.

Referenced by Assign(), DefineInfixOprtChars(), and ValidInfixOprtChars().

◆ m_sNameChars

string_type mu::ParserBase::m_sNameChars
private

Charset for names.

Definition at line 366 of file muParserBase.h.

Referenced by Assign(), DefineNameChars(), and ValidNameChars().

◆ m_sOprtChars

string_type mu::ParserBase::m_sOprtChars
private

Charset for postfix/ binary operator tokens.

Definition at line 367 of file muParserBase.h.

Referenced by Assign(), DefineOprtChars(), and ValidOprtChars().

◆ m_state

◆ m_stateStacks

◆ m_StrVarDef

strmap_type mu::ParserBase::m_StrVarDef
private

user defined string constants

Definition at line 361 of file muParserBase.h.

Referenced by Assign(), ClearConst(), DefineStrConst(), and mu::ParserTokenReader::SetParent().

◆ m_VarDef

varmap_type mu::ParserBase::m_VarDef
private

user defind variables.

Definition at line 362 of file muParserBase.h.

Referenced by Assign(), ClearVar(), DefineVar(), GetVar(), GetVectors(), RemoveVar(), mu::ParserTokenReader::SetParent(), and SetVectorVar().

◆ m_vStringBuf

stringbuf_type mu::ParserBase::m_vStringBuf
mutableprivate

String buffer, used for storing string function arguments.

Definition at line 351 of file muParserBase.h.

Referenced by Assign(), CreateRPN(), DefineStrConst(), mu::ParserTokenReader::IsString(), and ReInit().

◆ m_vStringVarBuf

stringbuf_type mu::ParserBase::m_vStringVarBuf
private

Definition at line 352 of file muParserBase.h.

Referenced by Assign(), DefineStrConst(), and mu::ParserTokenReader::IsStrVarTok().

◆ mVarMapPntr

◆ mVectorVars

vectormap_type mu::ParserBase::mVectorVars
mutableprivate

Maximum number of threads spawned by OpenMP when using the bulk mode.

Definition at line 340 of file muParserBase.h.

Referenced by ClearVectorVars(), compileVectors(), ContainsVectorVars(), CreateRPN(), Eval(), GetVectors(), GetVectorVar(), OnDetectVar(), SetVectorVar(), and UpdateVectorVar().

◆ nCurrVectorIndex

unsigned int mu::ParserBase::nCurrVectorIndex
private

◆ nMaxThreads

int mu::ParserBase::nMaxThreads
private

◆ nthLoopElement

◆ nthLoopPartEquation

unsigned int mu::ParserBase::nthLoopPartEquation
private

◆ s_locale

std::locale mu::ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.'))
staticprotected

The locale used by the parser.

Definition at line 228 of file muParserBase.h.

Referenced by mu::Parser::IsVal(), ResetLocale(), SetDecSep(), and SetThousandsSep().


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