Mercurial > octave-nkf
comparison src/pt-exp.h @ 2971:f2be17e6f1ea
[project @ 1997-05-15 18:55:44 by jwe]
author | jwe |
---|---|
date | Thu, 15 May 1997 18:55:47 +0000 |
parents | 194b50e4725b |
children | a3556d2adec9 |
comparison
equal
deleted
inserted
replaced
2970:b9e64477f703 | 2971:f2be17e6f1ea |
---|---|
31 | 31 |
32 class tree_identifier; | 32 class tree_identifier; |
33 class tree_index_expression; | 33 class tree_index_expression; |
34 class tree_indirect_ref; | 34 class tree_indirect_ref; |
35 class tree_argument_list; | 35 class tree_argument_list; |
36 class tree_assignment_lhs; | |
36 | 37 |
37 class tree_walker; | 38 class tree_walker; |
38 | 39 |
39 class octave_value; | 40 class octave_value; |
40 class octave_value_list; | 41 class octave_value_list; |
41 class octave_variable_reference; | 42 class octave_variable_reference; |
42 | 43 |
44 #include "oct-obj.h" | |
43 #include "pt-exp-base.h" | 45 #include "pt-exp-base.h" |
44 | 46 |
45 // Unary expressions. | 47 // Unary expressions. |
46 | 48 |
47 class | 49 class |
88 int l = -1, int c = -1) | 90 int l = -1, int c = -1) |
89 : tree_unary_expression (e, l, c), etype (t) { } | 91 : tree_unary_expression (e, l, c), etype (t) { } |
90 | 92 |
91 ~tree_prefix_expression (void) { } | 93 ~tree_prefix_expression (void) { } |
92 | 94 |
93 octave_value eval (bool print = false); | 95 bool rvalue_ok (void) const |
96 { return true; } | |
97 | |
98 octave_value rvalue (void); | |
99 | |
100 octave_value_list rvalue (int nargou); | |
94 | 101 |
95 void eval_error (void); | 102 void eval_error (void); |
96 | 103 |
97 string oper (void) const; | 104 string oper (void) const; |
98 | 105 |
127 int l = -1, int c = -1) | 134 int l = -1, int c = -1) |
128 : tree_unary_expression (e, l, c), etype (t) { } | 135 : tree_unary_expression (e, l, c), etype (t) { } |
129 | 136 |
130 ~tree_postfix_expression (void) { } | 137 ~tree_postfix_expression (void) { } |
131 | 138 |
132 octave_value eval (bool print = false); | 139 bool rvalue_ok (void) const |
140 { return true; } | |
141 | |
142 octave_value rvalue (void); | |
143 | |
144 octave_value_list rvalue (int nargout); | |
133 | 145 |
134 void eval_error (void); | 146 void eval_error (void); |
135 | 147 |
136 string oper (void) const; | 148 string oper (void) const; |
137 | 149 |
165 { | 177 { |
166 delete op_lhs; | 178 delete op_lhs; |
167 delete op_rhs; | 179 delete op_rhs; |
168 } | 180 } |
169 | 181 |
170 octave_value eval (bool print = false); | 182 bool rvalue_ok (void) const |
183 { return true; } | |
184 | |
185 octave_value rvalue (void); | |
186 | |
187 octave_value_list rvalue (int nargou); | |
171 | 188 |
172 void eval_error (void); | 189 void eval_error (void); |
173 | 190 |
174 string oper (void) const; | 191 string oper (void) const; |
175 | 192 |
211 int l = -1, int c = -1, type t = unknown) | 228 int l = -1, int c = -1, type t = unknown) |
212 : tree_binary_expression (a, b, l, c), etype (t) { } | 229 : tree_binary_expression (a, b, l, c), etype (t) { } |
213 | 230 |
214 ~tree_boolean_expression (void) { } | 231 ~tree_boolean_expression (void) { } |
215 | 232 |
216 octave_value eval (bool print = false); | 233 bool rvalue_ok (void) const |
234 { return true; } | |
235 | |
236 octave_value rvalue (void); | |
237 | |
238 octave_value_list rvalue (int nargout); | |
217 | 239 |
218 string oper (void) const; | 240 string oper (void) const; |
219 | 241 |
220 private: | 242 private: |
221 | 243 |
224 }; | 246 }; |
225 | 247 |
226 // Simple assignment expressions. | 248 // Simple assignment expressions. |
227 | 249 |
228 class | 250 class |
229 tree_simple_assignment_expression : public tree_expression | 251 tree_simple_assignment : public tree_expression |
230 { | 252 { |
231 public: | 253 public: |
232 | 254 |
233 tree_simple_assignment_expression | 255 tree_simple_assignment (bool plhs = false, int l = -1, int c = -1, |
234 (bool plhs = false, bool ans_assign = false, int l = -1, int c = -1, | 256 octave_value::assign_op t = octave_value::asn_eq) |
235 octave_value::assign_op t = octave_value::asn_eq) | 257 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t) { } |
236 : tree_expression (l, c), lhs_idx_expr (0), lhs (0), index (0), | 258 |
237 rhs (0), preserve (plhs), ans_ass (ans_assign), etype (t) { } | 259 tree_simple_assignment (tree_expression *le, tree_expression *re, |
238 | 260 bool plhs = false, int l = -1, int c = -1, |
239 tree_simple_assignment_expression | 261 octave_value::assign_op t = octave_value::asn_eq) |
240 (tree_identifier *i, tree_expression *r, bool plhs = false, | 262 : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), |
241 bool ans_assign = false, int l = -1, int c = -1, | 263 etype (t) { } |
242 octave_value::assign_op t = octave_value::asn_eq); | 264 |
243 | 265 ~tree_simple_assignment (void); |
244 tree_simple_assignment_expression | 266 |
245 (tree_indirect_ref *i, tree_expression *r, bool plhs = false, | 267 bool rvalue_ok (void) const |
246 bool ans_assign = false, int l = -1, int c = -1, | 268 { return true; } |
247 octave_value::assign_op t = octave_value::asn_eq) | 269 |
248 : tree_expression (l, c), lhs_idx_expr (0), lhs (i), index (0), | 270 octave_value rvalue (void); |
249 rhs (r), preserve (plhs), ans_ass (ans_assign), etype (t) { } | 271 |
250 | 272 octave_value_list rvalue (int nargout); |
251 tree_simple_assignment_expression | |
252 (tree_index_expression *idx_expr, tree_expression *r, | |
253 bool plhs = false, bool ans_assign = false, int l = -1, int c = -1, | |
254 octave_value::assign_op t = octave_value::asn_eq); | |
255 | |
256 ~tree_simple_assignment_expression (void); | |
257 | |
258 bool left_hand_side_is_identifier_only (void); | |
259 | |
260 tree_identifier *left_hand_side_id (void); | |
261 | |
262 bool is_ans_assign (void) | |
263 { return ans_ass; } | |
264 | |
265 octave_value eval (bool print = false); | |
266 | 273 |
267 bool is_assignment_expression (void) const | 274 bool is_assignment_expression (void) const |
268 { return true; } | 275 { return true; } |
269 | 276 |
270 void eval_error (void); | 277 void eval_error (void); |
271 | 278 |
272 string oper (void) const; | 279 string oper (void) const; |
273 | 280 |
274 tree_indirect_ref *left_hand_side (void) { return lhs; } | 281 tree_expression *left_hand_side (void) { return lhs; } |
275 | |
276 tree_argument_list *lhs_index (void) { return index; } | |
277 | 282 |
278 tree_expression *right_hand_side (void) { return rhs; } | 283 tree_expression *right_hand_side (void) { return rhs; } |
279 | 284 |
280 void accept (tree_walker& tw); | 285 void accept (tree_walker& tw); |
281 | 286 |
286 const octave_value& rhs_val); | 291 const octave_value& rhs_val); |
287 | 292 |
288 void do_assign (octave_variable_reference& ult, | 293 void do_assign (octave_variable_reference& ult, |
289 const octave_value& rhs_val); | 294 const octave_value& rhs_val); |
290 | 295 |
291 // The left hand side of the assignment, as an index expression. If | 296 // The left hand side of the assignment. |
292 // the assignment is constructed from an index expression, the index | 297 tree_expression *lhs; |
293 // expression is split into the its components in the constructor. | |
294 tree_index_expression *lhs_idx_expr; | |
295 | |
296 // The indirect reference (id or structure reference) on the left | |
297 // hand side of the assignemnt. | |
298 tree_indirect_ref *lhs; | |
299 | |
300 // The index of the left hand side of the assignment, if any. | |
301 tree_argument_list *index; | |
302 | 298 |
303 // The right hand side of the assignment. | 299 // The right hand side of the assignment. |
304 tree_expression *rhs; | 300 tree_expression *rhs; |
305 | 301 |
306 // True if we should not delete the lhs. | 302 // True if we should not delete the lhs. |
321 public: | 317 public: |
322 | 318 |
323 tree_colon_expression (int l = -1, int c = -1) | 319 tree_colon_expression (int l = -1, int c = -1) |
324 : tree_expression (l, c), op_base (0), op_limit (0), op_increment (0) { } | 320 : tree_expression (l, c), op_base (0), op_limit (0), op_increment (0) { } |
325 | 321 |
326 tree_colon_expression (tree_expression *a, tree_expression *b, | 322 tree_colon_expression (tree_expression *e, int l = -1, int c = -1) |
327 int l = -1, int c = -1) | 323 : tree_expression (l, c), op_base (e), op_limit (0), op_increment (0) { } |
328 : tree_expression (l, c), op_base (a), op_limit (b), op_increment (0) { } | |
329 | 324 |
330 ~tree_colon_expression (void) | 325 ~tree_colon_expression (void) |
331 { | 326 { |
332 delete op_base; | 327 delete op_base; |
333 delete op_limit; | 328 delete op_limit; |
334 delete op_increment; | 329 delete op_increment; |
335 } | 330 } |
336 | 331 |
337 tree_colon_expression *chain (tree_expression *t); | 332 tree_colon_expression *append (tree_expression *t); |
338 | 333 |
339 octave_value eval (bool print = false); | 334 bool rvalue_ok (void) const |
340 | 335 { return true; } |
341 void eval_error (const char *s); | 336 |
337 octave_value rvalue (void); | |
338 | |
339 octave_value_list rvalue (int nargout); | |
340 | |
341 void eval_error (const string& s = string ()); | |
342 | 342 |
343 tree_expression *base (void) { return op_base; } | 343 tree_expression *base (void) { return op_base; } |
344 tree_expression *limit (void) { return op_limit; } | 344 tree_expression *limit (void) { return op_limit; } |
345 tree_expression *increment (void) { return op_increment; } | 345 tree_expression *increment (void) { return op_increment; } |
346 | 346 |
350 | 350 |
351 // The components of the expression. | 351 // The components of the expression. |
352 tree_expression *op_base; | 352 tree_expression *op_base; |
353 tree_expression *op_limit; | 353 tree_expression *op_limit; |
354 tree_expression *op_increment; | 354 tree_expression *op_increment; |
355 }; | |
356 | |
357 // Index expressions. | |
358 | |
359 class | |
360 tree_index_expression : public tree_expression | |
361 { | |
362 public: | |
363 | |
364 tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0, | |
365 int l = -1, int c = -1) | |
366 : tree_expression (l, c), expr (e), list (lst), arg_nm () { } | |
367 | |
368 ~tree_index_expression (void); | |
369 | |
370 bool is_index_expression (void) const | |
371 { return true; } | |
372 | |
373 tree_expression *expression (void) | |
374 { return expr; } | |
375 | |
376 tree_argument_list *arg_list (void) | |
377 { return list; } | |
378 | |
379 bool rvalue_ok (void) const | |
380 { return true; } | |
381 | |
382 octave_value rvalue (void); | |
383 | |
384 octave_value_list rvalue (int nargout); | |
385 | |
386 octave_variable_reference lvalue (void); | |
387 | |
388 void eval_error (void); | |
389 | |
390 void accept (tree_walker& tw); | |
391 | |
392 private: | |
393 | |
394 tree_expression *expr; | |
395 | |
396 tree_argument_list *list; | |
397 | |
398 string_vector arg_nm; | |
399 }; | |
400 | |
401 // Multi-valued assignment expressions. | |
402 | |
403 class | |
404 tree_multi_assignment : public tree_expression | |
405 { | |
406 public: | |
407 | |
408 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1) | |
409 : tree_expression (l, c), preserve (plhs), lhs (0), rhs (0) { } | |
410 | |
411 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, | |
412 bool plhs = false, int l = -1, int c = -1) | |
413 : tree_expression (l, c), preserve (plhs), lhs (lst), rhs (r) { } | |
414 | |
415 ~tree_multi_assignment (void); | |
416 | |
417 bool is_assignment_expression (void) const | |
418 { return true; } | |
419 | |
420 bool rvalue_ok (void) const | |
421 { return true; } | |
422 | |
423 octave_value rvalue (void); | |
424 | |
425 octave_value_list rvalue (int nargout); | |
426 | |
427 void eval_error (void); | |
428 | |
429 tree_argument_list *left_hand_side (void) { return lhs; } | |
430 | |
431 tree_expression *right_hand_side (void) { return rhs; } | |
432 | |
433 void accept (tree_walker& tw); | |
434 | |
435 private: | |
436 | |
437 bool preserve; | |
438 tree_argument_list *lhs; | |
439 tree_expression *rhs; | |
355 }; | 440 }; |
356 | 441 |
357 #endif | 442 #endif |
358 | 443 |
359 /* | 444 /* |