Bridge++  Ver. 2.0.2
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
EvalExpr::global_symbol_table
static SymbolTable global_symbol_table
Definition: evalexpr.h:73
EvalExpr::semantic_type
yy::parser::semantic_type semantic_type
Definition: evalexpr.h:43
EvalExpr
EvalExpr class for algebraic expression in parameter strings.
Definition: evalexpr.h:39
bridgeIO.h
EvalExpr::get_symbol_function
function_t get_symbol_function(char const *name)
Definition: evalexpr.cpp:216
EvalExpr::m_pos
unsigned int m_pos
Definition: evalexpr.h:68
EvalExpr::parse
double parse()
Definition: evalexpr.cpp:177
EvalExpr::token
yy::parser::token token
Definition: evalexpr.h:44
EvalExpr::error
void error(const std::string &msg)
Definition: evalexpr.cpp:223
EvalExpr::m_trace
bool m_trace
Definition: evalexpr.h:71
yy::parser::semantic_type
Symbol semantic values.
Definition: evalexpr_parser.h:79
function_t
double(* function_t)(double)
Definition: evalexpr_symbol.h:21
evalexpr_parser.h
yylex
int yylex(EvalExpr::semantic_type *yylval, EvalExpr &driver)
Definition: evalexpr.cpp:65
EvalExpr::EvalExpr
EvalExpr(const std::string &line, bool debug=false)
Definition: evalexpr.h:46
EvalExpr::set_result
void set_result(double result)
Definition: evalexpr.cpp:200
EvalExpr::next_token
int next_token(semantic_type &yylval)
Definition: evalexpr.cpp:72
EvalExpr::get_symbol_value
double get_symbol_value(char const *name)
Definition: evalexpr.cpp:209
SymbolTable
Definition: evalexpr_symbol.h:23
EvalExpr::m_result
double m_result
Definition: evalexpr.h:69
yy::parser::token
Tokens.
Definition: evalexpr_parser.h:97
evalexpr_symbol.h
EvalExpr::m_src
const std::string m_src
Definition: evalexpr.h:67
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512