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