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