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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
1 /*
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
4
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
6
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5388
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5388
diff changeset
10 option) any later version.
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
11
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
15 for more details.
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
16
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5388
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5388
diff changeset
19 <http://www.gnu.org/licenses/>.
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
20
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
21 */
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2987
diff changeset
28 #include <string>
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2987
diff changeset
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
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2987
diff changeset
31
4748
7b145222fea3 [project @ 2004-02-07 06:27:27 by jwe]
jwe
parents: 4192
diff changeset
32 class octave_function;
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
36
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
37 // Base class for the parse tree.
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
38
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
39 class
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
40 tree
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
41 {
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
42 public:
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
46
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
47 virtual ~tree (void) { }
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
82
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
83 std::string str_print_code (void);
2991
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2987
diff changeset
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
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3770
diff changeset
86
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
87 private:
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
88
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
89 // The input line and column where we found the text that was
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
90 // eventually converted to this tree node.
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
91 int line_num;
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
92 int column_num;
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
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
bf6116ca10eb [project @ 2001-02-02 02:21:40 by jwe]
jwe
parents: 3523
diff changeset
96
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
97 // No copying!
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
98
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
99 tree (const tree&);
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
100
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
101 tree& operator = (const tree&);
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
102 };
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
103
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents:
diff changeset
104 #endif