Mercurial > jwe > qt-gui-with-push-parser
annotate parser.h @ 16:bfa9aaa2d608
update NOTES
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 24 May 2019 09:22:35 -0400 |
parents | d179b0bb85e4 |
children |
rev | line source |
---|---|
2
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
1 #if ! defined (calc_parse_h) |
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
2 #define calc_parse_h 1 |
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
3 |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
4 namespace calc |
0 | 5 { |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
6 class interpreter; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
7 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
8 class parser |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
9 { |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
10 public: |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
11 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
12 parser (interpreter&); |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
13 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
14 parser (const parser&) = delete; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
15 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
16 parser& operator = (const parser&) = delete; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
17 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
18 ~parser (void); |
0 | 19 |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
20 bool beg_of_stmt (void) const { return m_beg_of_stmt; } |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
21 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
22 void beg_of_stmt (bool flag) { m_beg_of_stmt = flag; } |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
23 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
24 int parse_and_execute (const std::string& line); |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
25 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
26 void emit_error (const char *msg) const; |
0 | 27 |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
28 void emit_result (double value) const; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
29 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
30 private: |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
31 |
13
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
32 int lexer (double& token_value); |
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
33 |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
34 interpreter& m_interpreter; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
35 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
36 void *m_parser_state; |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
37 |
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
38 bool m_beg_of_stmt; |
13
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
39 |
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
40 // Auxiliary variables for lexing. |
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
41 size_t m_bufptr = 0; |
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
42 size_t m_chunk_size = 0; |
d179b0bb85e4
make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents:
12
diff
changeset
|
43 const char *m_buf; |
12
894be158b32d
define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
44 }; |
0 | 45 } |
2
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
46 |
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
47 #endif |