Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evalexpr.h
Go to the documentation of this file.
1 
14 #ifndef EVALEXPR_INCLUDED
15 #define EVALEXPR_INCLUDED
16 
17 #include <map>
18 #include <string>
19 #include <cstring>
20 
21 #include "evalexpr_parser.h"
22 #include "evalexpr_symbol.h"
23 
24 #include "IO/bridgeIO.h"
25 using Bridge::vout;
26 
28 
39 class EvalExpr
40 {
41  public:
42 
45 
46  EvalExpr(const std::string& line, bool debug = false)
47  : m_src(line), m_pos(0), m_result(0),
48  m_trace(debug) {}
49 
50  // lexer
51  int next_token(semantic_type& yylval);
52 
53  // parse
54 // bool parse(double& result);
55  double parse();
56 
57  // symbol_table manipulation
58  double get_symbol_value(char const *name);
59  function_t get_symbol_function(char const *name);
60 
61  // parser interface
62  void set_result(double result);
63 
64  void error(const std::string& msg);
65 
66  private:
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:503
void error(const std::string &msg)
Definition: evalexpr.cpp:223
yy::parser::token token
Definition: evalexpr.h:44
function_t get_symbol_function(char const *name)
Definition: evalexpr.cpp:216
double parse()
Definition: evalexpr.cpp:177
static SymbolTable global_symbol_table
Definition: evalexpr.h:73
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:46
EvalExpr class for algebraic expression in parameter strings.
Definition: evalexpr.h:39
double m_result
Definition: evalexpr.h:69
double get_symbol_value(char const *name)
Definition: evalexpr.cpp:209
double(* function_t)(double)
void set_result(double result)
Definition: evalexpr.cpp:200
yy::parser::semantic_type semantic_type
Definition: evalexpr.h:43
int next_token(semantic_type &yylval)
Definition: evalexpr.cpp:72
const std::string m_src
Definition: evalexpr.h:67
int yylex(EvalExpr::semantic_type *yylval, EvalExpr &driver)
Definition: evalexpr.cpp:65