Mercurial > octave
annotate libinterp/parse-tree/pt.h @ 23219:3ac9f9ecfae5 stable
maint: Update copyright dates.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Feb 2017 12:39:29 -0500 |
parents | e9a0469dedd9 |
children | 092078913d54 |
rev | line source |
---|---|
2987 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2987 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2987 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2987 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_pt_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
24 #define octave_pt_h 1 |
2987 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21157
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21157
diff
changeset
|
27 |
2991 | 28 #include <string> |
29 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
30 #include <iosfwd> |
2991 | 31 |
4748 | 32 class octave_function; |
2987 | 33 class tree_walker; |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
34 class bp_table; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
35 bool meets_condition (std::string *); |
2987 | 36 |
37 // Base class for the parse tree. | |
38 | |
39 class | |
40 tree | |
41 { | |
42 public: | |
43 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
44 tree (int l = -1, int c = -1) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
45 : line_num (l), column_num (c), bp (NULL) { } |
2987 | 46 |
47 virtual ~tree (void) { } | |
48 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
49 virtual int line (void) const { return line_num; } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
50 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
51 virtual int column (void) const { return column_num; } |
2987 | 52 |
8843
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
53 void line (int l) { line_num = l; } |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
54 |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
55 void column (int c) { column_num = c; } |
2987 | 56 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
57 void set_location (int l, int c) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
58 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
59 line_num = l; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
60 column_num = c; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
61 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
62 |
21333
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
63 virtual void set_breakpoint (const std::string& condition) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
64 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
65 if (bp) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
66 *bp = condition; |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
67 else |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 bp = new std::string(condition); |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
69 } |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
70 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
71 virtual void delete_breakpoint (void) { if (bp) delete bp; bp = NULL; } |
8843
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
72 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
73 bool meets_bp_condition (void) const; |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
74 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
75 bool is_breakpoint (bool check_active = false) const |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
76 { return bp && (!check_active || meets_bp_condition ()); } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
77 |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
78 // breakpoint condition, or "0" (i.e., "false") if no breakpoint. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
79 // To distinguish "0" from a disabled breakpoint, test "is_breakpoint" too. |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
80 const std::string bp_cond (void) const |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 { return bp ? *bp : std::string("0"); } |
2987 | 82 |
3523 | 83 std::string str_print_code (void); |
2991 | 84 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7818
diff
changeset
|
85 virtual void accept (tree_walker& tw) = 0; |
3772 | 86 |
2987 | 87 private: |
88 | |
89 // The input line and column where we found the text that was | |
90 // eventually converted to this tree node. | |
91 int line_num; | |
92 int column_num; | |
93 | |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
94 // Breakpoint flag: NULL if no breakpoint, or the condition if there is one |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20791
diff
changeset
|
95 std::string *bp; |
3770 | 96 |
2987 | 97 // No copying! |
98 | |
99 tree (const tree&); | |
100 | |
101 tree& operator = (const tree&); | |
102 }; | |
103 | |
104 #endif |