00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef MUP_DEF_H
00026 #define MUP_DEF_H
00027
00028 #include <iostream>
00029 #include <string>
00030 #include <sstream>
00031 #include <map>
00032
00033 #include "muParserFixes.h"
00034
00045 #define MUP_BASETYPE double
00046
00051 #define MUP_BYTECODE_TYPE long
00052
00053 #if defined(_UNICODE)
00054
00055 #define MUP_STRING_TYPE std::wstring
00056
00057 #if !defined(_T)
00058 #define _T(x) L##x
00059 #endif // not defined _T
00060 #else
00061 #ifndef _T
00062 #define _T
00063 #endif
00064
00066 #define MUP_STRING_TYPE std::string
00067 #endif
00068
00069 #if defined(_DEBUG)
00070
00072 #define MUP_FAIL(MSG) \
00073 bool MSG=false; \
00074 assert(MSG);
00075
00076 #ifndef _UNICODE
00077
00082 #define MUP_ASSERT(COND) \
00083 if (!(COND)) \
00084 { \
00085 stringstream_type ss; \
00086 ss << "Assertion \""#COND"\" failed: " \
00087 << __FILE__ << " line " \
00088 << __LINE__ << "."; \
00089 throw ParserError( ss.str() ); \
00090 }
00091 #else
00092 #define MUP_ASSERT(COND)
00093 #endif // _UNICODE
00094 #else
00095 #define MUP_FAIL(MSG)
00096 #define MUP_ASSERT(COND)
00097 #endif
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 namespace mu
00111 {
00112 #if defined(_UNICODE)
00113
00114
00116 inline std::wostream& console()
00117 {
00118 return std::wcout;
00119 }
00120
00122 inline std::wistream& console_in()
00123 {
00124 return std::wcin;
00125 }
00126
00127 #else
00128
00133 inline std::ostream& console()
00134 {
00135 return std::cout;
00136 }
00137
00142 inline std::istream& console_in()
00143 {
00144 return std::cin;
00145 }
00146
00147 #endif
00148
00149
00154 enum ECmdCode
00155 {
00156
00157
00158
00159 cmLE = 0,
00160 cmGE = 1,
00161 cmNEQ = 2,
00162 cmEQ = 3,
00163 cmLT = 4,
00164 cmGT = 5,
00165 cmADD = 6,
00166 cmSUB = 7,
00167 cmMUL = 8,
00168 cmDIV = 9,
00169 cmPOW = 10,
00170 cmAND = 11,
00171 cmOR = 12,
00172 cmXOR = 13,
00173 cmASSIGN = 14,
00174 cmBO = 15,
00175 cmBC = 16,
00176 cmARG_SEP,
00177 cmVAR,
00178 cmVAL,
00179 cmFUNC,
00180 cmFUNC_STR,
00181 cmSTRING,
00182 cmOPRT_BIN,
00183 cmOPRT_POSTFIX,
00184 cmOPRT_INFIX,
00185 cmEND,
00186 cmUNKNOWN,
00187 };
00188
00189
00192 enum ETypeCode
00193 {
00194 tpSTR = 0,
00195 tpDBL = 1,
00196 tpVOID = 2
00197 };
00198
00199
00201 enum EPrec
00202 {
00203
00204 prLOGIC = 1,
00205 prCMP = 2,
00206 prADD_SUB = 3,
00207 prMUL_DIV = 4,
00208 prPOW = 5,
00209
00210
00211 prINFIX = 4,
00212 prPOSTFIX = 4
00213 };
00214
00215
00216
00217
00222 typedef MUP_BASETYPE value_type;
00223
00228 typedef MUP_STRING_TYPE string_type;
00229
00234 typedef MUP_BYTECODE_TYPE bytecode_type;
00235
00240 typedef string_type::value_type char_type;
00241
00243 typedef std::basic_stringstream<char_type,
00244 std::char_traits<char_type>,
00245 std::allocator<char_type> > stringstream_type;
00246
00247
00248
00250 typedef std::map<string_type, value_type*> varmap_type;
00251
00253 typedef std::map<string_type, value_type> valmap_type;
00254
00256 typedef std::map<string_type, std::size_t> strmap_type;
00257
00258
00259
00261 typedef value_type (*fun_type0)();
00262
00264 typedef value_type (*fun_type1)(value_type);
00265
00267 typedef value_type (*fun_type2)(value_type, value_type);
00268
00270 typedef value_type (*fun_type3)(value_type, value_type, value_type);
00271
00273 typedef value_type (*fun_type4)(value_type, value_type, value_type, value_type);
00274
00276 typedef value_type (*fun_type5)(value_type, value_type, value_type, value_type, value_type);
00277
00279 typedef value_type (*multfun_type)(const value_type*, int);
00280
00282 typedef value_type (*strfun_type1)(const char_type*);
00283
00285 typedef value_type (*strfun_type2)(const char_type*, value_type);
00286
00288 typedef value_type (*strfun_type3)(const char_type*, value_type, value_type);
00289
00291 typedef int (*identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal);
00292
00294 typedef value_type* (*facfun_type)(const char_type*, void*);
00295
00296
00304 template <bool> struct STATIC_ASSERTION_FAILURE;
00305 template <> struct STATIC_ASSERTION_FAILURE<true> {};
00306
00311 typedef char MAP_TYPE_CANT_BE_UNSIGNED[ sizeof( STATIC_ASSERTION_FAILURE< bytecode_type(-1)<0 >) ];
00312 }
00313
00314 #endif
00315