mu::ParserBase Class Reference

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

#include <muParserBase.h>

Inheritance diagram for mu::ParserBase:

mu::Parser mu::ParserComplex mu::ParserInt

List of all members.

Public Types

typedef ParserError exception_type
 Type of the error class.

Public Member Functions

 ParserBase ()
 Constructor.
 ParserBase (const ParserBase &a_Parser)
ParserBaseoperator= (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_typeGetUsedVar () const
 Return a map containing the used variables only.
const varmap_typeGetVar () const
 Return a map containing the used variables only.
const valmap_typeGetConst () const
 Return a map containing all parser constants.
const string_typeGetExpr () const
 Retrieve the formula.
const funmap_typeGetFunDef () 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_typeValidNameChars () const
 Virtual function that defines the characters allowed in name identifiers.
const char_typeValidOprtChars () const
 Virtual function that defines the characters allowed in operator definitions.
const char_typeValidInfixOprtChars () 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_typec_DefaultOprt []
 Identifiers for built in binary operators.

Private Types

typedef value_type(ParserBase::* ParseFunction )() const
 Typedef for the parse functions.
typedef std::vector< string_typestringbuf_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_typem_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_typem_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


Detailed Description

Mathematical expressions parser (base parser engine).

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.

Author:
(C) 2004-2008 Ingo Berg
Examples:

list_expr_var.cpp, and listvar.cpp.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

mu::ParserBase::ParserBase (  ) 

Constructor.

Parameters:
a_szFormula the formula to interpret.
Exceptions:
ParserException if a_szFormula is null.

References InitTokenReader().


Member Function Documentation

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

Assignement operator.

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

Parameters:
a_Parser Object to copy to this.
Returns:
*this
Exceptions:
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.

Precondition:
A formula must be set.

Variables must have been set (if needed)

See also:
m_pParseFormula
Returns:
The evaluation result
Exceptions:
ParseException if no Formula is set or in case of any other error related to the formula.
Examples:
calc.cpp.

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.

Parameters:
a_strFormula Formula as string_type
Exceptions:
ParserException in case of syntax errors.
Triggers first time calculation thus the creation of the bytecode and scanning of used variables.
Examples:
calc.cpp.

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.

Postcondition:
Resets the parser to string parser mode.
Exceptions:
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.

Attention:
There is no reason to disable bytecode. It will drastically decrease parsing speed.

References m_bUseByteCode, and ReInit().

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().

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.

Returns:
m_bBuiltInOp; true if built in operators are enabled.
Exceptions:
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.

Parameters:
[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.

Parameters:
[in] a_sName The name of the constant.
[in] a_fVal the value of the constant.
Postcondition:
Will reset the Parser to string parsing mode.
Exceptions:
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.

Parameters:
[in] a_strName The name of the constant.
[in] a_strVal the value of the constant.
Examples:
calc.cpp.

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.

Parameters:
[in] a_sName the variable name
[in] a_pVar A pointer to the variable vaule.
Postcondition:
Will reset the Parser to string parsing mode.
Precondition:
[assert] a_fVar!=0
Exceptions:
ParserException in case the name contains invalid signs.
Examples:
calc.cpp.

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.

Postcondition:
Will reset the Parser to string parsing mode.
Examples:
calc.cpp.

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.

Postcondition:
Will reset the Parser to string parsing mode.
Parameters:
[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)
See also:
EPrec
Examples:
calc.cpp.

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 (  ) 

Clear all user defined variables.

Exceptions:
nothrow Resets the parser to string parsing mode by calling ReInit.

References m_VarDef, and ReInit().

void mu::ParserBase::ClearFun (  ) 

Clear all functions.

Postcondition:
Resets the parser to string parsing mode.
Exceptions:
nothrow 

References m_FunDef, and ReInit().

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 

References m_ConstDef, m_StrVarDef, and ReInit().

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

void mu::ParserBase::ClearInfixOprt (  ) 

Clear the user defined Prefix operators.

Postcondition:
Resets the parser to string parser mode.
Exceptions:
nothrow 

References m_InfixOprtDef, and ReInit().

void mu::ParserBase::ClearPostfixOprt (  ) 

Clear all user defined postfix operators.

Postcondition:
Resets the parser to string parsing mode.
Exceptions:
nothrow 

References m_PostOprtDef, and ReInit().

void mu::ParserBase::ClearOprt (  ) 

Clear all user defined binary operators.

Postcondition:
Resets the parser to string parsing mode.
Exceptions:
nothrow 

References m_OprtDef, and ReInit().

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.

References m_VarDef, and ReInit().

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.

References m_FunDef.

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

Get the default symbols used for the built in operators.

See also:
c_DefaultOprt

References c_DefaultOprt.

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

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

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

Virtual function that defines the characters allowed in operator definitions.

See also:
ValidNameChars, ValidPrefixOprtChars

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.

See also:
ValidNameChars, ValidOprtChars

References m_sInfixOprtChars.

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

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

Set argument separator.

Parameters:
cArgSep the argument separator character.
Examples:
calc.cpp.

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.

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:
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.

Parameters:
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.

Postcondition:
m_pTokenReader.get()!=0
Exceptions:
nothrow 

References m_pTokenReader.

Referenced by ParserBase().

void mu::ParserBase::ReInit (  )  const [private]

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

Apply a function token.

Parameters:
iArgCount 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_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]

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

int mu::ParserBase::GetOprtPri ( const token_type a_Tok  )  const [private]

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.

See also:
ParseCmdCode(), ParseValue()

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.

See also:
ParseString(), ParseValue()
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.

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.

Postcondition:
Resets the parser to string parsing mode.
Exceptions:
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.

Exceptions:
ParserException if the name contains invalid charakters.

References mu::ecINVALID_NAME, and Error().

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


Member Data Documentation

Initial value:

 
  { 
    _T("<="), _T(">="),  _T("!="), 
    _T("=="), _T("<"),   _T(">"), 
    _T("+"),  _T("-"),   _T("*"), 
    _T("/"),  _T("^"),   _T("and"), 
    _T("or"), _T("xor"), _T("="), 
    _T("("),  _T(")"), 0 
  }
Identifiers for built in binary operators.

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

Referenced by DefineOprt(), and GetOprtDef().

Pointer to the parser function.

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

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


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

Generated on Sun Jun 22 00:57:25 2008 for muParser by  doxygen 1.5.5