Mercurial > hg > octave-nkf
annotate src/pt-select.h @ 12113:232a0ddce7cd release-3-2-x
toplev.cc: handle exceptions while preparing to exit
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 Jul 2009 14:24:45 -0400 |
parents | eb63fbe60fab |
children | cd96d29c5efa |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
2982 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2982 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_select_h) | |
25 #define octave_tree_select_h 1 | |
26 | |
27 class expression; | |
28 class tree_statement_list; | |
29 | |
30 class tree_walker; | |
31 | |
4219 | 32 #include "base-list.h" |
3665 | 33 #include "comment-list.h" |
2982 | 34 #include "pt-cmd.h" |
7336 | 35 #include "symtab.h" |
2982 | 36 |
37 // If. | |
38 | |
39 class | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
40 tree_if_clause : public tree |
2982 | 41 { |
42 public: | |
43 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
44 tree_if_clause (int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
45 : tree (l, c), expr (0), list (0), lead_comm (0) { } |
2982 | 46 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
47 tree_if_clause (tree_statement_list *sl, octave_comment_list *lc = 0, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
48 int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
49 : tree (l, c), expr (0), list (sl), lead_comm (lc) { } |
2982 | 50 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
51 tree_if_clause (tree_expression *e, tree_statement_list *sl, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
52 octave_comment_list *lc = 0, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
53 int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
54 : tree (l, c), expr (e), list (sl), lead_comm (lc) { } |
2982 | 55 |
56 ~tree_if_clause (void); | |
57 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
58 bool is_else_clause (void) { return ! expr; } |
2982 | 59 |
60 tree_expression *condition (void) { return expr; } | |
61 | |
62 tree_statement_list *commands (void) { return list; } | |
63 | |
3665 | 64 octave_comment_list *leading_comment (void) { return lead_comm; } |
65 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
66 tree_if_clause *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
67 symbol_table::context_id context) const; |
5861 | 68 |
2982 | 69 void accept (tree_walker& tw); |
70 | |
71 private: | |
72 | |
73 // The condition to test. | |
74 tree_expression *expr; | |
75 | |
76 // The list of statements to evaluate if expr is true. | |
77 tree_statement_list *list; | |
2988 | 78 |
3665 | 79 // Comment preceding ELSE or ELSEIF token. |
80 octave_comment_list *lead_comm; | |
81 | |
2988 | 82 // No copying! |
83 | |
84 tree_if_clause (const tree_if_clause&); | |
85 | |
86 tree_if_clause& operator = (const tree_if_clause&); | |
2982 | 87 }; |
88 | |
89 class | |
4219 | 90 tree_if_command_list : public octave_base_list<tree_if_clause *> |
2982 | 91 { |
92 public: | |
93 | |
4219 | 94 tree_if_command_list (void) { } |
2982 | 95 |
4219 | 96 tree_if_command_list (tree_if_clause *t) { append (t); } |
2982 | 97 |
98 ~tree_if_command_list (void) | |
99 { | |
4219 | 100 while (! empty ()) |
2982 | 101 { |
4219 | 102 iterator p = begin (); |
103 delete *p; | |
104 erase (p); | |
2982 | 105 } |
106 } | |
107 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
108 tree_if_command_list *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
109 symbol_table::context_id context) const; |
5861 | 110 |
2982 | 111 void accept (tree_walker& tw); |
2988 | 112 |
113 private: | |
114 | |
115 // No copying! | |
116 | |
117 tree_if_command_list (const tree_if_command_list&); | |
118 | |
119 tree_if_command_list& operator = (const tree_if_command_list&); | |
2982 | 120 }; |
121 | |
122 class | |
123 tree_if_command : public tree_command | |
124 { | |
125 public: | |
126 | |
127 tree_if_command (int l = -1, int c = -1) | |
3665 | 128 : tree_command (l, c), list (0), lead_comm (0), trail_comm (0) { } |
2982 | 129 |
3665 | 130 tree_if_command (tree_if_command_list *lst, octave_comment_list *lc, |
131 octave_comment_list *tc, int l = -1, int c = -1) | |
132 : tree_command (l, c), list (lst), lead_comm (lc), trail_comm (tc) { } | |
2982 | 133 |
134 ~tree_if_command (void); | |
135 | |
8843
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
136 void set_breakpoint (void); |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
137 |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
138 void delete_breakpoint (void); |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
139 |
2982 | 140 tree_if_command_list *cmd_list (void) { return list; } |
141 | |
3665 | 142 octave_comment_list *leading_comment (void) { return lead_comm; } |
143 | |
144 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
145 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
146 tree_command *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
147 symbol_table::context_id context) const; |
5861 | 148 |
2982 | 149 void accept (tree_walker& tw); |
150 | |
151 private: | |
152 | |
153 // List of if commands (if, elseif, elseif, ... else, endif) | |
154 tree_if_command_list *list; | |
2988 | 155 |
3665 | 156 // Comment preceding IF token. |
157 octave_comment_list *lead_comm; | |
158 | |
159 // Comment preceding ENDIF token. | |
160 octave_comment_list *trail_comm; | |
161 | |
2988 | 162 // No copying! |
163 | |
164 tree_if_command (const tree_if_command&); | |
165 | |
166 tree_if_command& operator = (const tree_if_command&); | |
2982 | 167 }; |
168 | |
169 // Switch. | |
170 | |
171 class | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
172 tree_switch_case : public tree |
2982 | 173 { |
174 public: | |
175 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
176 tree_switch_case (int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
177 : tree (l, c), label (0), list (0), lead_comm (0) { } |
2982 | 178 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
179 tree_switch_case (tree_statement_list *sl, octave_comment_list *lc = 0, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
180 int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
181 : tree (l, c), label (0), list (sl), lead_comm (lc) { } |
2982 | 182 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
183 tree_switch_case (tree_expression *e, tree_statement_list *sl, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
184 octave_comment_list *lc = 0, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
185 int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
186 : tree (l, c), label (e), list (sl), lead_comm (lc) { } |
2982 | 187 |
188 ~tree_switch_case (void); | |
189 | |
3933 | 190 bool is_default_case (void) { return ! label; } |
2982 | 191 |
192 bool label_matches (const octave_value& val); | |
193 | |
194 tree_expression *case_label (void) { return label; } | |
195 | |
196 tree_statement_list *commands (void) { return list; } | |
197 | |
3665 | 198 octave_comment_list *leading_comment (void) { return lead_comm; } |
199 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
200 tree_switch_case *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
201 symbol_table::context_id context) const; |
5861 | 202 |
2982 | 203 void accept (tree_walker& tw); |
204 | |
205 private: | |
206 | |
207 // The case label. | |
208 tree_expression *label; | |
209 | |
210 // The list of statements to evaluate if the label matches. | |
211 tree_statement_list *list; | |
2988 | 212 |
3665 | 213 // Comment preceding CASE or OTHERWISE token. |
214 octave_comment_list *lead_comm; | |
215 | |
2988 | 216 // No copying! |
217 | |
218 tree_switch_case (const tree_switch_case&); | |
219 | |
220 tree_switch_case& operator = (const tree_switch_case&); | |
2982 | 221 }; |
222 | |
223 class | |
4219 | 224 tree_switch_case_list : public octave_base_list<tree_switch_case *> |
2982 | 225 { |
226 public: | |
227 | |
4219 | 228 tree_switch_case_list (void) { } |
2982 | 229 |
4219 | 230 tree_switch_case_list (tree_switch_case *t) { append (t); } |
2982 | 231 |
232 ~tree_switch_case_list (void) | |
233 { | |
4219 | 234 while (! empty ()) |
2982 | 235 { |
4219 | 236 iterator p = begin (); |
237 delete *p; | |
238 erase (p); | |
2982 | 239 } |
240 } | |
241 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
242 tree_switch_case_list *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
243 symbol_table::context_id context) const; |
5861 | 244 |
2982 | 245 void accept (tree_walker& tw); |
2988 | 246 |
247 private: | |
248 | |
249 // No copying! | |
250 | |
251 tree_switch_case_list (const tree_switch_case_list&); | |
252 | |
253 tree_switch_case_list& operator = (const tree_switch_case_list&); | |
2982 | 254 }; |
255 | |
256 class | |
257 tree_switch_command : public tree_command | |
258 { | |
259 public: | |
260 | |
261 tree_switch_command (int l = -1, int c = -1) | |
3665 | 262 : tree_command (l, c), expr (0), list (0), lead_comm (0), |
263 trail_comm (0) { } | |
2982 | 264 |
265 tree_switch_command (tree_expression *e, tree_switch_case_list *lst, | |
3665 | 266 octave_comment_list *lc, octave_comment_list *tc, |
2982 | 267 int l = -1, int c = -1) |
3665 | 268 : tree_command (l, c), expr (e), list (lst), lead_comm (lc), |
269 trail_comm (tc) { } | |
2982 | 270 |
271 ~tree_switch_command (void); | |
272 | |
8843
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
273 void set_breakpoint (void); |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
274 |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
275 void delete_breakpoint (void); |
b9ce57a309a3
don't store breakpoint info in tree_statement object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
276 |
2982 | 277 tree_expression *switch_value (void) { return expr; } |
278 | |
279 tree_switch_case_list *case_list (void) { return list; } | |
280 | |
3665 | 281 octave_comment_list *leading_comment (void) { return lead_comm; } |
282 | |
283 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
284 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
285 tree_command *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
286 symbol_table::context_id context) const; |
5861 | 287 |
2982 | 288 void accept (tree_walker& tw); |
289 | |
290 private: | |
291 | |
292 // Value on which to switch. | |
293 tree_expression *expr; | |
294 | |
295 // List of cases (case 1, case 2, ..., default) | |
296 tree_switch_case_list *list; | |
2988 | 297 |
3665 | 298 // Comment preceding SWITCH token. |
299 octave_comment_list *lead_comm; | |
300 | |
301 // Comment preceding ENDSWITCH token. | |
302 octave_comment_list *trail_comm; | |
303 | |
2988 | 304 // No copying! |
305 | |
306 tree_switch_command (const tree_switch_command&); | |
307 | |
308 tree_switch_command& operator = (const tree_switch_command&); | |
2982 | 309 }; |
310 | |
311 #endif | |
312 | |
313 /* | |
314 ;;; Local Variables: *** | |
315 ;;; mode: C++ *** | |
316 ;;; End: *** | |
317 */ |