Mercurial > jwe > qt-gui-with-push-parser
comparison parser.h @ 12:894be158b32d
define parser as a class and eliminate some global variables
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 May 2019 17:57:20 -0400 |
parents | 0e154787183d |
children | d179b0bb85e4 |
comparison
equal
deleted
inserted
replaced
11:b652a5528fb1 | 12:894be158b32d |
---|---|
1 #if ! defined (calc_parse_h) | 1 #if ! defined (calc_parse_h) |
2 #define calc_parse_h 1 | 2 #define calc_parse_h 1 |
3 | 3 |
4 namespace parser | 4 namespace calc |
5 { | 5 { |
6 extern bool beg_of_stmt; | 6 class interpreter; |
7 | 7 |
8 extern void init (void); | 8 class parser |
9 extern void fini (void); | 9 { |
10 public: | |
10 | 11 |
11 extern int parse_and_execute (const std::string& line); | 12 parser (interpreter&); |
13 | |
14 parser (const parser&) = delete; | |
15 | |
16 parser& operator = (const parser&) = delete; | |
17 | |
18 ~parser (void); | |
19 | |
20 bool beg_of_stmt (void) const { return m_beg_of_stmt; } | |
21 | |
22 void beg_of_stmt (bool flag) { m_beg_of_stmt = flag; } | |
23 | |
24 int parse_and_execute (const std::string& line); | |
25 | |
26 void emit_error (const char *msg) const; | |
27 | |
28 void emit_result (double value) const; | |
29 | |
30 private: | |
31 | |
32 interpreter& m_interpreter; | |
33 | |
34 void *m_parser_state; | |
35 | |
36 bool m_beg_of_stmt; | |
37 }; | |
12 } | 38 } |
13 | 39 |
14 #endif | 40 #endif |