GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-except.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pt_except_h)
24 #define octave_pt_except_h 1
25 
27 
28 class tree_walker;
29 
30 #include "comment-list.h"
31 #include "pt-cmd.h"
32 #include "pt-id.h"
33 #include "symtab.h"
34 
35 // Simple exception handling.
36 
37 class
39 {
40 public:
41 
42  tree_try_catch_command (int l = -1, int c = -1)
43  : tree_command (l, c), try_code (0), catch_code (0), expr_id (0),
44  lead_comm (0), mid_comm (0), trail_comm (0) { }
45 
47  tree_identifier *id,
48  octave_comment_list *cl = 0,
49  octave_comment_list *cm = 0,
50  octave_comment_list *ct = 0,
51  int l = -1, int c = -1)
52  : tree_command (l, c), try_code (tc), catch_code (cc), expr_id (id),
53  lead_comm (cl), mid_comm (cm), trail_comm (ct) { }
54 
55  ~tree_try_catch_command (void);
56 
57  tree_identifier *identifier (void) { return expr_id; }
58 
59  tree_statement_list *body (void) { return try_code; }
60 
61  tree_statement_list *cleanup (void) { return catch_code; }
62 
63  octave_comment_list *leading_comment (void) { return lead_comm; }
64 
65  octave_comment_list *middle_comment (void) { return mid_comm; }
66 
67  octave_comment_list *trailing_comment (void) { return trail_comm; }
68 
71 
72  void accept (tree_walker& tw);
73 
74 private:
75 
76  // The first block of code to attempt to execute.
78 
79  // The code to execute if an error occurs in the first block.
81 
82  // Identifier to modify.
84 
85  // Comment preceding TRY token.
87 
88  // Comment preceding CATCH token.
90 
91  // Comment preceding END_TRY_CATCH token.
93 
94  // No copying!
95 
97 
99 };
100 
101 // Simple exception handling.
102 
103 class
105 {
106 public:
107 
108  tree_unwind_protect_command (int l = -1, int c = -1)
109  : tree_command (l, c), unwind_protect_code (0), cleanup_code (0),
110  lead_comm (0), mid_comm (0), trail_comm (0) { }
111 
114  octave_comment_list *cl = 0,
115  octave_comment_list *cm = 0,
116  octave_comment_list *ct = 0,
117  int l = -1, int c = -1)
118  : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc),
119  lead_comm (cl), mid_comm (cm), trail_comm (ct) { }
120 
122 
123  tree_statement_list *body (void) { return unwind_protect_code; }
124 
125  tree_statement_list *cleanup (void) { return cleanup_code; }
126 
127  octave_comment_list *leading_comment (void) { return lead_comm; }
128 
129  octave_comment_list *middle_comment (void) { return mid_comm; }
130 
131  octave_comment_list *trailing_comment (void) { return trail_comm; }
132 
135 
136  void accept (tree_walker& tw);
137 
138 private:
139 
140  // The first body of code to attempt to execute.
142 
143  // The body of code to execute no matter what happens in the first
144  // body of code.
146 
147  // Comment preceding UNWIND_PROTECT token.
149 
150  // Comment preceding UNWIND_PROTECT_CLEANUP token.
152 
153  // Comment preceding END_UNWIND_PROTECT token.
155 
156  // No copying!
157 
159 
161 };
162 
163 #endif