26#ifndef MU_PARSER_TOKEN_READER_H
27#define MU_PARSER_TOKEN_READER_H
Mathematical expressions parser (base parser engine).
Token reader for the ParserBase class.
bool IsArgSep(token_type &a_Tok)
bool IsPostOpTok(token_type &a_Tok)
Check if a string position contains a unary post value operator.
const funmap_type * m_pPostOprtDef
const funmap_type * m_pInfixOprtDef
std::list< identfun_type > m_vIdentFun
Value token identification function.
ParserTokenReader(ParserBase *a_pParent)
Constructor.
bool IsFunTok(token_type &a_Tok)
Check whether the token at a given position is a function token.
bool IsValTok(token_type &a_Tok)
Check whether the token at a given position is a value token.
token_type ReadNextToken()
Read the next token from the string.
@ noASSIGN
to block assignement to constant i.e. "4=7"
@ noEND
to avoid unexpected end of formula
@ noSTR
to block numeric arguments on string functions
@ noINFIXOP
to avoid i.e. "++4" "!!4"
@ noVAR
to avoid i.e. "sin a" or "sin(8)a"
@ noBO
to avoid i.e. "cos(7)("
@ noOPT
to avoid i.e. "(+)"
@ noANY
All of he above flags set.
@ noVAL
to avoid i.e. "tan 2" or "sin(8)3.14"
@ noPOSTOP
to avoid i.e. "(5!!)" "sin!"
@ noARG_SEP
to avoid i.e. ",," or "+," ...
@ noBC
to avoid i.e. "sin)" or "()"
@ noFUN
to avoid i.e. "sqrt cos" or "(1)sin"
void SetParent(ParserBase *a_pParent)
char_type m_cArgSep
The character used for separating function arguments.
void Assign(const ParserTokenReader &a_Reader)
Assign state of a token reader to this token reader.
bool IsOprt(token_type &a_Tok)
Check if a string position contains a binary operator.
int ExtractToken(const char_type *a_szCharSet, string_type &a_strTok, int a_iPos) const
Extract all characters that belong to a certain charset.
value_type m_fZero
Dummy value of zero, referenced by undefined variables.
void SetArgSep(char_type cArgSep)
const funmap_type * m_pFunDef
ParserTokenReader & operator=(const ParserTokenReader &a_Reader)
Assignement operator.
void Error(EErrorCodes a_iErrc, int a_iPos=-1, const string_type &a_sTok=string_type()) const
Create an error containing the parse error position.
void SetVarCreator(facfun_type a_pFactory, void *pUserData)
void IgnoreUndefVar(bool bIgnore)
Set Flag that contronls behaviour in case of undefined variables beeing found.
const funmap_type * m_pOprtDef
ParserTokenReader * Clone(ParserBase *a_pParent) const
Create instance of a ParserTokenReader identical with this and return its pointer.
bool IsVarTok(token_type &a_Tok)
Check wheter a token at a given position is a variable token.
void SetFormula(const string_type &a_strFormula)
Initialize the token Reader.
bool IsString(token_type &a_Tok)
Check wheter a token at a given position is a string.
int GetPos() const
Return the current position of the token reader in the formula string.
char_type GetArgSep() const
bool IsInfixOpTok(token_type &a_Tok)
Check if a string position contains a unary infix operator.
ParserToken< value_type, string_type > token_type
int ExtractOperatorToken(string_type &a_sTok, int a_iPos) const
Check Expression for the presence of a binary operator token.
varmap_type * m_pVarDef
The only non const pointer to parser internals.
const strmap_type * m_pStrVarDef
bool IsEOF(token_type &a_Tok)
Check for End of Formula.
bool IsBuiltIn(token_type &a_Tok)
Check if a built in operator or other token can be found.
void ReInit()
Reset the token reader to the start of the formula.
token_type & SaveBeforeReturn(const token_type &tok)
varmap_type & GetUsedVar()
Return a map containing the used variables only.
void AddValIdent(identfun_type a_pCallback)
bool IsStrVarTok(token_type &a_Tok)
const string_type & GetExpr() const
Return a reference to the formula.
bool IsUndefVarTok(token_type &a_Tok)
Check wheter a token at a given position is an undefined variable.
const valmap_type * m_pConstDef
This file contains standard definitions used by the parser.
This file contains the parser token definition.
Namespace for mathematical applications.
int(* identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal)
Callback used for functions that identify values in a string.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
value_type *(* facfun_type)(const char_type *, void *)
Callback used for variable creation factory functions.
std::map< string_type, value_type > valmap_type
Type used for storing constants.
string_type::value_type char_type
The character type used by the parser.
std::map< string_type, ParserCallback > funmap_type
Container for Callback objects.
std::map< string_type, value_type * > varmap_type
Type used for storing variables.
std::string string_type
The stringtype used by the parser.
std::map< string_type, std::size_t > strmap_type
Type for assigning a string name to an index in the internal string table.