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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_except_h) |
|
24 #define octave_tree_except_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2982
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class tree_statement_list; |
|
31 |
|
32 class tree_walker; |
|
33 |
3665
|
34 #include "comment-list.h" |
2982
|
35 #include "pt-cmd.h" |
|
36 |
|
37 // Simple exception handling. |
|
38 |
|
39 class |
|
40 tree_try_catch_command : public tree_command |
|
41 { |
|
42 public: |
|
43 |
|
44 tree_try_catch_command (int l = -1, int c = -1) |
3665
|
45 : tree_command (l, c), try_code (0), catch_code (0), lead_comm (0), |
|
46 mid_comm (0), trail_comm (0) { } |
2982
|
47 |
|
48 tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, |
3665
|
49 octave_comment_list *cl = 0, |
|
50 octave_comment_list *cm = 0, |
|
51 octave_comment_list *ct = 0, |
2982
|
52 int l = -1, int c = -1) |
3665
|
53 : tree_command (l, c), try_code (tc), catch_code (cc), |
|
54 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } |
2982
|
55 |
|
56 ~tree_try_catch_command (void); |
|
57 |
|
58 void eval (void); |
|
59 |
|
60 tree_statement_list *body (void) { return try_code; } |
|
61 |
|
62 tree_statement_list *cleanup (void) { return catch_code; } |
|
63 |
3665
|
64 octave_comment_list *leading_comment (void) { return lead_comm; } |
|
65 |
|
66 octave_comment_list *middle_comment (void) { return mid_comm; } |
|
67 |
|
68 octave_comment_list *trailing_comment (void) { return trail_comm; } |
|
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 |
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 */ |