OpcUaCanOpen
CANopen OPC-UA server
muParserDef.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2014 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 #ifndef MUP_DEF_H
26 #define MUP_DEF_H
27 
28 #include <iostream>
29 #include <string>
30 #include <sstream>
31 #include <map>
32 
33 #include "muParserFixes.h"
34 
39 #define MUP_VERSION _T("2.2.6")
40 #define MUP_VERSION_DATE _T("20181004")
41 
42 #define MUP_CHARS _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
43 
45 //#define MUP_MATH_EXCEPTIONS
46 
52 #define MUP_BASETYPE double
53 
58 //#define MUP_USE_OPENMP
59 
60 #if defined(_UNICODE)
61 
62  #define MUP_STRING_TYPE std::wstring
63 
64  #if !defined(_T)
65  #define _T(x) L##x
66  #endif // not defined _T
67 #else
68  #ifndef _T
69  #define _T(x) x
70  #endif
71 
73  #define MUP_STRING_TYPE std::string
74 #endif
75 
76 #if defined(_DEBUG)
77 
79  #define MUP_FAIL(MSG) \
80  { \
81  bool MSG=false; \
82  assert(MSG); \
83  }
84 
90  #define MUP_ASSERT(COND) \
91  if (!(COND)) \
92  { \
93  stringstream_type ss; \
94  ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \
95  << __FILE__ << _T(" line ") \
96  << __LINE__ << _T("."); \
97  throw ParserError( ss.str() ); \
98  }
99 #else
100  #define MUP_FAIL(MSG)
101  #define MUP_ASSERT(COND)
102 #endif
103 
104 
105 namespace mu
106 {
107 #if defined(_UNICODE)
108 
109  //------------------------------------------------------------------------------
111  inline std::wostream& console()
112  {
113  return std::wcout;
114  }
115 
117  inline std::wistream& console_in()
118  {
119  return std::wcin;
120  }
121 
122 #else
123 
128  inline std::ostream& console()
129  {
130  return std::cout;
131  }
132 
137  inline std::istream& console_in()
138  {
139  return std::cin;
140  }
141 
142 #endif
143 
144  //------------------------------------------------------------------------------
149  enum ECmdCode
150  {
151  // The following are codes for built in binary operators
152  // apart from built in operators the user has the opportunity to
153  // add user defined operators.
154  cmLE = 0,
155  cmGE = 1,
156  cmNEQ = 2,
157  cmEQ = 3,
158  cmLT = 4,
159  cmGT = 5,
160  cmADD = 6,
161  cmSUB = 7,
162  cmMUL = 8,
163  cmDIV = 9,
164  cmPOW = 10,
165  cmLAND = 11,
166  cmLOR = 12,
167  cmASSIGN = 13,
168  cmBO = 14,
169  cmBC = 15,
170  cmIF = 16,
171  cmELSE = 17,
172  cmENDIF = 18,
173  cmARG_SEP = 19,
174  cmVAR = 20,
175  cmVAL = 21,
176 
177  // For optimization purposes
183 
184  // operators and functions
194  };
195 
196  //------------------------------------------------------------------------------
200  {
201  tpSTR = 0,
202  tpDBL = 1,
203  tpVOID = 2
204  };
205 
206  //------------------------------------------------------------------------------
208  {
211  };
212 
213  //------------------------------------------------------------------------------
216  {
217  oaLEFT = 0,
218  oaRIGHT = 1,
219  oaNONE = 2
220  };
221 
222  //------------------------------------------------------------------------------
225  {
226  // binary operators
227  prLOR = 1,
228  prLAND = 2,
229  prLOGIC = 3,
230  prCMP = 4,
231  prADD_SUB = 5,
232  prMUL_DIV = 6,
233  prPOW = 7,
234 
235  // infix operators
236  prINFIX = 6,
238  };
239 
240  //------------------------------------------------------------------------------
241  // basic types
242 
248 
254 
260 
262  typedef std::basic_stringstream<char_type,
263  std::char_traits<char_type>,
264  std::allocator<char_type> > stringstream_type;
265 
266  // Data container types
267 
269  typedef std::map<string_type, value_type*> varmap_type;
270 
272  typedef std::map<string_type, value_type> valmap_type;
273 
275  typedef std::map<string_type, std::size_t> strmap_type;
276 
277  // Parser callbacks
278 
281 
283  typedef value_type (*fun_type0)();
284 
287 
290 
293 
296 
299 
302 
305 
308 
311 
314 
316  typedef value_type (*bulkfun_type0)(int, int);
317 
319  typedef value_type (*bulkfun_type1)(int, int, value_type);
320 
323 
326 
329 
332 
335 
338 
341 
344 
347 
349  typedef value_type (*multfun_type)(const value_type*, int);
350 
352  typedef value_type (*strfun_type1)(const char_type*);
353 
356 
359 
361  typedef int (*identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal);
362 
364  typedef value_type* (*facfun_type)(const char_type*, void*);
365 } // end of namespace
366 
367 #endif
368