annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
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
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
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
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
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
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
32 interpreter& m_interpreter;
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
33
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
34 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
35
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
36 bool 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
37 };
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 }
2
b97ffa8e4019 multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
39
b97ffa8e4019 multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
40 #endif