#include <muParserBase.h>
Public Types | |
typedef ParserError | exception_type |
Type of the error class. | |
Public Member Functions | |
ParserBase () | |
Constructor. | |
ParserBase (const ParserBase &a_Parser) | |
ParserBase & | operator= (const ParserBase &a_Parser) |
Assignement operator. | |
value_type | Eval () const |
Calculate the result. | |
void | SetExpr (const string_type &a_sExpr) |
Set the formula. | |
void | SetVarFactory (facfun_type a_pFactory, void *pUserData=NULL) |
void | EnableOptimizer (bool a_bIsOn=true) |
Enable or disable the formula optimization feature. | |
void | EnableByteCode (bool a_bIsOn=true) |
Enable or disable parsing from Bytecode. | |
void | EnableBuiltInOprt (bool a_bIsOn=true) |
Enable or disable the built in binary operators. | |
bool | HasBuiltInOprt () const |
Query status of built in variables. | |
void | AddValIdent (identfun_type a_pCallback) |
void | DefineOprt (const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, bool a_bAllowOpt=false) |
Define a binary operator. | |
void | DefineConst (const string_type &a_sName, value_type a_fVal) |
Add a user defined constant. | |
void | DefineStrConst (const string_type &a_sName, const string_type &a_strVal) |
Define a new string constant. | |
void | DefineVar (const string_type &a_sName, value_type *a_fVar) |
Add a user defined variable. | |
void | DefinePostfixOprt (const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true) |
Add a user defined operator. | |
void | DefineInfixOprt (const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true) |
Add a user defined operator. | |
void | ClearVar () |
Clear all user defined variables. | |
void | ClearFun () |
Clear all functions. | |
void | ClearConst () |
Clear all user defined constants. | |
void | ClearInfixOprt () |
Clear the user defined Prefix operators. | |
void | ClearPostfixOprt () |
Clear all user defined postfix operators. | |
void | ClearOprt () |
Clear all user defined binary operators. | |
void | RemoveVar (const string_type &a_strVarName) |
Remove a variable from internal storage. | |
const varmap_type & | GetUsedVar () const |
Return a map containing the used variables only. | |
const varmap_type & | GetVar () const |
Return a map containing the used variables only. | |
const valmap_type & | GetConst () const |
Return a map containing all parser constants. | |
const string_type & | GetExpr () const |
Retrieve the formula. | |
const funmap_type & | GetFunDef () const |
Return prototypes of all parser functions. | |
const char_type ** | GetOprtDef () const |
Get the default symbols used for the built in operators. | |
void | DefineNameChars (const char_type *a_szCharset) |
Define the set of valid characters to be used in names of functions, variables, constants. | |
void | DefineOprtChars (const char_type *a_szCharset) |
Define the set of valid characters to be used in names of binary operators and postfix operators. | |
void | DefineInfixOprtChars (const char_type *a_szCharset) |
Define the set of valid characters to be used in names of infix operators. | |
const char_type * | ValidNameChars () const |
Virtual function that defines the characters allowed in name identifiers. | |
const char_type * | ValidOprtChars () const |
Virtual function that defines the characters allowed in operator definitions. | |
const char_type * | ValidInfixOprtChars () const |
Virtual function that defines the characters allowed in infix operator definitions. | |
void | SetArgSep (char_type cArgSep) |
Set argument separator. | |
char_type | GetArgSep () const |
Get the argument separator character. | |
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. | |
Protected Member Functions | |
void | Init () |
Initialize user defined functions. | |
virtual void | InitCharSets ()=0 |
virtual void | InitFun ()=0 |
virtual void | InitConst ()=0 |
virtual void | InitOprt ()=0 |
Static Protected Attributes | |
static char_type * | c_DefaultOprt [] |
Identifiers for built in binary operators. | |
Private Types | |
typedef value_type(ParserBase::* | ParseFunction )() const |
Typedef for the parse functions. | |
typedef std::vector< string_type > | stringbuf_type |
Type for a vector of strings. | |
typedef ParserTokenReader | token_reader_type |
Typedef for the token reader. | |
typedef ParserToken < value_type, string_type > | token_type |
Type used for parser tokens. | |
Private Member Functions | |
void | Assign (const ParserBase &a_Parser) |
Copy state of a parser object to this. | |
void | InitTokenReader () |
Initialize the token reader. | |
void | ReInit () const |
Reset parser to string parsing mode and clear internal buffers. | |
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. | |
void | ApplyBinOprt (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. | |
token_type | ApplyNumFunc (const token_type &a_FunTok, const std::vector< token_type > &a_vArg) const |
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. | |
int | GetOprtPri (const token_type &a_Tok) const |
Get operator priority. | |
value_type | ParseString () const |
One of the two main parse functions. | |
value_type | ParseCmdCode () const |
Parse the command code. | |
value_type | ParseValue () const |
Return result for constant functions. | |
void | ClearFormula () |
Clear the formula. | |
void | CheckName (const string_type &a_strName, const string_type &a_CharSet) const |
Check if a name contains invalid characters. | |
Private Attributes | |
ParseFunction | m_pParseFormula |
Pointer to the parser function. | |
const ParserByteCode::map_type * | m_pCmdCode |
Formula converted to bytecode, points to the data of the bytecode class. | |
ParserByteCode | m_vByteCode |
The Bytecode class. | |
stringbuf_type | m_vStringBuf |
String buffer, used for storing string function arguments. | |
stringbuf_type | m_vStringVarBuf |
std::auto_ptr< token_reader_type > | m_pTokenReader |
Managed pointer to the token reader object. | |
funmap_type | m_FunDef |
Map of function names and pointers. | |
funmap_type | m_PostOprtDef |
Postfix operator callbacks. | |
funmap_type | m_InfixOprtDef |
unary infix operator. | |
funmap_type | m_OprtDef |
Binary operator callbacks. | |
valmap_type | m_ConstDef |
user constants. | |
strmap_type | m_StrVarDef |
user defined string constants | |
varmap_type | m_VarDef |
user defind variables. | |
bool | m_bOptimize |
Flag that indicates if the optimizer is on or off. | |
bool | m_bUseByteCode |
Flag that indicates if bytecode parsing is on or off. | |
bool | m_bBuiltInOp |
Flag that can be used for switching built in operators on and off. | |
string_type | m_sNameChars |
Charset for names. | |
string_type | m_sOprtChars |
Charset for postfix/ binary operator tokens. | |
string_type | m_sInfixOprtChars |
Charset for infix operator tokens. | |
Friends | |
class | ParserTokenReader |
Version 1.30 (20080413)
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.
list_expr_var.cpp, and listvar.cpp.
typedef value_type(ParserBase::* mu::ParserBase::ParseFunction)() const [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)
Type of the error class.
Included for backwards compatibility.
mu::ParserBase::ParserBase | ( | ) |
Constructor.
a_szFormula | the formula to interpret. |
ParserException | if a_szFormula is null. |
References InitTokenReader().
ParserBase & mu::ParserBase::operator= | ( | const ParserBase & | a_Parser | ) |
Assignement operator.
Implemented by calling Assign(a_Parser). Self assignement is suppressed.
a_Parser | Object to copy to this. |
nothrow |
References Assign().
value_type mu::ParserBase::Eval | ( | ) | const [inline] |
Calculate the result.
A note on const correctness: I consider it important that Calc is a const function. Due to caching operations Calc changes only the state of internal variables with one exception m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making Calc non const GetUsedVar is non const because it explicitely calls Eval() forcing this update.
Variables must have been set (if needed)
ParseException | if no Formula is set or in case of any other error related to the formula. |
References m_pParseFormula.
Referenced by mu::Parser::Diff(), mu::Test::ParserTester::EqnTest(), and mu::Test::ParserTester::TestVolatile().
void mu::ParserBase::SetExpr | ( | const string_type & | a_sExpr | ) |
Set the formula.
a_strFormula | Formula as string_type |
ParserException | in case of syntax errors. |
References mu::ecLOCALE, Error(), m_pTokenReader, and ReInit().
Referenced by mu::Test::ParserTester::EqnTest(), and mu::Test::ParserTester::TestVolatile().
void mu::ParserBase::EnableOptimizer | ( | bool | a_bIsOn = true |
) |
Enable or disable the formula optimization feature.
nothrow |
References m_bOptimize, and ReInit().
Referenced by mu::Test::ParserTester::EqnTest().
void mu::ParserBase::EnableByteCode | ( | bool | a_bIsOn = true |
) |
Enable or disable parsing from Bytecode.
References m_bUseByteCode, and ReInit().
void mu::ParserBase::EnableBuiltInOprt | ( | bool | a_bIsOn = true |
) |
Enable or disable the built in binary operators.
nothrow |
References m_bBuiltInOp, and ReInit().
Referenced by mu::ParserInt::InitOprt(), mu::ParserComplex::InitOprt(), and mu::Test::ParserTester::TestNames().
bool mu::ParserBase::HasBuiltInOprt | ( | ) | const |
Query status of built in variables.
nothrow |
References m_bBuiltInOp.
Referenced by mu::ParserTokenReader::IsBuiltIn().
void mu::ParserBase::DefineOprt | ( | const string_type & | a_sName, | |
fun_type2 | a_pFun, | |||
unsigned | a_iPrec = 0 , |
|||
bool | a_bAllowOpt = false | |||
) |
Define a binary operator.
[in] | a_pFun | Pointer to the callback function. |
[in] | a_iPrec | Precedence of the operator. |
[in] | a_bAllowOpt | If this is true the operator may be optimized away. |
References AddCallback(), c_DefaultOprt, mu::cmARG_SEP, mu::cmOPRT_BIN, mu::ecBUILTIN_OVERLOAD, Error(), m_bBuiltInOp, m_OprtDef, and ValidOprtChars().
Referenced by mu::ParserInt::InitOprt(), and mu::ParserComplex::InitOprt().
void mu::ParserBase::DefineConst | ( | const string_type & | a_sName, | |
value_type | a_fVal | |||
) |
Add a user defined constant.
[in] | a_sName | The name of the constant. |
[in] | a_fVal | the value of the constant. |
ParserException | in case the name contains invalid signs. |
References CheckName(), m_ConstDef, ReInit(), and ValidNameChars().
Referenced by mu::Test::ParserTester::EqnTest(), and mu::Parser::InitConst().
void mu::ParserBase::DefineStrConst | ( | const string_type & | a_strName, | |
const string_type & | a_strVal | |||
) |
Define a new string constant.
[in] | a_strName | The name of the constant. |
[in] | a_strVal | the value of the constant. |
References CheckName(), mu::ecNAME_CONFLICT, Error(), m_StrVarDef, m_vStringBuf, ReInit(), and ValidNameChars().
void mu::ParserBase::DefineVar | ( | const string_type & | a_sName, | |
value_type * | a_pVar | |||
) |
Add a user defined variable.
[in] | a_sName | the variable name |
[in] | a_pVar | A pointer to the variable vaule. |
ParserException | in case the name contains invalid signs. |
References CheckName(), mu::ecINVALID_VAR_PTR, mu::ecNAME_CONFLICT, Error(), m_ConstDef, m_FunDef, m_VarDef, ReInit(), and ValidNameChars().
Referenced by mu::Test::ParserTester::EqnTest().
void mu::ParserBase::DefinePostfixOprt | ( | const string_type & | a_sName, | |
fun_type1 | a_pFun, | |||
bool | a_bAllowOpt = true | |||
) |
Add a user defined operator.
References AddCallback(), mu::cmOPRT_POSTFIX, m_PostOprtDef, mu::prPOSTFIX, and ValidOprtChars().
Referenced by mu::Test::ParserTester::EqnTest().
void mu::ParserBase::DefineInfixOprt | ( | const string_type & | a_sName, | |
fun_type1 | a_pFun, | |||
int | a_iPrec = prINFIX , |
|||
bool | a_bAllowOpt = true | |||
) |
Add a user defined operator.
[in] | a_sName | operator Identifier |
[in] | a_pFun | Operator callback function |
[in] | a_iPrec | Operator Precedence (default=prSIGN) |
[in] | a_bAllowOpt | True if operator is volatile (default=false) |
References AddCallback(), mu::cmOPRT_INFIX, m_InfixOprtDef, and ValidOprtChars().
Referenced by mu::Test::ParserTester::EqnTest(), mu::ParserInt::InitOprt(), mu::ParserComplex::InitOprt(), and mu::Parser::InitOprt().
void mu::ParserBase::ClearVar | ( | ) |
void mu::ParserBase::ClearFun | ( | ) |
void mu::ParserBase::ClearConst | ( | ) |
Clear all user defined constants.
Both numeric and string constants will be removed from the internal storage.
nothrow |
References m_ConstDef, m_StrVarDef, and ReInit().
Referenced by mu::Test::ParserTester::TestNames().
void mu::ParserBase::ClearInfixOprt | ( | ) |
Clear the user defined Prefix operators.
nothrow |
References m_InfixOprtDef, and ReInit().
void mu::ParserBase::ClearPostfixOprt | ( | ) |
Clear all user defined postfix operators.
nothrow |
References m_PostOprtDef, and ReInit().
void mu::ParserBase::ClearOprt | ( | ) |
void mu::ParserBase::RemoveVar | ( | const string_type & | a_strVarName | ) |
const funmap_type & mu::ParserBase::GetFunDef | ( | ) | const |
Return prototypes of all parser functions.
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. |
References m_FunDef.
const char_type ** mu::ParserBase::GetOprtDef | ( | ) | const |
Get the default symbols used for the built in operators.
References c_DefaultOprt.
Referenced by mu::ParserTokenReader::IsBuiltIn().
const char_type * mu::ParserBase::ValidNameChars | ( | ) | const |
Virtual function that defines the characters allowed in name identifiers.
References m_sNameChars.
Referenced by DefineConst(), DefineStrConst(), DefineVar(), mu::ParserTokenReader::IsFunTok(), mu::ParserTokenReader::IsUndefVarTok(), mu::ParserTokenReader::IsValTok(), mu::ParserTokenReader::IsVarTok(), and mu::ParserTokenReader::ReadNextToken().
const char_type * mu::ParserBase::ValidOprtChars | ( | ) | const |
Virtual function that defines the characters allowed in operator definitions.
References m_sOprtChars.
Referenced by DefineInfixOprt(), DefineOprt(), DefinePostfixOprt(), mu::ParserTokenReader::IsOprt(), and mu::ParserTokenReader::IsPostOpTok().
const char_type * mu::ParserBase::ValidInfixOprtChars | ( | ) | const |
Virtual function that defines the characters allowed in infix operator definitions.
References m_sInfixOprtChars.
Referenced by mu::ParserTokenReader::IsInfixOpTok().
void mu::ParserBase::SetArgSep | ( | char_type | cArgSep | ) |
Set argument separator.
cArgSep | the argument separator character. |
References m_pTokenReader.
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.
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. |
ParserException | always throws thats the only purpose of this function. |
References m_pTokenReader.
Referenced by AddCallback(), ApplyFunc(), ApplyNumFunc(), ApplyStrFunc(), CheckName(), DefineOprt(), DefineStrConst(), DefineVar(), mu::ParserTokenReader::Error(), GetOprtPri(), ParseCmdCode(), ParseString(), and SetExpr().
void mu::ParserBase::Init | ( | ) | [protected] |
Initialize user defined functions.
Calls the virtual functions InitFun(), InitConst() and InitOprt().
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.
a_Parser | the source object. |
References m_bBuiltInOp, m_bOptimize, m_bUseByteCode, m_ConstDef, m_FunDef, m_InfixOprtDef, m_PostOprtDef, m_pTokenReader, m_sInfixOprtChars, m_sNameChars, m_sOprtChars, m_StrVarDef, m_VarDef, m_vStringBuf, m_vStringVarBuf, and ReInit().
Referenced by operator=().
void mu::ParserBase::InitTokenReader | ( | ) | [private] |
Initialize the token reader.
Create new token reader object and submit pointers to function, operator, constant and variable definitions.
nothrow |
References m_pTokenReader.
Referenced by ParserBase().
void mu::ParserBase::ReInit | ( | ) | const [private] |
Reset parser to string parsing mode and clear internal buffers.
Clear bytecode, reset the token reader.
nothrow |
References mu::ParserByteCode::clear(), m_pParseFormula, m_pTokenReader, m_vByteCode, m_vStringBuf, and ParseString().
Referenced by AddCallback(), Assign(), ClearConst(), ClearFormula(), ClearFun(), ClearInfixOprt(), ClearOprt(), ClearPostfixOprt(), ClearVar(), DefineConst(), DefineStrConst(), DefineVar(), EnableBuiltInOprt(), EnableByteCode(), EnableOptimizer(), ParseString(), RemoveVar(), and SetExpr().
void mu::ParserBase::ApplyFunc | ( | ParserStack< token_type > & | a_stOpt, | |
ParserStack< token_type > & | a_stVal, | |||
int | a_iArgCount | |||
) | const [private] |
Apply a function token.
iArgCount | Number of Arguments actually gathered used only for multiarg functions. |
The function token is removed from the stack
exception_type | if Argument count does not mach function requirements. |
References ApplyNumFunc(), ApplyStrFunc(), mu::cmFUNC_STR, mu::cmOPRT_BIN, 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(), m_pTokenReader, mu::ParserStack< TValueType >::pop(), mu::ParserStack< TValueType >::push(), mu::ParserStack< TValueType >::top(), and mu::tpSTR.
Referenced by ParseString().
ParserBase::token_type mu::ParserBase::ApplyNumFunc | ( | const token_type & | a_FunTok, | |
const std::vector< token_type > & | a_vArg | |||
) | const [private] |
(Attention: SetVal will reset Flags.)
References mu::ParserToken< TBase, TString >::AddFlags(), mu::ParserByteCode::AddFun(), mu::ParserByteCode::AddVal(), mu::ecINTERNAL_ERROR, mu::ecTOO_FEW_PARAMS, Error(), mu::ParserToken< TBase, TString >::flVOLATILE, mu::ParserToken< TBase, TString >::GetArgCount(), mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserToken< TBase, TString >::GetFuncAddr(), mu::ParserToken< TBase, TString >::GetVal(), mu::ParserToken< TBase, TString >::IsFlagSet(), m_bOptimize, m_pTokenReader, m_vByteCode, mu::ParserByteCode::RemoveValEntries(), and mu::ParserToken< TBase, TString >::SetVal().
Referenced by ApplyFunc().
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.
a_FunTok | Function token. |
exception_type | If the function token is not a string function |
(Attention: SetVal will reset Flags.)
References mu::ParserToken< TBase, TString >::AddFlags(), mu::ParserByteCode::AddStrFun(), mu::cmSTRING, mu::ecINTERNAL_ERROR, mu::ecSTRING_EXPECTED, mu::ecVAL_EXPECTED, Error(), mu::ParserToken< TBase, TString >::flVOLATILE, mu::ParserToken< TBase, TString >::GetArgCount(), mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserToken< TBase, TString >::GetFuncAddr(), mu::ParserToken< TBase, TString >::IsFlagSet(), m_pTokenReader, m_vByteCode, and mu::ParserToken< TBase, TString >::SetVal().
Referenced by ApplyFunc().
int mu::ParserBase::GetOprtPri | ( | const token_type & | a_Tok | ) | const [private] |
Get operator priority.
ParserException | if a_Oprt is no operator code |
References mu::cmADD, mu::cmAND, mu::cmARG_SEP, mu::cmASSIGN, mu::cmBC, mu::cmBO, mu::cmDIV, mu::cmEND, mu::cmEQ, mu::cmGE, mu::cmGT, mu::cmLE, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmOR, mu::cmPOW, mu::cmSUB, mu::cmXOR, mu::ecINTERNAL_ERROR, Error(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserToken< TBase, TString >::GetPri(), mu::prADD_SUB, mu::prCMP, mu::prLOGIC, mu::prMUL_DIV, and mu::prPOW.
Referenced by ParseString().
value_type mu::ParserBase::ParseString | ( | ) | const [private] |
One of the two main parse functions.
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.
References mu::ParserByteCode::AddVal(), mu::ParserByteCode::AddVar(), ApplyFunc(), mu::ParserByteCode::AsciiDump(), mu::cmADD, mu::cmAND, mu::cmARG_SEP, mu::cmASSIGN, mu::cmBC, mu::cmBO, mu::cmDIV, mu::cmEND, mu::cmEQ, mu::cmFUNC, mu::cmFUNC_STR, mu::cmGE, mu::cmGT, mu::cmLE, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOPRT_INFIX, mu::cmOPRT_POSTFIX, mu::cmOR, mu::cmPOW, mu::cmSTRING, mu::cmSUB, mu::cmVAL, mu::cmVAR, mu::cmXOR, mu::ecEMPTY_EXPRESSION, mu::ecINTERNAL_ERROR, mu::ecSTR_RESULT, mu::ecUNEXPECTED_ARG, mu::ecUNEXPECTED_ARG_SEP, mu::ecUNEXPECTED_EOF, mu::ParserStack< TValueType >::empty(), Error(), mu::ParserByteCode::Finalize(), mu::ParserToken< TBase, TString >::GetAsString(), mu::ParserByteCode::GetBufSize(), mu::ParserToken< TBase, TString >::GetCode(), mu::ParserToken< TBase, TString >::GetFuncAddr(), GetOprtPri(), mu::ParserByteCode::GetRawData(), mu::ParserToken< TBase, TString >::GetType(), mu::ParserToken< TBase, TString >::GetVal(), mu::ParserByteCode::GetValSize(), mu::ParserToken< TBase, TString >::GetVar(), m_bUseByteCode, m_pCmdCode, m_pParseFormula, m_pTokenReader, m_vByteCode, m_vStringBuf, ParseCmdCode(), ParseValue(), mu::ParserStack< TValueType >::pop(), mu::ParserStack< TValueType >::push(), ReInit(), mu::ParserToken< TBase, TString >::SetIdx(), mu::ParserStack< TValueType >::size(), mu::ParserStack< TValueType >::top(), and mu::tpDBL.
Referenced by GetUsedVar(), and ReInit().
value_type mu::ParserBase::ParseCmdCode | ( | ) | const [private] |
Parse the command code.
References mu::cmADD, mu::cmAND, mu::cmASSIGN, mu::cmDIV, mu::cmEND, mu::cmEQ, mu::cmFUNC, mu::cmFUNC_STR, mu::cmGE, mu::cmGT, mu::cmLE, mu::cmLT, mu::cmMUL, mu::cmNEQ, mu::cmOPRT_BIN, mu::cmOR, mu::cmPOW, mu::cmSUB, mu::cmVAL, mu::cmVAR, mu::cmXOR, mu::ecGENERIC, mu::ecINTERNAL_ERROR, Error(), mu::ParserByteCode::GetPtrSize(), mu::ParserByteCode::GetValSize(), m_pCmdCode, m_pTokenReader, m_vByteCode, and m_vStringBuf.
Referenced by ParseString().
value_type mu::ParserBase::ParseValue | ( | ) | const [private] |
Return result for constant functions.
Seems pointless, but for parser functions that are made up of only a value, which occur in real world applications, this speeds up things by removing the parser overhead almost completely.
References m_pCmdCode.
Referenced by ParseString().
void mu::ParserBase::ClearFormula | ( | ) | [private] |
Clear the formula.
nothrow | Clear the formula and existing bytecode. |
References mu::ParserByteCode::clear(), m_pCmdCode, m_pTokenReader, m_vByteCode, and ReInit().
void mu::ParserBase::CheckName | ( | const string_type & | a_sName, | |
const string_type & | a_szCharSet | |||
) | const [private] |
Check if a name contains invalid characters.
ParserException | if the name contains invalid charakters. |
References mu::ecINVALID_NAME, and Error().
Referenced by AddCallback(), DefineConst(), DefineStrConst(), and DefineVar().
char_type * mu::ParserBase::c_DefaultOprt [static, protected] |
Initial value:
{ _T("<="), _T(">="), _T("!="), _T("=="), _T("<"), _T(">"), _T("+"), _T("-"), _T("*"), _T("/"), _T("^"), _T("and"), _T("or"), _T("xor"), _T("="), _T("("), _T(")"), 0 }
When defining custom binary operators with AddOprt(...) make sure not to choose names conflicting with these definitions.
Referenced by DefineOprt(), and GetOprtDef().
ParseFunction mu::ParserBase::m_pParseFormula [mutable, private] |
Pointer to the parser function.
Eval() calls the function whose address is stored there.
Referenced by Eval(), GetUsedVar(), ParseString(), and ReInit().