Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evalexpr.h
Go to the documentation of this file.
1 
13 #ifndef EVALEXPR_INCLUDED
14 #define EVALEXPR_INCLUDED
15 
16 #include <map>
17 #include <string>
18 #include <cstring>
19 
20 #include "evalexpr_parser.h"
21 #include "evalexpr_symbol.h"
22 
23 #include "bridgeIO.h"
24 using Bridge::vout;
25 
27 
38 class EvalExpr
39 {
40  public:
41 
44 
45  EvalExpr(const std::string& line, bool debug = false)
46  : m_src(line), m_pos(0), m_result(0),
47  m_trace(debug) {}
48 
49  // lexer
50  int next_token(semantic_type& yylval);
51 
52  // parse
53 // bool parse(double& result);
54  double parse();
55 
56  // symbol_table manipulation
57  double get_symbol_value(char const *name);
58  function_t get_symbol_function(char const *name);
59 
60  // parser interface
61  void set_result(double result);
62 
63  void error(const std::string& msg);
64 
65  private:
66 
67  const std::string m_src;
68  unsigned int m_pos;
69  double m_result;
70 
71  bool m_trace;
72 
74 };
75 
76 
77 // lexer interface for parser
78 int yylex(EvalExpr::semantic_type *yylval, EvalExpr& driver);
79 
80 #endif
BridgeIO vout
Definition: bridgeIO.cpp:207
void error(const std::string &msg)
Definition: evalexpr.cpp:226
yy::parser::token token
Definition: evalexpr.h:43
function_t get_symbol_function(char const *name)
Definition: evalexpr.cpp:220
double parse()
Definition: evalexpr.cpp:188
static SymbolTable global_symbol_table
Definition: evalexpr.h:73
int yylex(EvalExpr::semantic_type *yylval, EvalExpr &driver)
Definition: evalexpr.cpp:55
unsigned int m_pos
Definition: evalexpr.h:68
bool m_trace
Definition: evalexpr.h:71
Symbol semantic values.
EvalExpr(const std::string &line, bool debug=false)
Definition: evalexpr.h:45
EvalExpr class for algebraic expression in parameter strings.
Definition: evalexpr.h:38
double m_result
Definition: evalexpr.h:69
double get_symbol_value(char const *name)
Definition: evalexpr.cpp:214
double(* function_t)(double)
void set_result(double result)
Definition: evalexpr.cpp:206
yy::parser::semantic_type semantic_type
Definition: evalexpr.h:42
int next_token(semantic_type &yylval)
Definition: evalexpr.cpp:61
const std::string m_src
Definition: evalexpr.h:67