NCBI C++ ToolKit
expr.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: expr.cpp 99041 2023-02-07 13:59:13Z ivanov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Sergey Sikorskiy, Mikhail Zakharov
27  *
28  * File Description:
29  * Expression parsing and evaluation.
30  *
31  * ===========================================================================
32  */
33 
34 #include <ncbi_pch.hpp>
35 
36 #include <corelib/expr.hpp>
37 
38 #include <math.h>
39 #include <limits>
40 
41 
42 #define BINARY(opd) (opd >= ePOW)
43 
44 
46 
47 ////////////////////////////////////////////////////////////////////////////////
49 : ival(0)
50 , m_sval("")
51 , m_Var(NULL)
52 , m_Pos(0)
53 , m_Tag()
54 {
55 }
56 
58 : ival(0),
59 m_sval(value),
60 m_Var(NULL),
61 m_Pos(0),
62 m_Tag(eSTRING)
63 {
64 }
65 
66 
68 : ival(value.ival)
69 , m_sval("")
70 , m_Var(value.m_Var)
71 , m_Pos(value.m_Pos)
72 , m_Tag(value.m_Tag)
73 {
74 }
75 
77 : ival(value)
78 , m_sval("")
79 , m_Var(NULL)
80 , m_Pos(0)
81 , m_Tag(eINT)
82 {
83 }
84 
86 : ival(value)
87 , m_sval("")
88 , m_Var(NULL)
89 , m_Pos(0)
90 , m_Tag(eINT)
91 {
92 }
93 
95 : ival(0)
96 , m_sval("")
97 , m_Var(NULL)
98 , m_Pos(0)
99 , m_Tag(eINT)
100 {
101  if (static_cast<Uint8>(numeric_limits<Int8>::max()) < value) {
103  eTypeConversionError,
104  "Value too big to fit in the 8-byte signed integer type",
105  m_Pos);
106  }
107 
108  ival = static_cast<Int8>(value);
109 }
110 
111 
113 : ival(value)
114 , m_sval("")
115 , m_Var(NULL)
116 , m_Pos(0)
117 , m_Tag(eINT)
118 {
119 }
120 
122 : fval(value)
123 , m_sval("")
124 , m_Var(NULL)
125 , m_Pos(0)
126 , m_Tag(eFLOAT)
127 {
128 }
129 
131 : bval(value)
132 , m_sval("")
133 , m_Var(NULL)
134 , m_Pos(0)
135 , m_Tag(eBOOL)
136 {
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
141 : m_Tag()
142 , m_IntFunc1(NULL)
143 , m_Val()
144 , m_Next(NULL)
145 {
146 }
147 
149 {
150  delete m_Next;
151 }
152 
154 : m_Tag(eVARIABLE)
155 , m_IntFunc1(NULL)
156 , m_Val(value)
157 , m_Name(name)
158 , m_Next(NULL)
159 {
160 }
161 
163 : m_Tag(eVARIABLE)
164 , m_IntFunc1(NULL)
165 , m_Val(value)
166 , m_Name(name)
167 , m_Next(NULL)
168 {
169 }
170 
172 : m_Tag(eVARIABLE)
173 , m_IntFunc1(NULL)
174 , m_Val(value)
175 , m_Name(name)
176 , m_Next(NULL)
177 {
178 }
179 
181 : m_Tag(eVARIABLE)
182 , m_IntFunc1(NULL)
183 , m_Val(value)
184 , m_Name(name)
185 , m_Next(NULL)
186 {
187 }
188 
189 CExprSymbol::CExprSymbol(const char* name, bool value)
190 : m_Tag(eVARIABLE)
191 , m_IntFunc1(NULL)
192 , m_Val(value)
193 , m_Name(name)
194 , m_Next(NULL)
195 {
196 }
197 
198 CExprSymbol::CExprSymbol(const char* name, double value)
199 : m_Tag(eVARIABLE)
200 , m_IntFunc1(NULL)
201 , m_Val(value)
202 , m_Name(name)
203 , m_Next(NULL)
204 {
205 }
206 
207 CExprSymbol::CExprSymbol(const char* name, string value)
208 : m_Tag(eVARIABLE)
209 , m_IntFunc1(NULL)
210 , m_Val(value)
211 , m_Name(name)
212 , m_Next(NULL)
213 {
214 }
215 
216 CExprSymbol::CExprSymbol(const char* name, FIntFunc1 value)
217 : m_Tag(eIFUNC1)
218 , m_IntFunc1(value)
219 , m_Val((Int8)0)
220 , m_Name(name)
221 , m_Next(NULL)
222 {
223 }
224 
225 CExprSymbol::CExprSymbol(const char* name, FIntFunc2 value)
226 : m_Tag(eIFUNC2)
227 , m_IntFunc2(value)
228 , m_Val((Int8)0)
229 , m_Name(name)
230 , m_Next(NULL)
231 {
232 }
233 
234 CExprSymbol::CExprSymbol(const char* name, FFloatFunc1 value)
235 : m_Tag(eFFUNC1)
236 , m_FloatFunc1(value)
237 , m_Val((Int8)0)
238 , m_Name(name)
239 , m_Next(NULL)
240 {
241 }
242 
243 CExprSymbol::CExprSymbol(const char* name, FFloatFunc2 value)
244 : m_Tag(eFFUNC2)
245 , m_FloatFunc2(value)
246 , m_Val((Int8)0)
247 , m_Name(name)
248 , m_Next(NULL)
249 {
250 }
251 
252 CExprSymbol::CExprSymbol(const char* name, FBoolFunc1 value)
253 : m_Tag(eBFUNC1)
254 , m_BoolFunc1(value)
255 , m_Val((Int8)0)
256 , m_Name(name)
257 , m_Next(NULL)
258 {
259 }
260 
261 CExprSymbol::CExprSymbol(const char* name, FBoolFunc2 value)
262 : m_Tag(eBFUNC2)
263 , m_BoolFunc2(value)
264 , m_Val((Int8)0)
265 , m_Name(name)
266 , m_Next(NULL)
267 {
268 }
269 
270 CExprSymbol::CExprSymbol(const char* name, FStringFunc1 value)
271 : m_Tag(eSFUNC1)
272 , m_StringFunc1(value)
273 , m_Val((Int8)0)
274 , m_Name(name)
275 , m_Next(NULL)
276 {
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 static
281 Int8 to_int(Int8 m_Val)
282 {
283  return m_Val;
284 }
285 
286 static
287 double to_float(double m_Val)
288 {
289  return m_Val;
290 }
291 
292 static
294 {
295  while (x) {
296  Int8 r = y%x;
297  y=x;
298  x=r;
299  }
300 
301  return y;
302 }
303 
304 static
306 {
307  Int8 m = y;
308  Int8 u = 1, v = 0;
309  Int8 s = 0, t = 1;
310 
311  while (x) {
312  Int8 q = y/x;
313  Int8 r = y%x;
314  Int8 a = s - q*u;
315  Int8 b = t - q*v;
316  y=x; s=u; t=v;
317  x=r; u=a; v=b;
318  }
319 
320  if (y!=1) return 0;
321 
322  while (s<0) s+=m;
323 
324  return s;
325 }
326 
327 static
329 {
330  if (n <= 3) {
331  return n;
332  }
333  n |= 1;
334  while (true) {
335  Int8 m = (Int8)sqrt((double)n) + 1;
336  Int8 k = 3;
337  while (true) {
338  if (k > m) {
339  return n;
340  }
341  if (n % k == 0) break;
342  k += 2;
343  }
344  n += 2;
345  }
346 }
347 
348 /*
349 static
350 char*
351 to_bin(int nval, char* pbuf, int nbufsize)
352 {
353  int ncnt;
354  int bcnt;
355  int nlen = sizeof(int) * 8 + sizeof(int);
356 
357  if (pbuf != NULL && nbufsize > nlen)
358  {
359  pbuf[nlen] = '\0';
360  pbuf[nlen - 1] = 'b';
361  for(ncnt = 0, bcnt = nlen - 2; ncnt < nlen; ncnt ++, bcnt --)
362  {
363  if (ncnt > 0 && (ncnt % 8) == 0)
364  {
365  pbuf[bcnt] = '.';
366  bcnt --;
367  }
368  pbuf[bcnt] = (nval & (1 << ncnt))? '1' : '0';
369  }
370  }
371 
372  return pbuf;
373 }
374 */
375 
376 unsigned string_hash_function(const char* p)
377 {
378  unsigned h = 0, g;
379  while(*p) {
380  h = (h << 4) + *p++;
381  if ((g = h & 0xF0000000) != 0) {
382  h ^= g >> 24;
383  }
384  h &= ~g;
385  }
386  return h;
387 }
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 const char* CExprParserException::GetErrCodeString(void) const
391 {
392  switch (GetErrCode()) {
393  case eParseError: return "eParseError";
394  case eTypeConversionError: return "eTypeConversionError";
395  default:
396  break;
397  }
398 
400 }
401 
403 {
404  out << "pos: " << m_Pos;
405 }
406 
408 {
410 
411  const CExprParserException& other = dynamic_cast<const CExprParserException&>(src);
412  m_Pos = other.m_Pos;
413 }
414 
415 ////////////////////////////////////////////////////////////////////////////////
417 : m_Buf(NULL)
418 , m_Pos(0)
419 , m_ParserFlags(ParserFlags)
420 {
421  memset(hash_table, 0, sizeof(hash_table));
422 
424  AddSymbol("acos", (CExprSymbol::FFloatFunc1)acos);
425  AddSymbol("asin", (CExprSymbol::FFloatFunc1)asin);
426  AddSymbol("atan", (CExprSymbol::FFloatFunc1)atan);
427  AddSymbol("atan2", (CExprSymbol::FFloatFunc2)atan2);
428  AddSymbol("cos", (CExprSymbol::FFloatFunc1)cos);
429  AddSymbol("cosh", (CExprSymbol::FFloatFunc1)cosh);
430  AddSymbol("exp", (CExprSymbol::FFloatFunc1)exp);
433  AddSymbol("sin", (CExprSymbol::FFloatFunc1)sin);
434  AddSymbol("sinh", (CExprSymbol::FFloatFunc1)sinh);
435  AddSymbol("tan", (CExprSymbol::FFloatFunc1)tan);
436  AddSymbol("tanh", (CExprSymbol::FFloatFunc1)tanh);
437  AddSymbol("sqrt", (CExprSymbol::FFloatFunc1)sqrt);
438 
439  AddSymbol("float", to_float);
440  AddSymbol("int", to_int);
441 
442  AddSymbol("gcd", gcd);
443  AddSymbol("invmod", invmod);
444 
445  AddSymbol("prime", prime);
446 
447  AddSymbol("pi", 3.1415926535897932385E0);
448  AddSymbol("e", 2.7182818284590452354E0);
449 }
450 
452 {
453  for (int i = 0; i < hash_table_size; ++i) {
454  delete hash_table[i];
455  }
456 }
457 
458 int CExprParser::sm_lpr[eTERMINALS] = {
459  2, 0, 0, 0, // eBEGIN, eOPERAND, eERROR, eEND,
460  4, 4, // eLPAR, eRPAR
461  5, 98, 98, // eFUNC, ePOSTINC, ePOSTDEC,
462  98, 98, 98, 98, 98, 98, // ePREINC, ePREDEC, ePLUS, eMINUS, eNOT, eCOM,
463  90, // ePOW,
464  80, 80, 80, // eMUL, eDIV, eMOD,
465  70, 70, // eADD, eSUB,
466  60, 60, 60, // eASL, eASR, eLSR,
467  50, 50, 50, 50, // eGT, eGE, eLT, eLE,
468  40, 40, // eEQ, eNE,
469  38, // eAND,
470  36, // eXOR,
471  34, // eOR,
472  20, 20, 20, 20, 20, 20, 20, //eSET, eSETADD, eSETSUB, eSETMUL, eSETDIV, eSETMOD,
473  20, 20, 20, 20, 20, 20, // eSETASL, eSETASR, eSETLSR, eSETAND, eSETXOR, eSETOR,
474  10 // eCOMMA
475 };
476 
477 int CExprParser::sm_rpr[eTERMINALS] = {
478  0, 0, 0, 1, // eBEGIN, eOPERAND, eERROR, eEND,
479  110, 3, // eLPAR, eRPAR
480  120, 99, 99, // eFUNC, ePOSTINC, ePOSTDEC
481  99, 99, 99, 99, 99, 99, // ePREINC, ePREDEC, ePLUS, eMINUS, eNOT, eCOM,
482  95, // ePOW,
483  80, 80, 80, // eMUL, eDIV, eMOD,
484  70, 70, // eADD, eSUB,
485  60, 60, 60, // eASL, eASR, eLSR,
486  50, 50, 50, 50, // eGT, eGE, eLT, eLE,
487  40, 40, // eEQ, eNE,
488  38, // eAND,
489  36, // eXOR,
490  34, // eOR,
491  25, 25, 25, 25, 25, 25, 25, //eSET, eSETADD, eSETSUB, eSETMUL, eSETDIV, eSETMOD,
492  25, 25, 25, 25, 25, 25, // eSETASL, eSETASR, eSETLSR, eSETAND, eSETXOR, eSETOR,
493  15 // eCOMMA
494 };
495 
496 CExprSymbol* CExprParser::GetSymbol(const char* name) const
497 {
498  unsigned h = string_hash_function(name) % hash_table_size;
499  CExprSymbol* sp = NULL;
500 
501  for (sp = hash_table[h]; sp != NULL; sp = sp->m_Next) {
502  if (sp->m_Name.compare(name) == 0) {
503  return sp;
504  }
505  }
506 
507  return sp;
508 }
509 
511 CExprParser::Scan(bool operand)
512 {
513  char sym_name[max_expression_length], *np;
514 
515  while (isspace(m_Buf[m_Pos])) m_Pos += 1;
516 
517  switch (m_Buf[m_Pos++]) {
518  case '\0':
519  return eEND;
520  case '(':
521  return eLPAR;
522  case ')':
523  return eRPAR;
524  case '+':
525  if (m_Buf[m_Pos] == '+') {
526  m_Pos += 1;
527  return operand ? ePREINC : ePOSTINC;
528  } else if (m_Buf[m_Pos] == '=') {
529  m_Pos += 1;
530  return eSETADD;
531  }
532  return operand ? ePLUS : eADD;
533  case '-':
534  if (m_Buf[m_Pos] == '-') {
535  m_Pos += 1;
536  return operand ? ePREDEC : ePOSTDEC;
537  } else if (m_Buf[m_Pos] == '=') {
538  m_Pos += 1;
539  return eSETSUB;
540  }
541  return operand ? eMINUS : eSUB;
542  case '!':
543  return IfChar('=', eNE, eNOT);
544  case '~':
545  return eCOM;
546  case '*':
547  return IfLongest2ElseChar('*', '=', eSETPOW, ePOW, eSETMUL, eMUL);
548  case '/':
549  if(LogicalOnly())
550  goto l_SkipDivision; // goto to default is justified - complete code refactoring otherwise (MZ)
551  return IfChar('=', eSETDIV, eDIV);
552  case '%':
553  return IfChar('=', eSETMOD, eMOD);
554  case '<':
555  return IfLongest2ElseChar('<', '=', eSETASL, eASL, eLE, eLT);
556  case '>':
557  if (m_Buf[m_Pos] == '>') {
558  if (m_Buf[m_Pos+1] == '>') {
559  if (m_Buf[m_Pos+2] == '=') {
560  m_Pos += 3;
561  return eSETLSR;
562  }
563  m_Pos += 2;
564  return eLSR;
565  } else if (m_Buf[m_Pos+1] == '=') {
566  m_Pos += 2;
567  return eSETASR;
568  } else {
569  m_Pos += 1;
570  return eASR;
571  }
572  } else if (m_Buf[m_Pos] == '=') {
573  m_Pos += 1;
574  return eGE;
575  }
576  return eGT;
577  case '=':
578  return IfChar('=', eEQ, eSET);
579  case '&':
580  return IfElseChar(
581  '&', eAND,
582  '=', eSETAND,
583  eAND);
584  case '|':
585  return IfElseChar(
586  '|', eOR,
587  '=', eSETOR,
588  eOR);
589  case '^':
590  return IfChar('=', eSETXOR, eXOR);
591  case ',':
592  return eCOMMA;
593  case '0': case '1': case '2': case '3': case '4':
594  case '5': case '6': case '7': case '8': case '9':
595  if(LogicalOnly())
596  goto l_SkipDivision; // goto default justified to avoid code refactoring
597  {
598  Int8 ival;
599  double fval;
600  int ierr, ferr;
601  char *ipos;
602  char *fpos;
603 
604 #ifdef NCBI_OS_MSWIN
605  int n = 0;
606  ierr = sscanf(m_Buf+m_Pos-1, "%I64i%n", &ival, &n) != 1;
607  ipos = const_cast<char*>(m_Buf+m_Pos-1+n);
608 #else
609  errno = 0;
610 #if SIZEOF_LONG == 8
611  ival = strtoul(m_Buf+m_Pos-1, &ipos, 0);
612 #else
613  ival = strtoull(m_Buf+m_Pos-1, &ipos, 0);
614 #endif
615  ierr = errno;
616 #endif
617  errno = 0;
618  fval = strtod(m_Buf+m_Pos-1, &fpos);
619  ferr = errno;
620 
621  if (ierr && ferr) {
622  ReportError("bad numeric constant");
623  return eERROR;
624  }
625 
626  if (m_v_sp == max_stack_size) {
627  ReportError("stack overflow");
628  return eERROR;
629  }
630 
631  if (!ierr && ipos >= fpos) {
633  m_VStack[m_v_sp].ival = ival;
634  m_Pos = (int)(ipos - m_Buf);
635  } else {
637  m_VStack[m_v_sp].fval = fval;
638  m_Pos = (int)(fpos - m_Buf);
639  }
640 
642  m_VStack[m_v_sp++].m_Var = NULL;
643 
644  return eOPERAND;
645  }
646 
647  case '"': // String literal case
648  {
649  string StringConstant(m_Buf+m_Pos); // Not including the \"
650  size_t pos=StringConstant.find('"');
651 
652  StringConstant = StringConstant.substr(0, pos);
653 
655 
656  m_VStack[m_v_sp].m_sval = StringConstant; //assign string
657  m_Pos += (int)pos+1; // move m_Pos
658 
661  m_v_sp++;
662 
663  return eOPERAND;
664  }
665 
666  default:
667  l_SkipDivision:
668  m_Pos -= 1;
669  np = sym_name;
670 
671  while (isalnum(m_Buf[m_Pos]) || m_Buf[m_Pos] == '$' || m_Buf[m_Pos] == '_' || (((m_Buf[m_Pos]=='/') || (m_Buf[m_Pos]=='.') ) && LogicalOnly())) {
672  *np++ = m_Buf[m_Pos++];
673  }
674 
675  if (np == m_Buf) {
676  ReportError("Bad character");
677  return eERROR;
678  }
679 
680  *np = '\0';
681 
682  // Check for true/false ...
683  if (strcmp(sym_name, "true") == 0) {
685  m_VStack[m_v_sp].bval = true;
686 
688  m_VStack[m_v_sp++].m_Var = NULL;
689 
690  return eOPERAND;
691  } else if (strcmp(sym_name, "false") == 0) {
693  m_VStack[m_v_sp].bval = false;
694 
696  m_VStack[m_v_sp++].m_Var = NULL;
697 
698  return eOPERAND;
699  }
700 
701  CExprSymbol* sym = NULL;
702 
704  sym = AddSymbol(sym_name, Int8(0));
705  } else {
706  sym = GetSymbol(sym_name);
707  if (!sym) {
708  ReportError(string("Invalid symbol name: ") + sym_name);
709  return eERROR;
710  }
711  }
712 
713  if (m_v_sp == max_stack_size) {
714  ReportError("stack overflow");
715  return eERROR;
716  }
717 
718  m_VStack[m_v_sp] = sym->m_Val;
720  m_VStack[m_v_sp++].m_Var = sym;
721 
722  return (sym->m_Tag == CExprSymbol::eVARIABLE) ? eOPERAND : eFUNC;
723  }
724 }
725 
727 {
728  CExprValue& v = m_VStack[m_v_sp-1];
729  if (v.m_Var == NULL) {
730  ReportError(v.m_Pos, "variable expected");
731  return false;
732  } else {
733  v.m_Var->m_Val = v;
734  return true;
735  }
736 }
737 
738 void CExprParser::Parse(const char* str)
739 {
740  // char var_name[16];
741  m_Buf = str;
742  m_v_sp = 0;
743  m_o_sp = 0;
744  m_Pos = 0;
745  m_OStack[m_o_sp++] = eBEGIN;
746  bool operand = true;
747  int n_args = 0;
748 
749  while (true) {
750  next_token:
751  int op_pos = m_Pos;
752 
753  EOperator oper = Scan(operand);
754 
755  if (oper == eERROR) {
756  return;
757  }
758 
759  if (!operand) {
760  if (!BINARY(oper) && oper != eEND && oper != ePOSTINC
761  && oper != ePOSTDEC && oper != eRPAR)
762  {
763  ReportError(op_pos, "operator expected");
764  return;
765  }
766  if (oper != ePOSTINC && oper != ePOSTDEC && oper != eRPAR) {
767  operand = true;
768  }
769  } else {
770  if (oper == eOPERAND) {
771  operand = false;
772  n_args += 1;
773  continue;
774  }
775  if (BINARY(oper) || oper == eRPAR) {
776  ReportError(op_pos, "operand expected");
777  return;
778  }
779  }
780 
781  n_args = 1;
782 
783  while (sm_lpr[m_OStack[m_o_sp-1]] >= sm_rpr[oper]) {
784  int cop = m_OStack[--m_o_sp];
785 
786  switch (cop) {
787  case eBEGIN:
788  if (oper == eRPAR) {
789  ReportError("Unmatched ')'");
790  return;
791  }
792 
793  if (oper != eEND) {
794  ReportError("Unexpected end of input");
795  }
796 
797  if (m_v_sp == 1) {
798  return;
799  } else if (m_v_sp != 0) {
800  ReportError("Unexpected end of expression");
801  }
802 
803  return;
804  case eCOMMA:
805  n_args += 1;
806  continue;
807  case eADD:
808  case eSETADD:
809  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
811  } else if(m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING && m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING) {
812  m_VStack[m_v_sp-2].m_sval += m_VStack[m_v_sp-1].m_sval; // string concatenation
813  } else {
814  m_VStack[m_v_sp-2].fval =
817  }
818 
819  m_v_sp -= 1;
820 
821  if (cop == eSETADD) {
822  if (!Assign()) return;
823  }
824 
825  m_VStack[m_v_sp-1].m_Var = NULL;
826  break;
827  case eSUB:
828  case eSETSUB:
829  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
830  ReportError("Can not subtract string literals");
831  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
833  } else {
834  m_VStack[m_v_sp-2].fval =
837  }
838 
839  m_v_sp -= 1;
840 
841  if (cop == eSETSUB) {
842  if (!Assign()) return;
843  }
844 
845  m_VStack[m_v_sp-1].m_Var = NULL;
846 
847  break;
848  case eMUL:
849  case eSETMUL:
850  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
851  ReportError("Can not mupltiply string literals");
852 
853  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
855  } else {
856  m_VStack[m_v_sp-2].fval =
859  }
860 
861  m_v_sp -= 1;
862 
863  if (cop == eSETMUL) {
864  if (!Assign()) return;
865  }
866  m_VStack[m_v_sp-1].m_Var = NULL;
867 
868  break;
869  case eDIV:
870  case eSETDIV:
871  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
872  ReportError("Can not divide string literals");
873 
874  if (m_VStack[m_v_sp-1].GetDouble() == 0.0) {
875  ReportError(m_VStack[m_v_sp-2].m_Pos, "Division by zero");
876  return;
877  }
878  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
880  } else {
881  m_VStack[m_v_sp-2].fval =
884  }
885  m_v_sp -= 1;
886  if (cop == eSETDIV) {
887  if (!Assign()) return;
888  }
889  m_VStack[m_v_sp-1].m_Var = NULL;
890  break;
891  case eMOD:
892  case eSETMOD:
893  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
894  ReportError("Can not divide string literals");
895 
896  if (m_VStack[m_v_sp-1].GetDouble() == 0.0) {
897  ReportError(m_VStack[m_v_sp-2].m_Pos, "Division by zero");
898  return;
899  }
900  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
902  } else {
903  m_VStack[m_v_sp-2].fval =
904  fmod(m_VStack[m_v_sp-2].GetDouble(), m_VStack[m_v_sp-1].GetDouble());
906  }
907  m_v_sp -= 1;
908  if (cop == eSETMOD) {
909  if (!Assign()) return;
910  }
911  m_VStack[m_v_sp-1].m_Var = NULL;
912  break;
913  case ePOW:
914  case eSETPOW:
915  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
916  ReportError("Illegal operation on string literals");
917 
918  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
919  m_VStack[m_v_sp-2].ival =
920  (Int8)pow((double)m_VStack[m_v_sp-2].ival,
921  (double)m_VStack[m_v_sp-1].ival);
922  } else {
923  m_VStack[m_v_sp-2].fval =
924  pow(m_VStack[m_v_sp-2].GetDouble(), m_VStack[m_v_sp-1].GetDouble());
926  }
927  m_v_sp -= 1;
928  if (cop == eSETPOW) {
929  if (!Assign()) return;
930  }
931  m_VStack[m_v_sp-1].m_Var = NULL;
932  break;
933  case eAND:
934  case eSETAND:
935  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
936  ReportError("Illegal operation on string literals");
937 
938  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
940  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
941  m_VStack[m_v_sp-2].bval =
943  } else {
944  m_VStack[m_v_sp-2].ival =
947  }
948  m_v_sp -= 1;
949  if (cop == eSETAND) {
950  if (!Assign()) return;
951  }
952  m_VStack[m_v_sp-1].m_Var = NULL;
953  break;
954  case eOR:
955  case eSETOR:
956  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
957  ReportError("Illegal operation on string literals");
958 
959  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
961  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
962  m_VStack[m_v_sp-2].bval =
964  } else {
965  m_VStack[m_v_sp-2].ival =
968  }
969  m_v_sp -= 1;
970  if (cop == eSETOR) {
971  if (!Assign()) return;
972  }
973  m_VStack[m_v_sp-1].m_Var = NULL;
974  break;
975  case eXOR:
976  case eSETXOR:
977  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
978  ReportError("Illegal operation on string literals");
979 
980  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
982  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
983  m_VStack[m_v_sp-2].bval =
985  } else {
986  m_VStack[m_v_sp-2].ival =
989  }
990  m_v_sp -= 1;
991  if (cop == eSETXOR) {
992  if (!Assign()) return;
993  }
994  m_VStack[m_v_sp-1].m_Var = NULL;
995  break;
996  case eASL:
997  case eSETASL:
998  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
999  ReportError("Illegal operation on string literals");
1000 
1001  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1002  m_VStack[m_v_sp-2].ival <<= m_VStack[m_v_sp-1].ival;
1003  } else {
1004  m_VStack[m_v_sp-2].ival =
1005  m_VStack[m_v_sp-2].GetInt() << m_VStack[m_v_sp-1].GetInt();
1007  }
1008  m_v_sp -= 1;
1009  if (cop == eSETASL) {
1010  if (!Assign()) return;
1011  }
1012  m_VStack[m_v_sp-1].m_Var = NULL;
1013  break;
1014  case eASR:
1015  case eSETASR:
1016  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1017  ReportError("Illegal operation on string literals");
1018 
1019  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1020  m_VStack[m_v_sp-2].ival >>= m_VStack[m_v_sp-1].ival;
1021  } else {
1022  m_VStack[m_v_sp-2].ival =
1023  m_VStack[m_v_sp-2].GetInt() >> m_VStack[m_v_sp-1].GetInt();
1025  }
1026  m_v_sp -= 1;
1027  if (cop == eSETASR) {
1028  if (!Assign()) return;
1029  }
1030  m_VStack[m_v_sp-1].m_Var = NULL;
1031  break;
1032  case eLSR:
1033  case eSETLSR:
1034  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1035  ReportError("Illegal operation on string literals");
1036 
1037  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1038  m_VStack[m_v_sp-2].ival =
1039  (Uint8)m_VStack[m_v_sp-2].ival >> m_VStack[m_v_sp-1].ival;
1040  } else {
1041  m_VStack[m_v_sp-2].ival = (Uint8)m_VStack[m_v_sp-2].GetInt()
1042  >> m_VStack[m_v_sp-1].GetInt();
1044  }
1045  m_v_sp -= 1;
1046  if (cop == eSETLSR) {
1047  if (!Assign()) return;
1048  }
1049  m_VStack[m_v_sp-1].m_Var = NULL;
1050  break;
1051  case eEQ:
1052  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1053  m_VStack[m_v_sp-2].bval =
1056  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1057  m_VStack[m_v_sp-2].bval =
1059  } else if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING && m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING) {
1060  m_VStack[m_v_sp-2].bval =
1063  } else {
1064  m_VStack[m_v_sp-2].bval =
1067  }
1068  m_v_sp -= 1;
1069  m_VStack[m_v_sp-1].m_Var = NULL;
1070  break;
1071  case eNE:
1072  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1073  m_VStack[m_v_sp-2].bval =
1076  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1077  m_VStack[m_v_sp-2].bval =
1079  } else if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING && m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING) {
1080  m_VStack[m_v_sp-2].bval =
1083  } else {
1084  m_VStack[m_v_sp-2].bval =
1087  }
1088  m_v_sp -= 1;
1089  m_VStack[m_v_sp-1].m_Var = NULL;
1090  break;
1091  case eGT:
1093  ReportError("Illegal operation on string literals");
1094 
1095  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1096  m_VStack[m_v_sp-2].bval =
1099  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1100  m_VStack[m_v_sp-2].bval =
1102  } else {
1103  m_VStack[m_v_sp-2].bval =
1106  }
1107  m_v_sp -= 1;
1108  m_VStack[m_v_sp-1].m_Var = NULL;
1109  break;
1110  case eGE:
1112  ReportError("Illegal operation on string literals");
1113 
1114  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1115  m_VStack[m_v_sp-2].bval =
1118  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1119  m_VStack[m_v_sp-2].bval =
1121  } else {
1122  m_VStack[m_v_sp-2].bval =
1125  }
1126  m_v_sp -= 1;
1127  m_VStack[m_v_sp-1].m_Var = NULL;
1128  break;
1129  case eLT:
1131  ReportError("Illegal operation on string literals");
1132 
1133  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1134  m_VStack[m_v_sp-2].bval =
1137  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1138  m_VStack[m_v_sp-2].bval =
1140  } else {
1141  m_VStack[m_v_sp-2].bval =
1144  }
1145  m_v_sp -= 1;
1146  m_VStack[m_v_sp-1].m_Var = NULL;
1147  break;
1148  case eLE:
1150  ReportError("Illegal operation on string literals");
1151 
1152  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT && m_VStack[m_v_sp-2].GetType() == CExprValue::eINT) {
1153  m_VStack[m_v_sp-2].bval =
1156  } else if (m_VStack[m_v_sp-2].GetType() == CExprValue::eBOOL) {
1157  m_VStack[m_v_sp-2].bval =
1159  } else {
1160  m_VStack[m_v_sp-2].bval =
1163  }
1164  m_v_sp -= 1;
1165  m_VStack[m_v_sp-1].m_Var = NULL;
1166  break;
1167  case ePREINC:
1169  ReportError("Illegal operation on string literals");
1170 
1171  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT) {
1172  m_VStack[m_v_sp-1].ival += 1;
1173  } else {
1174  m_VStack[m_v_sp-1].fval += 1;
1175  }
1176  if (!Assign()) return;
1177  m_VStack[m_v_sp-1].m_Var = NULL;
1178  break;
1179  case ePREDEC:
1180  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT) {
1181  m_VStack[m_v_sp-1].ival -= 1;
1182  } else {
1183  m_VStack[m_v_sp-1].fval -= 1;
1184  }
1185  if (!Assign()) return;
1186  m_VStack[m_v_sp-1].m_Var = NULL;
1187  break;
1188  case ePOSTINC:
1190  ReportError("Illegal operation on string literals");
1191 
1192  if (m_VStack[m_v_sp-1].m_Var == NULL) {
1193  ReportError(m_VStack[m_v_sp-1].m_Pos, "Varaibale expected");
1194  return;
1195  }
1196  if (m_VStack[m_v_sp-1].m_Var->m_Val.GetType() == CExprValue::eINT) {
1197  m_VStack[m_v_sp-1].m_Var->m_Val.ival += 1;
1198  } else {
1199  m_VStack[m_v_sp-1].m_Var->m_Val.fval += 1;
1200  }
1201  m_VStack[m_v_sp-1].m_Var = NULL;
1202  break;
1203  case ePOSTDEC:
1204  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1205  ReportError("Illegal operation on string literals");
1206 
1207  if (m_VStack[m_v_sp-1].m_Var == NULL) {
1208  ReportError(m_VStack[m_v_sp-1].m_Pos, "Varaibale expected");
1209  return;
1210  }
1211  if (m_VStack[m_v_sp-1].m_Var->m_Val.GetType() == CExprValue::eINT) {
1212  m_VStack[m_v_sp-1].m_Var->m_Val.ival -= 1;
1213  } else {
1214  m_VStack[m_v_sp-1].m_Var->m_Val.fval -= 1;
1215  }
1216  m_VStack[m_v_sp-1].m_Var = NULL;
1217  break;
1218  case eSET:
1219  if (m_VStack[m_v_sp-2].m_Var == NULL) {
1220  ReportError(m_VStack[m_v_sp-2].m_Pos, "Variable expected");
1221  return;
1222  } else {
1224  }
1225  m_v_sp -= 1;
1226  m_VStack[m_v_sp-1].m_Var = NULL;
1227  break;
1228  case eNOT:
1229  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1230  ReportError("Illegal operation on string literals");
1231 
1232  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT) {
1234  } else if (m_VStack[m_v_sp-1].GetType() == CExprValue::eBOOL) {
1236  } else {
1239  }
1240  m_VStack[m_v_sp-1].m_Var = NULL;
1241  break;
1242  case eMINUS:
1243  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1244  ReportError("Illegal operation on string literals");
1245 
1246  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT) {
1248  } else {
1250  }
1251  // no break
1252  case ePLUS:
1253  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1254  ReportError("Illegal operation on string literals");
1255 
1256  m_VStack[m_v_sp-1].m_Var = NULL;
1257  break;
1258  case eCOM:
1259  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eSTRING || m_VStack[m_v_sp-2].GetType() == CExprValue::eSTRING)
1260  ReportError("Illegal operation on string literals");
1261 
1262  if (m_VStack[m_v_sp-1].GetType() == CExprValue::eINT) {
1264  } else {
1265  m_VStack[m_v_sp-1].ival = ~(int)m_VStack[m_v_sp-1].fval;
1267  }
1268  m_VStack[m_v_sp-1].m_Var = NULL;
1269  break;
1270  case eRPAR:
1271  ReportError("mismatched ')'");
1272  return;
1273  case eFUNC:
1274  ReportError("'(' expected");
1275  return;
1276  case eLPAR:
1277  if (oper != eRPAR) {
1278  ReportError("')' expected");
1279  return;
1280  }
1281  if (m_OStack[m_o_sp-1] == eFUNC) {
1282  CExprSymbol* sym = m_VStack[m_v_sp-n_args-1].m_Var;
1283 
1284  switch(sym->m_Tag) {
1285  case CExprSymbol::eIFUNC1:
1286  if (n_args != 1) {
1287  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1288  "Function should take one argument");
1289  return;
1290  }
1291  m_VStack[m_v_sp-2].ival =
1292  (*sym->m_IntFunc1)(m_VStack[m_v_sp-1].GetInt());
1294  m_v_sp -= 1;
1295  break;
1296  case CExprSymbol::eIFUNC2:
1297  if (n_args != 2) {
1298  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1299  "Function should take two arguments");
1300  return;
1301  }
1302  m_VStack[m_v_sp-3].ival =
1303  (*sym->m_IntFunc2)
1304  (m_VStack[m_v_sp-2].GetInt(), m_VStack[m_v_sp-1].GetInt());
1306  m_v_sp -= 2;
1307  break;
1308  case CExprSymbol::eFFUNC1:
1309  if (n_args != 1) {
1310  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1311  "Function should take one argument");
1312  return;
1313  }
1314  m_VStack[m_v_sp-2].fval =
1315  (*sym->m_FloatFunc1)(m_VStack[m_v_sp-1].GetDouble());
1317  m_v_sp -= 1;
1318  break;
1319  case CExprSymbol::eFFUNC2:
1320  if (n_args != 2) {
1321  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1322  "Function should take two arguments");
1323  return;
1324  }
1325  m_VStack[m_v_sp-3].fval =
1326  (*sym->m_FloatFunc2)
1327  (m_VStack[m_v_sp-2].GetDouble(), m_VStack[m_v_sp-1].GetDouble());
1329  m_v_sp -= 2;
1330  break;
1331  case CExprSymbol::eBFUNC1:
1332  if (n_args != 1) {
1333  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1334  "Function should take one argument");
1335  return;
1336  }
1337  m_VStack[m_v_sp-2].bval =
1338  (*sym->m_BoolFunc1)(m_VStack[m_v_sp-1].GetBool());
1340  m_v_sp -= 1;
1341  break;
1342  case CExprSymbol::eBFUNC2:
1343  if (n_args != 2) {
1344  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1345  "Function should take two arguments");
1346  return;
1347  }
1348  m_VStack[m_v_sp-3].bval =
1349  (*sym->m_BoolFunc2)
1350  (m_VStack[m_v_sp-2].GetBool(), m_VStack[m_v_sp-1].GetBool());
1352  m_v_sp -= 2;
1353  break;
1354  case CExprSymbol::eSFUNC1:
1355  if (n_args != 1) {
1356  ReportError(m_VStack[m_v_sp-n_args-1].m_Pos,
1357  "Function should take one argument");
1358  return;
1359  }
1360  m_VStack[m_v_sp-2].bval =
1361  (*sym->m_StringFunc1)(m_VStack[m_v_sp-1].GetString());
1363  m_v_sp -= 1;
1364  break;
1365 ;
1366  default:
1367  ReportError("Invalid expression");
1368  }
1369 
1370  m_VStack[m_v_sp-1].m_Var = NULL;
1371  m_o_sp -= 1;
1372  n_args = 1;
1373  } else if (n_args != 1) {
1374  ReportError("Function call expected");
1375  return;
1376  }
1377 
1378  goto next_token;
1379 
1380  default:
1381  ReportError("syntax ReportError");
1382  }
1383  }
1384 
1385  if (m_o_sp == max_stack_size) {
1386  ReportError("operator stack overflow");
1387  return;
1388  }
1389 
1390  m_OStack[m_o_sp++] = oper;
1391  }
1392 }
1393 
1394 
virtual void ReportExtra(ostream &out) const override
Definition: expr.cpp:402
virtual CExprParserException(const CDiagCompileInfo &info, const CException *prev_exception, EErrCode err_code, const string &message, int pos, EDiagSev severity=eDiag_Error) const char GetErrCodeString)(void) const override
Definition: expr.hpp:249
virtual void x_Assign(const CException &src) override
Definition: expr.cpp:407
@ hash_table_size
Definition: expr.hpp:354
static int sm_lpr[eTERMINALS]
Definition: expr.hpp:360
@ max_stack_size
Definition: expr.hpp:357
@ max_expression_length
Definition: expr.hpp:358
int m_Pos
Definition: expr.hpp:368
EOperator IfElseChar(char c1, EOperator val1, char c2, EOperator val2, EOperator val_def)
Definition: expr.hpp:414
CExprSymbol * hash_table[hash_table_size]
Definition: expr.hpp:355
EOperator m_OStack[max_stack_size]
Definition: expr.hpp:365
void Parse(const char *str)
Definition: expr.cpp:738
bool Assign(void)
Definition: expr.cpp:726
int TParserFlags
Definition: expr.hpp:281
CExprSymbol * AddSymbol(const char *name, VT value)
Definition: expr.hpp:382
TParserFlags AutoCreateVariable(void) const
Definition: expr.hpp:346
int m_v_sp
Definition: expr.hpp:364
EOperator IfChar(char c, EOperator val, EOperator val_def)
Definition: expr.hpp:400
bool LogicalOnly(void) const
Definition: expr.hpp:351
CExprParser(TParserFlags auto_var=0)
Definition: expr.cpp:416
@ eOPERAND
Definition: expr.hpp:303
@ ePOSTINC
Definition: expr.hpp:304
@ ePOSTDEC
Definition: expr.hpp:304
static void ReportError(int pos, const string &msg)
Definition: expr.hpp:326
EOperator IfLongest2ElseChar(char c1, char c2, EOperator val_true_longest, EOperator val_true, EOperator val_false, EOperator val_def)
Definition: expr.hpp:432
static int sm_rpr[eTERMINALS]
Definition: expr.hpp:361
@ eAllowAutoVar
Definition: expr.hpp:277
const char * m_Buf
Definition: expr.hpp:367
EOperator Scan(bool operand)
Definition: expr.cpp:511
CExprValue m_VStack[max_stack_size]
Definition: expr.hpp:363
~CExprParser(void)
Definition: expr.cpp:451
int m_o_sp
Definition: expr.hpp:366
CExprSymbol * GetSymbol(const char *name) const
Definition: expr.cpp:496
FIntFunc1 m_IntFunc1
Definition: expr.hpp:217
double(* FFloatFunc1)(double)
Definition: expr.hpp:172
FStringFunc1 m_StringFunc1
Definition: expr.hpp:223
ESymbol m_Tag
Definition: expr.hpp:215
CExprSymbol(void)
Definition: expr.cpp:140
CExprSymbol * m_Next
Definition: expr.hpp:227
~CExprSymbol(void)
Definition: expr.cpp:148
FBoolFunc1 m_BoolFunc1
Definition: expr.hpp:221
FFloatFunc1 m_FloatFunc1
Definition: expr.hpp:219
double(* FFloatFunc2)(double, double)
Definition: expr.hpp:173
string m_Name
Definition: expr.hpp:226
CExprValue m_Val
Definition: expr.hpp:225
FIntFunc2 m_IntFunc2
Definition: expr.hpp:218
FFloatFunc2 m_FloatFunc2
Definition: expr.hpp:220
@ eVARIABLE
Definition: expr.hpp:204
FBoolFunc2 m_BoolFunc2
Definition: expr.hpp:222
Int8 GetInt(void) const
Definition: expr.hpp:119
bool GetBool(void) const
Definition: expr.hpp:135
void SetType(EValue type)
Definition: expr.hpp:79
EValue GetType(void) const
Definition: expr.hpp:75
CExprSymbol * m_Var
Definition: expr.hpp:159
double GetDouble(void) const
Definition: expr.hpp:103
Int8 ival
Definition: expr.hpp:153
bool bval
Definition: expr.hpp:155
string m_sval
Definition: expr.hpp:157
double fval
Definition: expr.hpp:154
string GetString(void) const
Definition: expr.hpp:84
@ eSTRING
Definition: expr.hpp:71
@ eBOOL
Definition: expr.hpp:70
@ eINT
Definition: expr.hpp:68
@ eFLOAT
Definition: expr.hpp:69
int m_Pos
Definition: expr.hpp:160
CExprValue(void)
Definition: expr.cpp:48
char value[7]
Definition: config.c:431
std::ofstream out("events_result.xml")
main entry point for tests
static double to_float(double m_Val)
Definition: expr.cpp:287
#define BINARY(opd)
Definition: expr.cpp:42
static Int8 gcd(Int8 x, Int8 y)
Definition: expr.cpp:293
static Int8 prime(Int8 n)
Definition: expr.cpp:328
static Int8 invmod(Int8 x, Int8 y)
Definition: expr.cpp:305
static Int8 to_int(Int8 m_Val)
Definition: expr.cpp:281
unsigned string_hash_function(const char *p)
Definition: expr.cpp:376
#define NULL
Definition: ncbistd.hpp:225
virtual void x_Assign(const CException &src)
Helper method for copying exception data.
Definition: ncbiexpt.cpp:536
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
Definition: ncbiexpt.hpp:1754
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
yy_size_t n
int strcmp(const char *str1, const char *str2)
Definition: odbc_utils.hpp:160
#define fabs(v)
Definition: ncbi_dispd.c:46
unsigned int a
Definition: ncbi_localip.c:102
EIPRangeType t
Definition: ncbi_localip.c:101
int isspace(Uchar c)
Definition: ncbictype.hpp:69
int isalnum(Uchar c)
Definition: ncbictype.hpp:62
T max(T x_, T y_)
T log10(T x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const char * str(char *buf, int n)
Definition: stats.c:84
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
Definition: thrddgri.c:44
Modified on Sat Dec 02 09:20:36 2023 by modify_doxy.py rev. 669887