45 value_type ParserInt::Sign(
value_type v) {
return (Round(v) < 0) ? -1 : (Round(v) > 0) ? 1 : 0; }
68 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]);
120 std::size_t pos = buf.find_first_not_of(
_T(
"0123456789"));
122 if (pos == std::string::npos)
132 stringstream_type::pos_type iEnd = stream.tellg();
134 iEnd = stream.str().length();
136 if (iEnd == (stringstream_type::pos_type) - 1)
139 *a_iPos += (int)iEnd;
156 if (a_szExpr[1] == 0 || (a_szExpr[0] !=
'0' || a_szExpr[1] !=
'x'))
162 stringstream_type::pos_type nPos(0);
164 ss >> std::hex >> iVal;
167 if (nPos == (stringstream_type::pos_type)0)
170 *a_iPos += (int)(2 + nPos);
178 if (a_szExpr[0] !=
'#')
182 iBits(
sizeof(iVal) * 8),
185 for (i = 0; (a_szExpr[i + 1] ==
'0' || a_szExpr[i + 1] ==
'1') && i < iBits; ++i)
186 iVal |= (
int)(a_szExpr[i + 1] ==
'1') << ((iBits - 1) - i);
192 throw exception_type(
_T(
"Binary to integer conversion error (overflow)."));
194 *a_fVal = (unsigned)(iVal >> (iBits - i));
205 ParserInt::ParserInt()
218 void ParserInt::InitConst()
223 void ParserInt::InitCharSets()
225 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).