45 value_type v3) {
return (Round(v1)==1) ? Round(v2) : Round(v3); }
67 return std::pow((
double)Round(v1), (
double)Round(v2));
81 throw ParserError(
_T(
"too few arguments for function sum."));
84 for (
int i=0; i<a_iArgc; ++i)
94 throw ParserError(
_T(
"too few arguments for function min.") );
97 for (
int i=0; i<a_iArgc; ++i)
98 fRes = std::min(fRes, a_afArg[i]);
107 throw ParserError(
_T(
"too few arguments for function min."));
110 for (
int i=0; i<a_iArgc; ++i)
111 fRes = std::max(fRes, a_afArg[i]);
121 std::size_t pos = buf.find_first_not_of(
_T(
"0123456789"));
123 if (pos==std::string::npos)
133 stringstream_type::pos_type iEnd = stream.tellg();
135 iEnd = stream.str().length();
137 if (iEnd==(stringstream_type::pos_type)-1)
140 *a_iPos += (int)iEnd;
157 if (a_szExpr[1]==0 || (a_szExpr[0]!=
'0' || a_szExpr[1]!=
'x') )
163 stringstream_type::pos_type nPos(0);
165 ss >> std::hex >> iVal;
168 if (nPos==(stringstream_type::pos_type)0)
171 *a_iPos += (int)(2 + nPos);
179 if (a_szExpr[0]!=
'#')
183 iBits(
sizeof(iVal)*8),
186 for (i=0; (a_szExpr[i+1]==
'0' || a_szExpr[i+1]==
'1') && i<iBits; ++i)
187 iVal |= (
int)(a_szExpr[i+1]==
'1') << ((iBits-1)-i);
193 throw exception_type(
_T(
"Binary to integer conversion error (overflow)."));
195 *a_fVal = (unsigned)(iVal >> (iBits-i) );
206 ParserInt::ParserInt()
219 void ParserInt::InitConst()
224 void ParserInt::InitCharSets()
226 DefineNameChars(
_T(
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
#define _T(x)
Activate this option in order to compile with OpenMP support.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
virtual void InitFun()
Initialize the default functions.
virtual void InitOprt()
Initialize operators.
void AddValIdent(identfun_type a_pCallback)
Add a value parsing function.
Definition of a parser using integer value.
power operator priority (highest)
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
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 DefineOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of binary operators and postfix operators...
void DefineFun(const string_type &a_strName, T a_pFun, bool a_bAllowOpt=true)
Define a parser function without arguments.
void DefineOprt(const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, EOprtAssociativity a_eAssociativity=oaLEFT, bool a_bAllowOpt=false)
Define a binary operator.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Namespace for mathematical applications.
string_type::value_type char_type
The character type used by the parser.
void EnableBuiltInOprt(bool a_bIsOn=true)
Enable or disable the built in binary operators.
MUP_STRING_TYPE string_type
The stringtype used by the parser.
Mathematical expressions parser (base parser engine).