Feature overview
-
Supported data types: double, integer, complex, boolean, string, array
-
Extensible with custom operators (binary, infix or postfix)
-
Extensible with custom functions with an arbitrary number of function arguments
-
Support for an unlimited number of variables and constants
-
No limit on expression complexity
-
Reads binary, hexadecimal, complex, integer and string values from expressions and can be extended to read user defined values as well.
-
Supports a large variety of predefined Predefined Operators, Predefined Functions and Predefined Constants.
Predefined Constants
By default the parser supports the following mathematical constants:
-
The eulerian number with:
e = 2.718281828459045235360287
-
The mathematical constant equal to a circle's circumference divided by its diameter.
pi = 3.141592653589793238462643
-
The imaginary unit with:
i = sqrt(-1)
Predefined Operators
Binary operators:
-
Standard operators:
"+", "-", "*", "/", "^"
-
Assignment operators:
"=", "+=", "-=", "*=", "/="
-
Logical operators:
"and", "or", "xor","==", "!=", ">", "<", "<=", ">="
-
Bit manipulation:
"&", "|", "<<", ">>"
-
String concatenation:
"//"
Postfix operators:
-
Unit postfixes (nano, micro, milli, kilo, giga, mega):
"{n}", "{mu}", "{m}", "{k}", "{G}", "{M}"
Infix operators:
-
Sign operator and type conversions:
"-", "(float)", "(int)"
Predefined Functions
-
Standard functions:
abs, sin, cos, tan, sinh, cosh, tanh, ln, log, log10, exp, sqrt
-
Unlimited number of arguments:
min, max, sum
-
String functions:
str2dbl, strlen, toupper
-
Complex functions:
real, imag, conj, arg, norm
-
Array functions:
sizeof
ECmdCode GetCode() const
return the token code.
Definition: mpIToken.cpp:205
virtual bool IsValue(const char_type *a_szExpr, int &a_iPos, Value &a_fVal)
Try to read a hex value from a given position in the expression.
Definition: mpValReader.cpp:168
Implementation of the parser engine.
Definition: mpParserBase.h:67
std::map< string_type, ptr_tok_type > oprt_ifx_maptype
Type of a map for storing infix operators by their name.
Definition: mpTypes.h:142
bool IsString() const
Returns true if this value is a string value.
Definition: mpIValue.h:172
@ sfALLOW_NONE
All of he above flags set.
Definition: mpTypes.h:240
ParserTester(const ParserTester &a_Obj)
Copy constructor is deactivated.
Definition: mpTest.h:78
Package for installing complex functions and operators.
Definition: mpPackageMatrix.h:45
void Finalize()
Definition: mpRPN.cpp:118
virtual IValueReader * Clone(TokenReader *pParent) const =0
Clone this ValueReader object.
Callback object class for the "Less or equal" operator.
Definition: mpOprtBinCommon.h:119
EErrorCodes Errc
Additional message
Definition: mpError.h:91
int GetPos() const
Return the expression position related to the error.
Definition: mpError.cpp:248
Callback object class for the "Less than" operator.
Definition: mpOprtBinCommon.h:93
@ cmEOE
End of expression.
Definition: mpTypes.h:170
Assignement operator.
Definition: mpOprtBinAssign.h:115
@ ecDIV_BY_ZERO
Division by zero (currently unused)
Definition: mpTypes.h:337
const char_type * g_sCmdCode[]
Strings assigned to the enum codes of ECmdCode.
Definition: mpParserBase.cpp:52
@ noNEWLINE
to avoid i.e. "a+\nb" or "sin(\na)"
Definition: mpTypes.h:237
Parser callback object for returning the real part of a complex number.
Definition: mpFuncCmplx.h:52
virtual bool IsValue(const char_type *a_szExpr, int &a_iPos, Value &a_fVal)
Check a certain position in an expression for the presence of a value.
Definition: mpValReader.cpp:120
@ prMUL_DIV
multiplication/division
Definition: mpTypes.h:280
void DefineConst(const string_type &ident, const Value &val)
Define a parser Constant.
Definition: mpParserBase.cpp:428
The ValueCache class provides a simple mechanism to recycle unused value items.
Definition: mpValueCache.h:54
Base class for Parser Message providing classes.
Definition: mpParserMessageProvider.h:16
Parser function callback for determining the size of an array.
Definition: mpFuncCommon.h:48
@ cmSCRIPT_FOR
Reserved for future use.
Definition: mpTypes.h:179
Definition: mpFuncCmplx.h:129
void ClearOprt()
Clear all user defined binary operators.
Definition: mpParserBase.cpp:1228
void SetParent(parent_type *a_pParent)
Assign a parser object to the callback.
Definition: mpICallback.cpp:106
Definition: mpFuncNonCmplx.h:59
void push(const value_type &a_Val)
Push an object into the stack.
Definition: mpStack.h:111
Namespace containing utility functions and classes for string processing.
Definition: suSortPred.h:40
@ ecOVERFLOW
Overflow (possibly) occurred.
Definition: mpTypes.h:345
@ cmELSE
Ternary if then else operator.
Definition: mpTypes.h:162
Definition: suStringTokens.h:49
@ noCBC
No opening closing bracket.
Definition: mpTypes.h:226
int GetPos() const
Return the current position of the token reader in the formula string.
Definition: mpTokenReader.cpp:205
@ noIFX
to avoid i.e. "++4" "!!4"
Definition: mpTypes.h:233
@ cmBC
Operator item: closing bracket.
Definition: mpTypes.h:155
Definition: mpFuncNonCmplx.h:82
oprt_pfx_maptype m_PostOprtDef
Postfix operator callbacks.
Definition: mpParserBase.h:153
Variable(IValue *pVal)
Create a variable and bind a value to it.
Definition: mpVariable.cpp:51
std::map< string_type, ptr_tok_type > oprt_pfx_maptype
Type of a map for storing postfix operators by their name.
Definition: mpTypes.h:139
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
Definition: mpParserBase.cpp:258
@ ecUNDEFINED
Undefined message, placeholder to detect unassigned error messages.
Definition: mpTypes.h:363
Interface for unary infix operators.
Definition: mpIOprt.h:97
@ ecUNEXPECTED_VAR
An unexpected variable token has been found.
Definition: mpTypes.h:300
Definition: mpFuncNonCmplx.h:97
Definition: mpOprtMatrix.h:71
const val_maptype & GetConst() const
Return a map containing all parser constants.
Definition: mpParserBase.cpp:597
@ noOPT
to avoid i.e. "(+)"
Definition: mpTypes.h:231
value_type & top()
Return reference to the top object in the stack.
Definition: mpStack.h:135
const fun_maptype & GetFunDef() const
Return prototypes of all parser functions.
Definition: mpParserBase.cpp:613
Parse string to a floating point value.
Definition: mpFuncStr.h:83
std::map< string_type, ptr_tok_type > val_maptype
type of a container used to store parser values.
Definition: mpTypes.h:127
virtual void SetParent(TokenReader *pTokenReader)
Assign this value reader object to a token reader object.
Definition: mpIValReader.cpp:59
EErrorCodes
Error codes.
Definition: mpTypes.h:293
Parser callback object for creating unity matrices.
Definition: mpFuncMatrix.h:78
The variable class represents a parser variable.
Definition: mpVariable.h:52
virtual IValueReader * Clone(TokenReader *pTokenReader) const
Clone this ValueReader object.
Definition: mpValReader.cpp:141
@ prPOW
power operator priority (highest)
Definition: mpTypes.h:281
Package for installing complex functions and operators.
Definition: mpPackageNonCmplx.h:45
@ ecUNEXPECTED_CURLY_BRACKET
Invalid use of the index operator.
Definition: mpTypes.h:322
const string_type & GetIdent() const
Return the token identifier string.
Definition: mpIToken.cpp:212
Definition: mpFuncNonCmplx.h:71
Default implementation of a multidimensional index operator.
Definition: mpOprtIndex.h:55
@ cmFUNC
Code for a function item.
Definition: mpTypes.h:166
Parser callback object for returning the complex conjugate of the complex number.
Definition: mpFuncCmplx.h:80
@ cmSCRIPT_IF
Reserved for future use.
Definition: mpTypes.h:180
@ cmSCRIPT_ENDIF
Reserved for future use.
Definition: mpTypes.h:183
IValue * GetPtr() const
Returns the Value pointer bound to this variable.
Definition: mpVariable.cpp:194
Definition: mpFuncNonCmplx.h:68
@ ecCONSTANT_DEFINED
Constant is already defined.
Definition: mpTypes.h:355
const char_type * ValidOprtChars() const
Virtual function that defines the characters allowed in operator definitions.
Definition: mpParserBase.cpp:299
Callback for an operator allowing to cast values to integer values.
Definition: mpOprtBinCommon.h:237
Definition: mpPackageUnit.h:53
Parser function callback for determining the size of an array.
Definition: mpFuncCommon.h:100
Definition: mpFuncCmplx.h:179
bool IsScalar() const
Returns true if the type is not a vector and not a string.
Definition: mpIValue.h:133
Callback for the positive sign operator for noncomplex values.
Definition: mpOprtNonCmplx.h:69
ParserXBase & operator=(const ParserXBase &a_Parser)
Assignement operator.
Definition: mpParserBase.cpp:177
Callback object for implementing the multiplications of noncomplex values.
Definition: mpOprtNonCmplx.h:108
Parser callback object for returning the phase angle (or angular component) of a complex number,...
Definition: mpFuncCmplx.h:95
const var_maptype & GetUsedVar() const
Return a map containing the used variables only.
Definition: mpTokenReader.cpp:223
Definition: mpPackageUnit.h:52
static string_type GetVersion()
Get the version number of muParserX.
Definition: mpParserBase.cpp:629
A class for reading strings from an expression string.
Definition: mpValReader.h:125
Definition: mpFuncNonCmplx.h:95
Interface for binary operators.
Definition: mpIOprt.h:57
@ cmOPRT_POSTFIX
Postfix operator.
Definition: mpTypes.h:169
English versions of parser messages.
Definition: mpParserMessageProvider.h:40
unsigned size() const
Return the number of stored elements.
Definition: mpStack.h:118
void AddValueReader(IValueReader *a_pReader)
Add a value reader object to muParserX.
Definition: mpParserBase.cpp:358
const char_type * ValidNameChars() const
Virtual function that defines the characters allowed in name identifiers.
Definition: mpParserBase.cpp:289
char_type Type2
For type conflicts only! This is the type that was actually found.
Definition: mpError.h:93
@ cmOPRT_INFIX
Infix operator.
Definition: mpTypes.h:168
Definition: mpFuncNonCmplx.h:76
std::istream & console_in()
Encapsulate cin.
Definition: mpTypes.h:397
Definition: mpFuncCmplx.h:200
void ClearVar()
Clear all user defined variables.
Definition: mpParserBase.cpp:1173
@ noBO
to avoid i.e. "cos(7)("
Definition: mpTypes.h:221
@ ecINVALID_FUN_PTR
Invalid callback function pointer.
Definition: mpTypes.h:326
virtual void Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
Returns the minimum value of all values.
Definition: mpFuncCommon.cpp:142
TokenPtr< IToken > ptr_tok_type
Type of a managed pointer storing parser tokens.
Definition: mpTypes.h:71
Definition: mpFuncNonCmplx.h:58
@ prRELATIONAL2
Relational operators "<", "<=", ">", ">=".
Definition: mpTypes.h:274
@ prSHIFT
Shift operators "<<", ">>".
Definition: mpTypes.h:275
Definition: mpFuncNonCmplx.h:75
@ ecUNEXPECTED_OPERATOR
Unexpected binary operator found.
Definition: mpTypes.h:295
std::ostream & console()
Encapsulate cout.
Definition: mpTypes.h:388
@ ecSTRING_EXPECTED
A string function has been called with a different type of argument.
Definition: mpTypes.h:305
ParserXBase()
Default constructor.
Definition: mpParserBase.cpp:108
ECmdCode
Bytecode values.
Definition: mpTypes.h:150
void SetExpr(const string_type &a_sExpr)
Initialize the token Reader.
Definition: mpTokenReader.cpp:234
virtual char_type GetType() const
Returns a character representing the type of the variable.
Definition: mpVariable.cpp:185
@ noPFX
to avoid i.e. "(5!!)" "sin!"
Definition: mpTypes.h:232
@ ecINTERNAL_ERROR
Internal error of any kind.
Definition: mpTypes.h:359
void CheckName(const string_type &a_sName, const string_type &a_CharSet) const
Check if a given name contains invalid characters.
Definition: mpParserBase.cpp:369
const var_maptype & GetExprVar() const
Return a map containing the used variables only.
Definition: mpParserBase.cpp:578
std::map< string_type, ptr_tok_type > var_maptype
type for the parser variable storage.
Definition: mpTypes.h:124
@ cmVAL
value item
Definition: mpTypes.h:165
EOprtAsct
Binary operator associativity values.
Definition: mpTypes.h:246
@ noIO
No opening bracket "[".
Definition: mpTypes.h:223
A class for reading boolean values from an expression string.
Definition: mpValReader.h:72
@ ecMISSING_PARENS
Missing parens. (Example: "3*sin(3")
Definition: mpTypes.h:307
virtual bool IsValue(const char_type *a_szExpr, int &a_iPos, Value &a_fVal)
Check a certain position in an expression for the presence of a value.
Definition: mpValReader.cpp:329
Definition: mpFwdDecl.h:51
@ prRELATIONAL1
For "==", "!=".
Definition: mpTypes.h:273
Callback object for implementing the multiplications of complex values.
Definition: mpOprtCmplx.h:95
const string_type & GetToken() const
Return string related with this token (if available).
Definition: mpError.cpp:255
int int_type
Parser datatype for integer valuse.
Definition: mpTypes.h:97
Package for installing operators and functions which are always present.
Definition: mpPackageCommon.h:47
parent_type * GetParent()
Returns a pointer to the parser object owning this callback.
Definition: mpICallback.cpp:77
string_type::value_type char_type
Character type of the parser.
Definition: mpTypes.h:116
Definition: mpPackageUnit.h:51
Error class of the parser.
Definition: mpError.h:105
Interface for custom value reader objects.
Definition: mpIValReader.h:59
@ ecTOO_FEW_PARAMS
Too few function parameters. (Example: "ite(1<2,2)")
Definition: mpTypes.h:313
Callback class for the shift left operator.
Definition: mpOprtBinCommon.h:197
Definition: mpFuncCmplx.h:230
@ noEND
to avoid unexpected end of expression
Definition: mpTypes.h:234
Definition: mpPackageUnit.h:55
@ cmIO
Operator item: index operator opening.
Definition: mpTypes.h:156
TokenPtr< IValue > ptr_val_type
Type of a managed pointer storing value tokens.
Definition: mpTypes.h:80
bool IsInteger() const
Returns true if this value is a noncomplex integer.
Definition: mpIValue.h:143
@ cmIC
Operator item: index operator closing.
Definition: mpTypes.h:157
Callback object for testing if two values are equal.
Definition: mpOprtBinCommon.h:66
bool IsComplex() const
Returns true if this value is a complex value.
Definition: mpIValue.h:163
@ cmARG_SEP
Operator item: comma.
Definition: mpTypes.h:160
Package for installing unit postfix operators into muParserX.
Definition: mpPackageStr.h:46
@ cmUNKNOWN
uninitialized item
Definition: mpTypes.h:187
Determine maximal value from the parameter list.
Definition: mpFuncCommon.h:61
Parser stack implementation.
Definition: mpStack.h:54
@ prPOSTFIX
Postfix operator priority (currently unused)
Definition: mpTypes.h:285
@ ecUNEXPECTED_PARENS
Unexpected Parenthesis, opening or closing.
Definition: mpTypes.h:301
void ClearFun()
Clear all function definitions.
Definition: mpParserBase.cpp:1196
const char_type ** GetOprtDef() const
Return the strings of all Operator identifiers.
Definition: mpParserBase.cpp:249
double float_type
Parser datatype for floating point value.
Definition: mpTypes.h:94
@ ecTYPE_CONFLICT_FUN
Function argument type conflict.
Definition: mpTypes.h:315
Definition: mpFuncCmplx.h:251
~ParserTester()
Destructor (trivial).
Definition: mpTest.h:75
void DefinePostfixOprt(const TokenPtr< IOprtPostfix > &oprt)
Add a user defined operator.
Definition: mpParserBase.cpp:473
Assignement operator.
Definition: mpOprtBinAssign.h:101
Definition: mpFuncCmplx.h:169
virtual const cmplx_type & GetComplex() const
Returns this value as a complex number.
Definition: mpValue.cpp:662
A class for reading floating point values from an expression string.
Definition: mpValReader.h:54
oprt_ifx_maptype m_InfixOprtDef
Infix operator callbacks.
Definition: mpParserBase.h:154
@ cmCBO
Operator item: curly bracket (opening)
Definition: mpTypes.h:158
@ ecVAL_EXPECTED
A numerical function has been called with a non value type of argument.
Definition: mpTypes.h:306
ESynCodes
Syntax codes.
Definition: mpTypes.h:220
Definition: mpFuncNonCmplx.h:80
Definition: mpFuncNonCmplx.h:74
int Arg
For type conflicts only! This is the type that was expected.
Definition: mpError.h:94
virtual void Eval(ptr_val_type &ret, const ptr_val_type *arg, int argc)
Index operator implementation.
Definition: mpOprtIndex.cpp:53
@ ecUNEXPECTED_EOF
Unexpected end of expression. (Example: "2+sin(")
Definition: mpTypes.h:297
std::ostream & operator<<(std::ostream &a_Stream, const IToken &tok)
Overloaded streaming operator for outputting the value type into an std::ostream.
Definition: mpIToken.cpp:60
@ cmENDIF
Ternary if then else operator.
Definition: mpTypes.h:163
virtual IValueReader * Clone(TokenReader *pTokenReader) const
Clone this ValueReader object.
Definition: mpValReader.cpp:340
~TokenReader()
Destructor (trivial).
Definition: mpTokenReader.cpp:149
virtual IValue & operator*=(const IValue &val)
Assign a value with multiplication.
Definition: mpValue.cpp:528
@ ecUNEXPECTED_FUN
Unexpected function found. (Example: "sin(8)cos(9)")
Definition: mpTypes.h:310
@ cmCBC
Operator item: curly bracket (closing)
Definition: mpTypes.h:159
const char_type * ValidInfixOprtChars() const
Virtual function that defines the characters allowed in infix operator definitions.
Definition: mpParserBase.cpp:309
bool IsMatrix() const
Returns true if this value is an array.
Definition: mpIValue.h:154
Raise x to the power of y.
Definition: mpOprtCmplx.h:121
int GetArgc() const
Returns the m´number of arguments required by this callback.
Definition: mpICallback.cpp:93
Package for installing unit postfix operators into muParserX.
Definition: mpPackageUnit.h:63
Definition: mpFuncCmplx.h:220
@ cmSCRIPT_WHILE
Reserved for future use.
Definition: mpTypes.h:176
@ noCBO
No opening curly bracket.
Definition: mpTypes.h:225
@ ecNOT_AN_ARRAY
Using the index operator on a scalar variable.
Definition: mpTypes.h:320
EErrorCodes GetCode() const
Return the error code.
Definition: mpError.cpp:262
@ ecTYPE_CONFLICT
Generic type conflict.
Definition: mpTypes.h:314
ErrorContext(EErrorCodes a_iErrc=ecUNDEFINED, int a_iPos=-1, string_type a_sIdent=string_type())
Creates an empty ErrorContext object.
Definition: mpError.cpp:87
Definition: mpFuncNonCmplx.h:64
TokenReader * Clone(ParserXBase *a_pParent) const
Create instance of a ParserTokenReader identical with this and return its pointer.
Definition: mpTokenReader.cpp:173
Value class of muParserX.
Definition: mpValue.h:56
std::string string_type
Parser datatype for strings.
Definition: mpTypes.h:113
Definition: mpPackageUnit.h:56
void ReInit()
Reset the token reader to the start of the formula.
Definition: mpTokenReader.cpp:249
void ClearConst()
Clear all user defined constants.
Definition: mpParserBase.cpp:1208
@ ecCOUNT
This is no error code, It just stores just the total number of error codes.
Definition: mpTypes.h:362
std::map< string_type, ptr_tok_type, su::pred::SortByLength< string_type > > oprt_bin_maptype
Type of a container that binds Callback object pointer to operator identifiers.
Definition: mpTypes.h:136
Convert a string to upper case letters.
Definition: mpFuncStr.h:57
Calculate factorial of a non-negative integer.
Definition: mpOprtPostfixCommon.h:25
@ ecASSIGNEMENT_TO_VALUE
Assignment to operator (3=4 instead of a=4)
Definition: mpTypes.h:333
@ noBC
to avoid i.e. "sin)" or "()"
Definition: mpTypes.h:222
int GetDim() const
Returns the dimension of the value represented by a value object.
Definition: mpIValue.h:111
A class for encapsulation if-then-else tokens.
Definition: mpIfThenElse.h:52
Namespace for mathematical applications.
Definition: mpError.cpp:36
const string_type & GetExpr() const
Retrieve the mathematical expression.
Definition: mpParserBase.cpp:620
@ cmSCRIPT_GOTO
Reserved for future use.
Definition: mpTypes.h:177
virtual char_type GetType() const
Returns a character representing the type of this value instance.
Definition: mpValue.cpp:578
Raise x to the power of y.
Definition: mpOprtNonCmplx.h:134
Package for installing complex functions and operators.
Definition: mpPackageCmplx.h:45
std::map< string_type, ptr_tok_type > fun_maptype
Type of a container that binds Callback object pointer to operator identifiers.
Definition: mpTypes.h:131
@ ecUNTERMINATED_STRING
unterminated string constant. (Example: "3*valueof("hello)")
Definition: mpTypes.h:311
@ ecUNEXPECTED_COMMA
An unexpected comma has been found. (Example: "1,23")
Definition: mpTypes.h:298
Parser callback object for creating matrices consisting entirely of zeros.
Definition: mpFuncMatrix.h:64
void DefineOprt(const TokenPtr< IOprtBin > &oprt)
Define a binary operator.
Definition: mpParserBase.cpp:458
virtual bool IsValue(const char_type *a_szExpr, int &a_iPos, Value &a_Val)=0
Check a certain position in an expression for the presence of a value.
virtual ~ParserXBase()
Destructor.
Definition: mpParserBase.cpp:160
bool IsNonComplexScalar() const
Returns true if the type is either floating point or interger.
Definition: mpIValue.h:123
@ ecGENERIC
Generic error.
Definition: mpTypes.h:338
@ ecINVALID_PARAMETER
Invalid function parameter.
Definition: mpTypes.h:328
Interface for callback objects.
Definition: mpICallback.h:54
Callback class for a logical or operator.
Definition: mpOprtBinCommon.h:171
Assignement operator.
Definition: mpOprtBinAssign.h:87
@ cmIF
Ternary if then else operator.
Definition: mpTypes.h:161
Returns percentage of given number.
Definition: mpOprtPostfixCommon.h:40
static void EnableDebugDump(bool bDumpCmd, bool bDumpRPN)
Enable the dumping of bytecode amd stack content on the console.
Definition: mpParserBase.cpp:1263
Sort two strings based on their length.
Definition: suSortPred.h:48
A class representing the reverse polnish notation of the expression.
Definition: mpRPN.h:46
A class for reading hex values from an expression string.
Definition: mpValReader.h:90
Parser callback object for returning the norm value of the complex number phase angle.
Definition: mpFuncCmplx.h:109
Definition: mpOprtBinCommon.h:53
@ noIC
No closing bracket "]".
Definition: mpTypes.h:224
fun_maptype m_FunDef
Function definitions.
Definition: mpParserBase.h:152
Definition: mpFuncNonCmplx.h:72
Callback class for a logical and operator.
Definition: mpOprtBinCommon.h:184
Definition: mpFuncCmplx.h:149
@ ecINVALID_TYPECAST
Invalid Value token cast.
Definition: mpTypes.h:318
Callback object for implementing the division of complex values.
Definition: mpOprtCmplx.h:108
Callback object for testing if two values are not equal.
Definition: mpOprtBinCommon.h:80
Definition: mpFuncCmplx.h:119
@ noFUN
to avoid i.e. "sqrt cos" or "(1)sin"
Definition: mpTypes.h:230
Definition: mpFuncCmplx.h:159
void SetExpr(const string_type &a_sExpr)
Set the mathematical expression.
Definition: mpParserBase.cpp:388
Definition: mpMatrixError.h:41
A class for encapsulation a newline token.
Definition: mpScriptTokens.h:47
Definition: mpFuncNonCmplx.h:70
var_maptype m_varDef
user defind variables.
Definition: mpParserBase.h:157
Definition: utGeneric.h:39
Definition: mpFuncNonCmplx.h:67
void DefineOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of binary operators and postfix operators.
Definition: mpParserBase.cpp:269
void ClearInfixOprt()
Clear the user defined Prefix operators.
Definition: mpParserBase.cpp:1238
virtual void Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int)
Implements the Division operator.
Definition: mpOprtNonCmplx.cpp:353
@ noVAL
to avoid i.e. "tan 2" or "sin(8)3.14"
Definition: mpTypes.h:227
Definition: mpOprtMatrix.h:49
Parser callback for implementing an addition of two noncomplex values.
Definition: mpOprtNonCmplx.h:82
Callback object for determining the length of a string.
Definition: mpFuncStr.h:44
Definition: suStringTokens.h:69
Value(char_type cType='v')
Construct an empty value object of a given type.
Definition: mpValue.cpp:44
Parser callback for implementing the subtraction of two complex values.
Definition: mpOprtCmplx.h:82
Token reader for the ParserXBase class.
Definition: mpTokenReader.h:58
The parser implementation.
Definition: mpParser.h:53
@ ecINDEX_OUT_OF_BOUNDS
Array index is out of bounds.
Definition: mpTypes.h:340
Convert a string to lower case letters.
Definition: mpFuncStr.h:70
Definition: mpFuncNonCmplx.h:79
const IValue & Eval() const
Evaluate the expression.
Definition: mpParserBase.cpp:237
Assignement operator.
Definition: mpOprtBinAssign.h:57
@ ecNAME_CONFLICT
Name conflict.
Definition: mpTypes.h:331
@ prCOLON
Colon operator.
Definition: mpTypes.h:277
@ ecUNEXPECTED_SQR_BRACKET
Invalid use of the index operator.
Definition: mpTypes.h:321
EOprtPrecedence
Parser operator precedence values.
Definition: mpTypes.h:258
Definition: mpFuncNonCmplx.h:66
@ cmSCRIPT_NEWLINE
Newline.
Definition: mpTypes.h:174
string_type Ident
The expression string.
Definition: mpError.h:89
@ ecINVALID_NAME
Invalid function, variable or constant name.
Definition: mpTypes.h:324
virtual int_type GetInteger() const
Return the value as an integer.
Definition: mpValue.cpp:590
int Pos
The number of arguments that were expected.
Definition: mpError.h:95
char_type Type1
The error code
Definition: mpError.h:92
Error context class.
Definition: mpError.h:72
@ cmSCRIPT_ELSEIF
Reserved for future use.
Definition: mpTypes.h:182
@ ecBUILTIN_OVERLOAD
Trying to overload builtin operator.
Definition: mpTypes.h:325
German versions of parser messages.
Definition: mpParserMessageProvider.h:51
@ ecTYPE_CONFLICT_IDX
Function argument type conflict.
Definition: mpTypes.h:316
Callback for the negative sign operator for noncomplex values.
Definition: mpOprtNonCmplx.h:56
void AddPackage(IPackage *p)
Adds a new package to the parser.
Definition: mpParserBase.cpp:349
ptr_tok_type ReadNextToken()
Read the next token from the string.
Definition: mpTokenReader.cpp:300
Callback object for implementing the division of noncomplex values.
Definition: mpOprtNonCmplx.h:121
Interface for unary postfix operators.
Definition: mpIOprt.h:83
@ cmJMP
Reserved for future use.
Definition: mpTypes.h:164
@ noVAR
to avoid i.e. "sin a" or "sin(8)a"
Definition: mpTypes.h:228
@ cmOPRT_BIN
Binary operator.
Definition: mpTypes.h:167
Definition: mpFuncCmplx.h:240
std::vector< ptr_val_type > val_vec_type
Type for a vector of value items.
Definition: mpTypes.h:89
Definition: mpFuncNonCmplx.h:98
@ ecVARIABLE_DEFINED
Variable is already defined.
Definition: mpTypes.h:354
Determines the dimensions of a matrix.
Definition: mpFuncMatrix.h:93
bool bool_type
Parser boolean datatype.
Definition: mpTypes.h:107
Parser callback for implementing an addition of two complex values.
Definition: mpOprtCmplx.h:69
@ ecFUNOPRT_DEFINED
Function/operator is already defined.
Definition: mpTypes.h:356
virtual void Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
Returns the minimum value of all values.
Definition: mpFuncCommon.cpp:198
Callback class for a logic or operator.
Definition: mpOprtBinCommon.h:158
Definition: mpFuncCmplx.h:139
Callback class for the shift right operator.
Definition: mpOprtBinCommon.h:210
@ cmSCRIPT_LABEL
Reserved for future use.
Definition: mpTypes.h:178
virtual void Eval(ptr_val_type &ret, const ptr_val_type *arg, int argc)
Index operator implementation.
Definition: mpOprtMatrix.cpp:88
@ ecMISSING_SQR_BRACKET
The index operator was not closed properly (i.e. "v[3")
Definition: mpTypes.h:342
A class for reading binary values from an expression string.
Definition: mpValReader.h:107
std::vector< IValueReader * > readervec_type
Type of a vector holding pointers to value reader objects.
Definition: mpTypes.h:121
bool empty() const
Returns true if stack is empty false otherwise.
Definition: mpStack.h:125
@ ecUNASSIGNABLE_TOKEN
Token cant be identified.
Definition: mpTypes.h:296
Test cases for unit testing the parser framework.
Definition: mpTest.h:45
std::complex< float_type > cmplx_type
The basic type used for representing complex numbers.
Definition: mpTypes.h:100
@ cmCOUNT
Dummy entry for counting the enum values.
Definition: mpTypes.h:188
@ cmSCRIPT_ELSE
Reserved for future use.
Definition: mpTypes.h:181
Default token implentation.
Definition: mpIToken.h:138
@ cmSCRIPT_FUNCTION
Reserved for future use.
Definition: mpTypes.h:184
oprt_bin_maptype m_OprtDef
Binary operator callbacks.
Definition: mpParserBase.h:155
On the fly array creation using the curly bracket operator.
Definition: mpOprtMatrix.h:61
virtual void Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int a_iArgc)
Returns the number of elements stored in the first parameter.
Definition: mpFuncCommon.cpp:254
void DefineInfixOprt(const TokenPtr< IOprtInfix > &oprt)
Add a user defined operator.
Definition: mpParserBase.cpp:488
@ ecARRAY_SIZE_MISMATCH
Array size mismatch during a vector operation.
Definition: mpTypes.h:319
void Reset(token_type tok)
Release the managed pointer and assign a new pointer.
Definition: mpIToken.h:200
value_type pop()
Pop a value from the stack.
Definition: mpStack.h:89
Definition: mpFuncNonCmplx.h:63
Parser callback for summing up all function arguments.
Definition: mpFuncCommon.h:87
Parser callback object for creating matrices consisting entirely of ones.
Definition: mpFuncMatrix.h:49
val_maptype m_valDef
Definition of parser constants.
Definition: mpParserBase.h:156
Parser callback object for returning the imaginary part of a complex number.
Definition: mpFuncCmplx.h:66
Definition: mpMatrix.h:48
virtual IValueReader * Clone(TokenReader *pTokenReader) const
Clone this ValueReader object.
Definition: mpValReader.cpp:254
@ prADD_SUB
addition
Definition: mpTypes.h:279
Definition: mpFuncNonCmplx.h:96
Interface for binary and ternary operators.
Definition: mpIPrecedence.h:52
Definition: mpFuncCmplx.h:190
@ ecTOO_MANY_PARAMS
Too many function parameters.
Definition: mpTypes.h:312
Definition: mpFuncNonCmplx.h:60
@ ecINVALID_VAR_PTR
Invalid variable pointer.
Definition: mpTypes.h:327
@ ecOPT_PRI
Invalid operator priority.
Definition: mpTypes.h:332
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
Definition: mpParserBase.cpp:280
Callback object class for the "Greater or or equal" operator.
Definition: mpOprtBinCommon.h:132
Callback for an operator allowing to cast values to floating point values.
Definition: mpOprtBinCommon.h:224
Callback object class for the "Greater than" operator.
Definition: mpOprtBinCommon.h:106
virtual IValueReader * Clone(TokenReader *pTokenReader) const
Clone this ValueReader object.
Definition: mpValReader.cpp:201
Callback for the negative sign operator.
Definition: mpOprtCmplx.h:56
Definition: mpFuncNonCmplx.h:62
Assignement operator.
Definition: mpOprtBinAssign.h:73
Definition: mpFuncNonCmplx.h:99
Definition: mpIPackage.h:47
@ prINFIX
Signs have a higher priority than ADD_SUB, but lower than power operator.
Definition: mpTypes.h:284
@ noCOMMA
to avoid i.e. ",," or "+," ...
Definition: mpTypes.h:229
string_type Hint
The identifier of the token that caused the error.
Definition: mpError.h:90
@ ecEVAL
Error while evaluating function / operator.
Definition: mpTypes.h:344
virtual void Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int)
Implements the Division operator.
Definition: mpOprtCmplx.cpp:252
std::vector< ptr_tok_type > token_vec_type
Type for a vector of tokens.
Definition: mpTypes.h:86
void ClearPostfixOprt()
Clear all user defined postfix operators.
Definition: mpParserBase.cpp:1218
Determine minimal value from the parameter list.
Definition: mpFuncCommon.h:74
@ ecUNEXPECTED_VAL
An unexpected value token has been found.
Definition: mpTypes.h:299
void DefineFun(const ptr_cal_type &fun)
Add a callback object to the parser.
Definition: mpParserBase.cpp:445
const string_type & GetExpr() const
Return a reference to the formula.
Definition: mpTokenReader.cpp:216
const var_maptype & GetVar() const
Return a map containing the used variables only.
Definition: mpParserBase.cpp:590
Interface to be implemented by all classes representing values.
Definition: mpIValue.h:53
Generic token interface for expression tokens.
Definition: mpIToken.h:55
virtual float_type GetImag() const
Get the imaginary part of the value.
Definition: mpValue.cpp:628
void DefineVar(const string_type &ident, const Variable &var)
Add a user defined variable.
Definition: mpParserBase.cpp:399
@ ecUNEXPECTED_STR
A string has been found at an inapropriate position.
Definition: mpTypes.h:302
Definition: mpFuncCmplx.h:210
Definition: mpFuncNonCmplx.h:81
@ ecDOMAIN_ERROR
Trying to use func/oprtr with out-of-domain input args.
Definition: mpTypes.h:336
Definition: mpPackageUnit.h:54
Definition: mpFuncNonCmplx.h:77
virtual bool IsValue(const char_type *a_szExpr, int &a_iPos, Value &a_fVal)
Check a certain position in an expression for the presence of a value.
Definition: mpValReader.cpp:223
Callback class for a logic and operator.
Definition: mpOprtBinCommon.h:145
Parser callback for implementing the subtraction of two noncomplex values.
Definition: mpOprtNonCmplx.h:95
@ cmBO
Operator item: opening bracket.
Definition: mpTypes.h:154
Matrix< Value > matrix_type
The parsers underlying matrix type.
Definition: mpTypes.h:110