29 #ifndef MU_PARSER_TOKEN_H
30 #define MU_PARSER_TOKEN_H
39 #pragma warning(disable : 26812)
65 template<
typename TBase,
typename TString>
77 std::unique_ptr<ParserCallback> m_pCallback;
131 m_iCode = a_Tok.m_iCode;
132 m_pTok = a_Tok.m_pTok;
133 m_strTok = a_Tok.m_strTok;
134 m_iIdx = a_Tok.m_iIdx;
135 m_strVal = a_Tok.m_strVal;
136 m_iType = a_Tok.m_iType;
137 m_fVal = a_Tok.m_fVal;
139 m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0);
175 m_iCode = a_pCallback.
GetCode();
201 m_pCallback.reset(0);
218 m_pTok = (
void*)a_pVar;
219 m_pCallback.reset(0);
234 m_iIdx =
static_cast<int>(a_iSize);
237 m_pCallback.reset(0);
250 if (m_iCode !=
cmSTRING || a_iIdx < 0)
266 if (m_iIdx < 0 || m_iCode !=
cmSTRING)
280 if (m_pCallback.get())
282 return m_pCallback->GetCode();
293 if (m_pCallback.get())
295 return m_pCallback->GetType();
306 if (!m_pCallback.get())
312 return m_pCallback->GetPri();
318 if (m_pCallback.get() ==
nullptr || m_pCallback->GetCode() !=
cmOPRT_BIN)
321 return m_pCallback->GetAssociativity();
354 case cmVAL:
return m_fVal;
355 case cmVAR:
return *((TBase*)m_pTok);
368 if (m_iCode !=
cmVAR)
371 return (TBase*)m_pTok;
383 if (!m_pCallback->GetAddr())
386 return m_pCallback->GetArgc();
405 #if defined(_MSC_VER)
user defined binary operator
ParserToken & SetVar(TBase *a_pVar, const TString &a_strTok)
make this token a variable token.
int GetArgCount() const
Return the number of function arguments.
TBase * GetVar() const
Get address of a variable token.
Internal error of any kind.
ParserToken & SetVal(TBase a_fVal, const TString &a_strTok=TString())
Make this token a value token.
void Assign(const ParserToken &a_Tok)
Copy token information from argument.
ParserToken & operator=(const ParserToken &a_Tok)
Assignment operator.
ECmdCode GetCode() const
Return the callback code.
ParserToken & SetString(const TString &a_strTok, std::size_t a_iSize)
Make this token a variable token.
Code for a generic function item.
EOprtAssociativity
Parser operator precedence values.
int GetIdx() const
Return Index associated with the token related data.
ETypeCode
Types internally used by the parser.
ParserToken()
Constructor (default).
Error class of the parser.
#define MUP_ASSERT(COND)
An assertion that does not kill the program.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
String type (Function arguments and constants only, no string variables)
A numerical function has been called with a non value type of argument.
ECmdCode GetCode() const
Return the token type.
Namespace for mathematical applications.
ParserToken & Set(ECmdCode a_iType, const TString &a_strTok=TString())
Assign a token type.
value_type(* generic_fun_type)()
Callback type used for functions without arguments.
Definition of the parser callback class.
void * GetAddr() const
Get the callback address for the parser function.
void SetIdx(int a_iIdx)
Set an index associated with the token related data.
Encapsulation of the data for a single formula token.
const TString & GetAsString() const
Return the token identifier.
generic_fun_type GetFuncAddr() const
Return the address of the callback function assoziated with function and operator tokens...
Floating point variables.
ParserToken(const ParserToken &a_Tok)
Create token from another one.
Encapsulation of prototypes for a numerical parser function.
ParserToken & Set(const ParserCallback &a_pCallback, const TString &a_sTok)
Set Callback type.
This file defines the error class used by the parser.