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-Until. |
|
88 |
|
89 class |
|
90 tree_do_until_command : public tree_while_command |
|
91 { |
|
92 public: |
|
93 |
|
94 tree_do_until_command (int l = -1, int c = -1) |
|
95 : tree_while_command (l, c) { } |
|
96 |
|
97 tree_do_until_command (tree_expression *e, int l = -1, int c = -1) |
|
98 : tree_while_command (e, l, c) { } |
|
99 |
|
100 tree_do_until_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_until_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_until_command (const tree_do_until_command&); |
|
117 |
|
118 tree_do_until_command& operator = (const tree_do_until_command&); |
|
119 }; |
|
120 |
2982
|
121 // For. |
|
122 |
|
123 class |
|
124 tree_simple_for_command : public tree_command |
|
125 { |
|
126 public: |
|
127 |
|
128 tree_simple_for_command (int l = -1, int c = -1) |
|
129 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
130 |
|
131 tree_simple_for_command (tree_expression *le, tree_expression *re, |
|
132 tree_statement_list *lst, int l = -1, int c = -1) |
|
133 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
134 |
|
135 ~tree_simple_for_command (void); |
|
136 |
|
137 void eval (void); |
|
138 |
|
139 void eval_error (void); |
|
140 |
|
141 tree_expression *left_hand_side (void) { return lhs; } |
|
142 |
|
143 tree_expression *control_expr (void) { return expr; } |
|
144 |
|
145 tree_statement_list *body (void) { return list; } |
|
146 |
|
147 void accept (tree_walker& tw); |
|
148 |
|
149 private: |
|
150 |
|
151 // Expression to modify. |
|
152 tree_expression *lhs; |
|
153 |
|
154 // Expression to evaluate. |
|
155 tree_expression *expr; |
|
156 |
|
157 // List of commands to execute. |
|
158 tree_statement_list *list; |
|
159 |
|
160 void do_for_loop_once (octave_lvalue &ult, const octave_value& rhs, |
|
161 bool& quit); |
2988
|
162 |
|
163 // No copying! |
|
164 |
|
165 tree_simple_for_command (const tree_simple_for_command&); |
|
166 |
|
167 tree_simple_for_command& operator = (const tree_simple_for_command&); |
2982
|
168 }; |
|
169 |
|
170 class |
|
171 tree_complex_for_command : public tree_command |
|
172 { |
|
173 public: |
|
174 |
|
175 tree_complex_for_command (int l = -1, int c = -1) |
|
176 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
177 |
|
178 tree_complex_for_command (tree_argument_list *le, tree_expression *re, |
|
179 tree_statement_list *lst, int l = -1, int c = -1) |
|
180 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
181 |
|
182 ~tree_complex_for_command (void); |
|
183 |
|
184 void eval (void); |
|
185 |
|
186 void eval_error (void); |
|
187 |
|
188 tree_argument_list *left_hand_side (void) { return lhs; } |
|
189 |
|
190 tree_expression *control_expr (void) { return expr; } |
|
191 |
|
192 tree_statement_list *body (void) { return list; } |
|
193 |
|
194 void accept (tree_walker& tw); |
|
195 |
|
196 private: |
|
197 |
|
198 // Expression to modify. |
|
199 tree_argument_list *lhs; |
|
200 |
|
201 // Expression to evaluate. |
|
202 tree_expression *expr; |
|
203 |
|
204 // List of commands to execute. |
|
205 tree_statement_list *list; |
|
206 |
|
207 void do_for_loop_once (octave_lvalue &val_ref, octave_lvalue &key_ref, |
|
208 const octave_value& val, const octave_value& key, |
|
209 bool& quit); |
2988
|
210 |
|
211 // No copying! |
|
212 |
|
213 tree_complex_for_command (const tree_complex_for_command&); |
|
214 |
|
215 tree_complex_for_command& operator = (const tree_complex_for_command&); |
2982
|
216 }; |
|
217 |
|
218 #endif |
|
219 |
|
220 /* |
|
221 ;;; Local Variables: *** |
|
222 ;;; mode: C++ *** |
|
223 ;;; End: *** |
|
224 */ |