2982
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007 |
|
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_except_h) |
|
25 #define octave_tree_except_h 1 |
|
26 |
|
27 class tree_statement_list; |
|
28 |
|
29 class tree_walker; |
|
30 |
3665
|
31 #include "comment-list.h" |
2982
|
32 #include "pt-cmd.h" |
7336
|
33 #include "symtab.h" |
2982
|
34 |
|
35 // Simple exception handling. |
|
36 |
|
37 class |
|
38 tree_try_catch_command : public tree_command |
|
39 { |
|
40 public: |
|
41 |
|
42 tree_try_catch_command (int l = -1, int c = -1) |
3665
|
43 : tree_command (l, c), try_code (0), catch_code (0), lead_comm (0), |
|
44 mid_comm (0), trail_comm (0) { } |
2982
|
45 |
|
46 tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, |
3665
|
47 octave_comment_list *cl = 0, |
|
48 octave_comment_list *cm = 0, |
|
49 octave_comment_list *ct = 0, |
2982
|
50 int l = -1, int c = -1) |
3665
|
51 : tree_command (l, c), try_code (tc), catch_code (cc), |
|
52 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } |
2982
|
53 |
|
54 ~tree_try_catch_command (void); |
|
55 |
|
56 void eval (void); |
|
57 |
|
58 tree_statement_list *body (void) { return try_code; } |
|
59 |
|
60 tree_statement_list *cleanup (void) { return catch_code; } |
|
61 |
3665
|
62 octave_comment_list *leading_comment (void) { return lead_comm; } |
|
63 |
|
64 octave_comment_list *middle_comment (void) { return mid_comm; } |
|
65 |
|
66 octave_comment_list *trailing_comment (void) { return trail_comm; } |
|
67 |
7336
|
68 tree_command *dup (symbol_table::scope_id scope); |
5861
|
69 |
2982
|
70 void accept (tree_walker& tw); |
|
71 |
|
72 private: |
|
73 |
|
74 // The first block of code to attempt to execute. |
|
75 tree_statement_list *try_code; |
|
76 |
|
77 // The code to execute if an error occurs in the first block. |
|
78 tree_statement_list *catch_code; |
2988
|
79 |
3665
|
80 // Comment preceding TRY token. |
|
81 octave_comment_list *lead_comm; |
|
82 |
|
83 // Comment preceding CATCH token. |
|
84 octave_comment_list *mid_comm; |
|
85 |
|
86 // Comment preceding END_TRY_CATCH token. |
|
87 octave_comment_list *trail_comm; |
|
88 |
2988
|
89 // No copying! |
|
90 |
|
91 tree_try_catch_command (const tree_try_catch_command&); |
|
92 |
|
93 tree_try_catch_command& operator = (const tree_try_catch_command&); |
2982
|
94 }; |
|
95 |
|
96 // Simple exception handling. |
|
97 |
|
98 class |
|
99 tree_unwind_protect_command : public tree_command |
|
100 { |
|
101 public: |
|
102 |
|
103 tree_unwind_protect_command (int l = -1, int c = -1) |
3665
|
104 : tree_command (l, c), unwind_protect_code (0), cleanup_code (0), |
|
105 lead_comm (0), mid_comm (0), trail_comm (0) { } |
2982
|
106 |
|
107 tree_unwind_protect_command (tree_statement_list *tc, |
|
108 tree_statement_list *cc, |
3665
|
109 octave_comment_list *cl = 0, |
|
110 octave_comment_list *cm = 0, |
|
111 octave_comment_list *ct = 0, |
2982
|
112 int l = -1, int c = -1) |
3665
|
113 : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc), |
|
114 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } |
2982
|
115 |
|
116 ~tree_unwind_protect_command (void); |
|
117 |
|
118 void eval (void); |
|
119 |
|
120 tree_statement_list *body (void) { return unwind_protect_code; } |
|
121 |
|
122 tree_statement_list *cleanup (void) { return cleanup_code; } |
|
123 |
3665
|
124 octave_comment_list *leading_comment (void) { return lead_comm; } |
|
125 |
|
126 octave_comment_list *middle_comment (void) { return mid_comm; } |
|
127 |
|
128 octave_comment_list *trailing_comment (void) { return trail_comm; } |
|
129 |
7336
|
130 tree_command *dup (symbol_table::scope_id scope); |
5861
|
131 |
2982
|
132 void accept (tree_walker& tw); |
|
133 |
|
134 private: |
|
135 |
|
136 // The first body of code to attempt to execute. |
|
137 tree_statement_list *unwind_protect_code; |
|
138 |
|
139 // The body of code to execute no matter what happens in the first |
|
140 // body of code. |
|
141 tree_statement_list *cleanup_code; |
2988
|
142 |
3665
|
143 // Comment preceding TRY token. |
|
144 octave_comment_list *lead_comm; |
|
145 |
|
146 // Comment preceding CATCH token. |
|
147 octave_comment_list *mid_comm; |
|
148 |
|
149 // Comment preceding END_TRY_CATCH token. |
|
150 octave_comment_list *trail_comm; |
|
151 |
2988
|
152 // No copying! |
|
153 |
|
154 tree_unwind_protect_command (const tree_unwind_protect_command&); |
|
155 |
|
156 tree_unwind_protect_command& operator = (const tree_unwind_protect_command&); |
2982
|
157 }; |
|
158 |
|
159 #endif |
|
160 |
|
161 /* |
|
162 ;;; Local Variables: *** |
|
163 ;;; mode: C++ *** |
|
164 ;;; End: *** |
|
165 */ |