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_loop_h) |
|
24 #define octave_tree_loop_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class octave_value; |
|
31 class octave_lvalue; |
|
32 |
|
33 class tree_argument_list; |
|
34 class tree_expression; |
|
35 class tree_statement_list; |
|
36 |
|
37 class tree_walker; |
|
38 |
|
39 #include "pt-cmd.h" |
|
40 |
|
41 // While. |
|
42 |
|
43 class |
|
44 tree_while_command : public tree_command |
|
45 { |
|
46 public: |
|
47 |
|
48 tree_while_command (int l = -1, int c = -1) |
|
49 : tree_command (l, c), expr (0), list (0) { } |
|
50 |
|
51 tree_while_command (tree_expression *e, int l = -1, int c = -1) |
|
52 : tree_command (l, c), expr (e), list (0) { } |
|
53 |
|
54 tree_while_command (tree_expression *e, tree_statement_list *lst, |
|
55 int l = -1, int c = -1) |
|
56 : tree_command (l, c), expr (e), list (lst) { } |
|
57 |
|
58 ~tree_while_command (void); |
|
59 |
|
60 void eval (void); |
|
61 |
|
62 void eval_error (void); |
|
63 |
|
64 tree_expression *condition (void) { return expr; } |
|
65 |
|
66 tree_statement_list *body (void) { return list; } |
|
67 |
|
68 void accept (tree_walker& tw); |
|
69 |
3484
|
70 protected: |
2982
|
71 |
|
72 // Expression to test. |
|
73 tree_expression *expr; |
|
74 |
|
75 // List of commands to execute. |
|
76 tree_statement_list *list; |
2988
|
77 |
3484
|
78 private: |
|
79 |
2988
|
80 // No copying! |
|
81 |
|
82 tree_while_command (const tree_while_command&); |
|
83 |
|
84 tree_while_command& operator = (const tree_while_command&); |
2982
|
85 }; |
|
86 |
3484
|
87 // Do-While. |
|
88 |
|
89 class |
|
90 tree_do_while_command : public tree_while_command |
|
91 { |
|
92 public: |
|
93 |
|
94 tree_do_while_command (int l = -1, int c = -1) |
|
95 : tree_while_command (l, c) { } |
|
96 |
|
97 tree_do_while_command (tree_expression *e, int l = -1, int c = -1) |
|
98 : tree_while_command (e, l, c) { } |
|
99 |
|
100 tree_do_while_command (tree_expression *e, tree_statement_list *lst, |
|
101 int l = -1, int c = -1) |
|
102 : tree_while_command (e, lst, l, c) { } |
|
103 |
|
104 ~tree_do_while_command (void) { } |
|
105 |
|
106 void eval (void); |
|
107 |
|
108 void eval_error (void); |
|
109 |
|
110 void accept (tree_walker& tw); |
|
111 |
|
112 private: |
|
113 |
|
114 // No copying! |
|
115 |
|
116 tree_do_while_command (const tree_do_while_command&); |
|
117 |
|
118 tree_do_while_command& operator = (const tree_do_while_command&); |
|
119 }; |
|
120 |
|
121 // Do-Until. |
|
122 |
|
123 class |
|
124 tree_do_until_command : public tree_while_command |
|
125 { |
|
126 public: |
|
127 |
|
128 tree_do_until_command (int l = -1, int c = -1) |
|
129 : tree_while_command (l, c) { } |
|
130 |
|
131 tree_do_until_command (tree_expression *e, int l = -1, int c = -1) |
|
132 : tree_while_command (e, l, c) { } |
|
133 |
|
134 tree_do_until_command (tree_expression *e, tree_statement_list *lst, |
|
135 int l = -1, int c = -1) |
|
136 : tree_while_command (e, lst, l, c) { } |
|
137 |
|
138 ~tree_do_until_command (void) { } |
|
139 |
|
140 void eval (void); |
|
141 |
|
142 void eval_error (void); |
|
143 |
|
144 void accept (tree_walker& tw); |
|
145 |
|
146 private: |
|
147 |
|
148 // No copying! |
|
149 |
|
150 tree_do_until_command (const tree_do_until_command&); |
|
151 |
|
152 tree_do_until_command& operator = (const tree_do_until_command&); |
|
153 }; |
|
154 |
2982
|
155 // For. |
|
156 |
|
157 class |
|
158 tree_simple_for_command : public tree_command |
|
159 { |
|
160 public: |
|
161 |
|
162 tree_simple_for_command (int l = -1, int c = -1) |
|
163 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
164 |
|
165 tree_simple_for_command (tree_expression *le, tree_expression *re, |
|
166 tree_statement_list *lst, int l = -1, int c = -1) |
|
167 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
168 |
|
169 ~tree_simple_for_command (void); |
|
170 |
|
171 void eval (void); |
|
172 |
|
173 void eval_error (void); |
|
174 |
|
175 tree_expression *left_hand_side (void) { return lhs; } |
|
176 |
|
177 tree_expression *control_expr (void) { return expr; } |
|
178 |
|
179 tree_statement_list *body (void) { return list; } |
|
180 |
|
181 void accept (tree_walker& tw); |
|
182 |
|
183 private: |
|
184 |
|
185 // Expression to modify. |
|
186 tree_expression *lhs; |
|
187 |
|
188 // Expression to evaluate. |
|
189 tree_expression *expr; |
|
190 |
|
191 // List of commands to execute. |
|
192 tree_statement_list *list; |
|
193 |
|
194 void do_for_loop_once (octave_lvalue &ult, const octave_value& rhs, |
|
195 bool& quit); |
2988
|
196 |
|
197 // No copying! |
|
198 |
|
199 tree_simple_for_command (const tree_simple_for_command&); |
|
200 |
|
201 tree_simple_for_command& operator = (const tree_simple_for_command&); |
2982
|
202 }; |
|
203 |
|
204 class |
|
205 tree_complex_for_command : public tree_command |
|
206 { |
|
207 public: |
|
208 |
|
209 tree_complex_for_command (int l = -1, int c = -1) |
|
210 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
211 |
|
212 tree_complex_for_command (tree_argument_list *le, tree_expression *re, |
|
213 tree_statement_list *lst, int l = -1, int c = -1) |
|
214 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
215 |
|
216 ~tree_complex_for_command (void); |
|
217 |
|
218 void eval (void); |
|
219 |
|
220 void eval_error (void); |
|
221 |
|
222 tree_argument_list *left_hand_side (void) { return lhs; } |
|
223 |
|
224 tree_expression *control_expr (void) { return expr; } |
|
225 |
|
226 tree_statement_list *body (void) { return list; } |
|
227 |
|
228 void accept (tree_walker& tw); |
|
229 |
|
230 private: |
|
231 |
|
232 // Expression to modify. |
|
233 tree_argument_list *lhs; |
|
234 |
|
235 // Expression to evaluate. |
|
236 tree_expression *expr; |
|
237 |
|
238 // List of commands to execute. |
|
239 tree_statement_list *list; |
|
240 |
|
241 void do_for_loop_once (octave_lvalue &val_ref, octave_lvalue &key_ref, |
|
242 const octave_value& val, const octave_value& key, |
|
243 bool& quit); |
2988
|
244 |
|
245 // No copying! |
|
246 |
|
247 tree_complex_for_command (const tree_complex_for_command&); |
|
248 |
|
249 tree_complex_for_command& operator = (const tree_complex_for_command&); |
2982
|
250 }; |
|
251 |
|
252 #endif |
|
253 |
|
254 /* |
|
255 ;;; Local Variables: *** |
|
256 ;;; mode: C++ *** |
|
257 ;;; End: *** |
|
258 */ |