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 |
|
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 |
2982
|
66 void accept (tree_walker& tw); |
|
67 |
|
68 private: |
|
69 |
|
70 // The first block of code to attempt to execute. |
|
71 tree_statement_list *try_code; |
|
72 |
|
73 // The code to execute if an error occurs in the first block. |
|
74 tree_statement_list *catch_code; |
2988
|
75 |
3665
|
76 // Comment preceding TRY token. |
|
77 octave_comment_list *lead_comm; |
|
78 |
|
79 // Comment preceding CATCH token. |
|
80 octave_comment_list *mid_comm; |
|
81 |
|
82 // Comment preceding END_TRY_CATCH token. |
|
83 octave_comment_list *trail_comm; |
|
84 |
2988
|
85 // No copying! |
|
86 |
|
87 tree_try_catch_command (const tree_try_catch_command&); |
|
88 |
|
89 tree_try_catch_command& operator = (const tree_try_catch_command&); |
2982
|
90 }; |
|
91 |
|
92 // Simple exception handling. |
|
93 |
|
94 class |
|
95 tree_unwind_protect_command : public tree_command |
|
96 { |
|
97 public: |
|
98 |
|
99 tree_unwind_protect_command (int l = -1, int c = -1) |
3665
|
100 : tree_command (l, c), unwind_protect_code (0), cleanup_code (0), |
|
101 lead_comm (0), mid_comm (0), trail_comm (0) { } |
2982
|
102 |
|
103 tree_unwind_protect_command (tree_statement_list *tc, |
|
104 tree_statement_list *cc, |
3665
|
105 octave_comment_list *cl = 0, |
|
106 octave_comment_list *cm = 0, |
|
107 octave_comment_list *ct = 0, |
2982
|
108 int l = -1, int c = -1) |
3665
|
109 : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc), |
|
110 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } |
2982
|
111 |
|
112 ~tree_unwind_protect_command (void); |
|
113 |
|
114 void eval (void); |
|
115 |
|
116 tree_statement_list *body (void) { return unwind_protect_code; } |
|
117 |
|
118 tree_statement_list *cleanup (void) { return cleanup_code; } |
|
119 |
3665
|
120 octave_comment_list *leading_comment (void) { return lead_comm; } |
|
121 |
|
122 octave_comment_list *middle_comment (void) { return mid_comm; } |
|
123 |
|
124 octave_comment_list *trailing_comment (void) { return trail_comm; } |
|
125 |
2982
|
126 void accept (tree_walker& tw); |
|
127 |
|
128 private: |
|
129 |
|
130 // The first body of code to attempt to execute. |
|
131 tree_statement_list *unwind_protect_code; |
|
132 |
|
133 // The body of code to execute no matter what happens in the first |
|
134 // body of code. |
|
135 tree_statement_list *cleanup_code; |
2988
|
136 |
3665
|
137 // Comment preceding TRY token. |
|
138 octave_comment_list *lead_comm; |
|
139 |
|
140 // Comment preceding CATCH token. |
|
141 octave_comment_list *mid_comm; |
|
142 |
|
143 // Comment preceding END_TRY_CATCH token. |
|
144 octave_comment_list *trail_comm; |
|
145 |
2988
|
146 // No copying! |
|
147 |
|
148 tree_unwind_protect_command (const tree_unwind_protect_command&); |
|
149 |
|
150 tree_unwind_protect_command& operator = (const tree_unwind_protect_command&); |
2982
|
151 }; |
|
152 |
|
153 #endif |
|
154 |
|
155 /* |
|
156 ;;; Local Variables: *** |
|
157 ;;; mode: C++ *** |
|
158 ;;; End: *** |
|
159 */ |