67 return std::pow((
double)
Round(v1), (
double)
Round(v2));
84 for (
int i=0; i<a_iArgc; ++i)
97 for (
int i=0; i<a_iArgc; ++i)
110 for (
int i=0; i<a_iArgc; ++i)
121 std::size_t pos = buf.find_first_not_of(
_nrT(
"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);
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);
195 *a_fVal = (unsigned)(iVal >> (iBits-i) );
226 DefineNameChars(
_nrT(
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
Mathematical expressions parser (base parser engine).
void AddValIdent(identfun_type a_pCallback)
Add a value parsing function.
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 DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool optimizeAway=true)
Add a user defined operator.
ParserError exception_type
Type of the error class.
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
void DefineFun(const string_type &a_strName, T a_pFun, bool optimizeAway=true)
Define a parser function without arguments.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
void EnableBuiltInOprt(bool a_bIsOn=true)
Enable or disable the built in binary operators.
void DefineOprt(const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, EOprtAssociativity a_eAssociativity=oaLEFT, bool optimizeAway=true)
Define a binary operator.
Error class of the parser.
static int IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
Check a given position in the expression for the presence of a hex value.
static value_type Abs(value_type)
static value_type LessEq(value_type v1, value_type v2)
static value_type GreaterEq(value_type v1, value_type v2)
static value_type Shl(value_type v1, value_type v2)
static value_type Not(value_type v1)
static value_type Div(value_type v1, value_type v2)
static value_type Mul(value_type v1, value_type v2)
static value_type NotEqual(value_type v1, value_type v2)
static value_type Shr(value_type v1, value_type v2)
static value_type UnaryMinus(value_type)
static value_type Or(value_type v1, value_type v2)
static value_type Greater(value_type v1, value_type v2)
static value_type And(value_type v1, value_type v2)
static value_type Add(value_type v1, value_type v2)
static value_type Mod(value_type v1, value_type v2)
static value_type Max(const value_type *a_afArg, int a_iArgc)
virtual void InitOprt()
Initialize operators.
virtual void InitCharSets()
static value_type Sub(value_type v1, value_type v2)
static value_type LogOr(value_type v1, value_type v2)
static value_type Ite(value_type, value_type, value_type)
static value_type Pow(value_type v1, value_type v2)
static value_type Min(const value_type *a_afArg, int a_iArgc)
static value_type Equal(value_type v1, value_type v2)
static value_type Sign(value_type)
static value_type Sum(const value_type *a_afArg, int a_iArgc)
static value_type Less(value_type v1, value_type v2)
static value_type LogAnd(value_type v1, value_type v2)
static int IsBinVal(const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
virtual void InitFun()
Initialize the default functions.
static int Round(value_type v)
#define _nrT(x)
Activate this option in order to compile with OpenMP support.
Definition of a parser using integer value.
Namespace for mathematical applications.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
string_type::value_type char_type
The character type used by the parser.
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.
std::string string_type
The stringtype used by the parser.
@ prCMP
comparsion operators
@ prPOW
power operator priority (highest)
@ prMUL_DIV
multiplication/division