1
|
1 // Tree classes. -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993 John W. Eaton |
|
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 |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
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 |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (_tree_h) |
|
25 #define _tree_h 1 |
|
26 |
|
27 // This seems to leave vt$tree undefined with g++ 2.3.3. |
|
28 #if 0 |
|
29 #ifdef __GNUG__ |
|
30 #pragma interface |
|
31 #endif |
|
32 #endif |
|
33 |
|
34 #include <stdio.h> |
|
35 |
|
36 class ostrstream; |
|
37 |
|
38 #include "builtins.h" |
|
39 #include "tree-base.h" |
|
40 #include "tree-const.h" |
|
41 |
|
42 class symbol_record; |
|
43 class symbol_table; |
|
44 |
|
45 #ifndef TREE_FCN_TYPEDEFS |
|
46 #define TREE_FCN_TYPEDEFS 1 |
|
47 |
|
48 typedef tree_constant (*Text_fcn)(int, char **); |
164
|
49 typedef tree_constant* (*General_fcn)(const tree_constant *, int, int); |
1
|
50 |
|
51 #endif |
|
52 |
|
53 #ifndef NULL_TREE |
|
54 #define NULL_TREE (tree *) NULL |
|
55 #endif |
|
56 |
|
57 #ifndef NULL_TREE_CONST |
|
58 #define NULL_TREE_CONST (tree_constant *) NULL |
|
59 #endif |
|
60 |
|
61 /* |
|
62 * Forward declarations. |
|
63 */ |
|
64 class tree; |
|
65 class tree_constant_rep; |
|
66 class tree_constant; |
|
67 class tree_matrix; |
|
68 class tree_builtin; |
|
69 class tree_identifier; |
|
70 class tree_function; |
|
71 class tree_expression; |
|
72 class tree_prefix_expression; |
|
73 class tree_postfix_expression; |
|
74 class tree_unary_expression; |
|
75 class tree_binary_expression; |
|
76 class tree_assignment_expression; |
|
77 class tree_simple_assignment_expression; |
|
78 class tree_multi_assignment_expression; |
|
79 class tree_colon_expression; |
|
80 class tree_index_expression; |
|
81 class tree_argument_list; |
|
82 class tree_parameter_list; |
|
83 class tree_return_list; |
|
84 class tree_word_list; |
|
85 class tree_command; |
|
86 class tree_command_list; |
195
|
87 class tree_global_command; |
1
|
88 class tree_while_command; |
|
89 class tree_for_command; |
|
90 class tree_if_command; |
|
91 class tree_break_command; |
|
92 class tree_continue_command; |
|
93 class tree_return_command; |
|
94 class tree_word_list_command;; |
|
95 class tree_plot_limits; |
|
96 class tree_plot_range; |
|
97 class tree_subplot; |
|
98 class tree_subplot_using; |
|
99 class tree_subplot_style; |
|
100 class tree_subplot_list; |
|
101 class tree_plot_command; |
|
102 |
|
103 /* |
|
104 * General matrices. This allows us to construct matrices from |
|
105 * other matrices, variables, and functions. |
|
106 */ |
|
107 class |
|
108 tree_matrix : public tree |
|
109 { |
|
110 public: |
|
111 tree_matrix (void); |
|
112 tree_matrix (tree *t, tree::matrix_dir d); |
|
113 |
|
114 ~tree_matrix (void); |
|
115 |
|
116 tree_matrix *chain (tree *t, tree::matrix_dir d); |
|
117 tree_matrix *reverse (void); |
|
118 int length (void); |
|
119 |
|
120 tree_return_list *to_return_list (void); |
|
121 |
|
122 tree_constant eval (int print); |
|
123 |
|
124 private: |
|
125 tree::matrix_dir dir; // Direction to the next element. |
|
126 tree *element; |
|
127 tree_matrix *next; |
|
128 }; |
|
129 |
|
130 /* |
|
131 * Builtin functions. |
|
132 */ |
|
133 class |
|
134 tree_builtin : public tree |
|
135 { |
|
136 public: |
195
|
137 tree_builtin (const char *nm = (char *) NULL); |
|
138 |
|
139 tree_builtin (int i_max, int o_max, Mapper_fcn& m_fcn, |
|
140 const char *nm = (char *) NULL); |
|
141 |
|
142 tree_builtin (int i_max, int o_max, Text_fcn t_fcn, |
|
143 const char *nm = (char *) NULL); |
|
144 |
|
145 tree_builtin (int i_max, int o_max, General_fcn t_fcn, |
|
146 const char *nm = (char *) NULL); |
1
|
147 |
|
148 ~tree_builtin (void); |
|
149 |
164
|
150 int is_builtin (void) const; |
1
|
151 |
|
152 tree_constant eval (int print); |
|
153 |
|
154 tree_constant *eval (int print, int nargout); |
|
155 |
|
156 tree_constant eval (int argc, char **argv, int print); |
|
157 |
164
|
158 tree_constant *eval (const tree_constant *args, int n_in, int n_out, |
|
159 int print); |
1
|
160 |
200
|
161 char *name (void) const; |
1
|
162 |
|
163 int max_expected_args (void); |
|
164 |
|
165 private: |
|
166 int nargin_max; |
|
167 int nargout_max; |
|
168 Mapper_fcn mapper_fcn; |
|
169 Text_fcn text_fcn; |
|
170 General_fcn general_fcn; |
195
|
171 char *my_name; |
1
|
172 }; |
|
173 |
|
174 /* |
|
175 * Symbols from the symbol table. |
|
176 */ |
|
177 class |
|
178 tree_identifier : public tree |
|
179 { |
|
180 friend class tree_index_expression; |
|
181 |
|
182 public: |
143
|
183 tree_identifier (int l = -1, int c = -1); |
|
184 tree_identifier (symbol_record *s, int l = -1, int c = -1); |
1
|
185 |
|
186 ~tree_identifier (void); |
|
187 |
164
|
188 int is_identifier (void) const; |
1
|
189 |
200
|
190 char *name (void) const; |
195
|
191 void rename (const char *n); |
1
|
192 |
|
193 tree_identifier *define (tree_constant *t); |
|
194 tree_identifier *define (tree_function *t); |
|
195 |
|
196 void document (char *s); |
|
197 |
|
198 tree_constant assign (tree_constant& t); |
|
199 tree_constant assign (tree_constant& t, tree_constant *args, int nargs); |
|
200 |
|
201 void bump_value (tree::expression_type); |
|
202 |
|
203 int parse_m_file (int exec_script = 1); |
|
204 int parse_m_file (char *mf, int exec_script = 1); |
|
205 void parse_m_file (FILE *mfile, char *mf); |
|
206 |
|
207 tree *do_lookup (int& script_file_executed); |
|
208 |
|
209 void mark_as_formal_parameter (void); |
|
210 |
195
|
211 void mark_for_possible_ans_assign (void); |
|
212 |
1
|
213 tree_constant eval (int print); |
|
214 |
|
215 tree_constant *eval (int print, int nargout); |
|
216 |
|
217 tree_constant eval (int argc, char **argv, int print); |
|
218 |
164
|
219 tree_constant *eval (const tree_constant *args, int n_in, int n_out, |
|
220 int print); |
1
|
221 |
|
222 void eval_undefined_error (void); |
|
223 |
|
224 private: |
|
225 symbol_record *sym; |
195
|
226 int maybe_do_ans_assign; |
1
|
227 }; |
|
228 |
|
229 /* |
|
230 * User defined functions. |
|
231 */ |
|
232 class |
|
233 tree_function : public tree |
|
234 { |
|
235 public: |
|
236 tree_function (void); |
|
237 tree_function (tree *cl, symbol_table *st); |
|
238 |
|
239 ~tree_function (void); |
|
240 |
|
241 tree_function *define (tree *t); |
|
242 tree_function *define_param_list (tree_parameter_list *t); |
|
243 tree_function *define_ret_list (tree_parameter_list *t); |
|
244 |
|
245 void stash_m_file_name (char * s); |
|
246 void stash_m_file_time (time_t t); |
|
247 |
|
248 char *m_file_name (void); |
|
249 time_t time_parsed (void); |
|
250 |
195
|
251 void mark_as_system_m_file (void); |
|
252 int is_system_m_file (void) const; |
|
253 |
143
|
254 void stash_function_name (char *s); |
|
255 char *function_name (void); |
|
256 |
1
|
257 tree_constant eval (int print); |
|
258 |
|
259 tree_constant *eval (int print, int nargout); |
|
260 |
|
261 tree_constant eval (int argc, char **argv, int print); |
|
262 |
164
|
263 tree_constant *eval (const tree_constant *args, int n_in, int n_out, |
|
264 int print); |
1
|
265 |
|
266 int max_expected_args (void); |
|
267 |
143
|
268 void traceback_error (void); |
|
269 |
1
|
270 private: |
|
271 int call_depth; |
|
272 tree_parameter_list *param_list; |
|
273 tree_parameter_list *ret_list; |
|
274 symbol_table *sym_tab; |
|
275 tree *cmd_list; |
143
|
276 char *file_name; |
|
277 char *fcn_name; |
1
|
278 time_t t_parsed; |
195
|
279 int system_m_file; |
1
|
280 }; |
|
281 |
|
282 /* |
|
283 * A base class for expressions. |
|
284 */ |
|
285 class |
|
286 tree_expression : public tree |
|
287 { |
|
288 public: |
|
289 tree_expression (void); |
|
290 |
|
291 ~tree_expression (void); |
|
292 |
|
293 tree_constant eval (int print); |
|
294 |
|
295 protected: |
|
296 expression_type etype; |
|
297 }; |
|
298 |
|
299 /* |
|
300 * Prefix expressions. |
|
301 */ |
|
302 class |
|
303 tree_prefix_expression : public tree_expression |
|
304 { |
|
305 public: |
143
|
306 tree_prefix_expression (int l = -1, int c = -1); |
|
307 tree_prefix_expression (tree_identifier *t, tree::expression_type et, |
|
308 int l = -1, int c = -1); |
1
|
309 |
|
310 ~tree_prefix_expression (void); |
|
311 |
|
312 tree_constant eval (int print); |
|
313 |
143
|
314 void eval_error (void); |
|
315 |
195
|
316 int is_prefix_expression (void) const; |
|
317 |
1
|
318 private: |
|
319 tree_identifier *id; |
|
320 }; |
|
321 |
|
322 /* |
|
323 * Postfix expressions. |
|
324 */ |
|
325 class |
|
326 tree_postfix_expression : public tree_expression |
|
327 { |
|
328 public: |
143
|
329 tree_postfix_expression (int l = -1, int c = -1); |
|
330 tree_postfix_expression (tree_identifier *t, tree::expression_type et, |
|
331 int l = -1, int c = -1); |
1
|
332 |
|
333 ~tree_postfix_expression (void); |
|
334 |
|
335 tree_constant eval (int print); |
|
336 |
143
|
337 void eval_error (void); |
|
338 |
1
|
339 private: |
|
340 tree_identifier *id; |
|
341 }; |
|
342 |
|
343 /* |
|
344 * Unary expressions. |
|
345 */ |
|
346 class |
|
347 tree_unary_expression : public tree_expression |
|
348 { |
|
349 public: |
143
|
350 tree_unary_expression (int l = -1, int c = -1); |
|
351 tree_unary_expression (tree *a, tree::expression_type t, int l = -1, |
|
352 int c = -1); |
1
|
353 |
|
354 ~tree_unary_expression (void); |
|
355 |
|
356 tree_constant eval (int print); |
|
357 |
143
|
358 void eval_error (void); |
|
359 |
1
|
360 private: |
|
361 tree *op; |
|
362 }; |
|
363 |
|
364 /* |
|
365 * Binary expressions. |
|
366 */ |
|
367 class |
|
368 tree_binary_expression : public tree_expression |
|
369 { |
|
370 public: |
143
|
371 tree_binary_expression (int l = -1, int c = -1); |
|
372 tree_binary_expression (tree *a, tree *b, tree::expression_type t, |
|
373 int l = -1, int c = -1); |
1
|
374 |
|
375 ~tree_binary_expression (void); |
|
376 |
|
377 tree_constant eval (int print); |
|
378 |
143
|
379 void eval_error (void); |
|
380 |
1
|
381 private: |
|
382 tree *op1; |
|
383 tree *op2; |
|
384 }; |
|
385 |
|
386 /* |
|
387 * Assignment expressions. |
|
388 */ |
|
389 class |
|
390 tree_assignment_expression : public tree_expression |
|
391 { |
|
392 public: |
|
393 int in_parens; |
|
394 |
|
395 tree_assignment_expression (void); |
|
396 |
|
397 ~tree_assignment_expression (void); |
|
398 |
|
399 tree_constant eval (int print); |
|
400 |
164
|
401 int is_assignment_expression (void) const; |
1
|
402 }; |
|
403 |
|
404 /* |
|
405 * Simple assignment expressions. |
|
406 */ |
|
407 class |
|
408 tree_simple_assignment_expression : public tree_assignment_expression |
|
409 { |
|
410 public: |
143
|
411 tree_simple_assignment_expression (int l = -1, int c = -1); |
|
412 tree_simple_assignment_expression (tree_identifier *i, tree *r, |
|
413 int l = -1, int c = -1); |
|
414 tree_simple_assignment_expression (tree_index_expression *idx_expr, |
|
415 tree *r, int l = -1, int c = -1); |
1
|
416 |
|
417 ~tree_simple_assignment_expression (void); |
|
418 |
|
419 tree_constant eval (int print); |
|
420 |
143
|
421 void eval_error (void); |
|
422 |
1
|
423 private: |
|
424 tree_identifier *lhs; |
|
425 tree_argument_list *index; |
|
426 tree *rhs; |
|
427 }; |
|
428 |
|
429 /* |
|
430 * Multi-valued assignment expressions. |
|
431 */ |
|
432 class |
|
433 tree_multi_assignment_expression : public tree_assignment_expression |
|
434 { |
|
435 public: |
143
|
436 tree_multi_assignment_expression (int l = -1, int c = -1); |
|
437 tree_multi_assignment_expression (tree_return_list *lst, tree *r, |
|
438 int l = -1, int c = -1); |
1
|
439 |
|
440 ~tree_multi_assignment_expression (void); |
|
441 |
|
442 tree_constant eval (int print); |
|
443 |
|
444 tree_constant *eval (int print, int nargout); |
|
445 |
143
|
446 void eval_error (void); |
|
447 |
1
|
448 private: |
|
449 tree_return_list *lhs; |
|
450 tree *rhs; |
|
451 }; |
|
452 |
|
453 /* |
|
454 * Colon expressions. |
|
455 */ |
|
456 class |
|
457 tree_colon_expression : public tree_expression |
|
458 { |
|
459 public: |
143
|
460 tree_colon_expression (int l = -1, int c = -1); |
|
461 tree_colon_expression (tree *a, tree *b, int l = -1, int c = -1); |
1
|
462 |
|
463 ~tree_colon_expression (void); |
|
464 |
|
465 tree_colon_expression *chain (tree *t); |
|
466 |
|
467 tree_constant eval (int print); |
|
468 |
143
|
469 void eval_error (const char *s); |
|
470 |
1
|
471 private: |
|
472 tree *op1; |
|
473 tree *op2; |
|
474 tree *op3; |
|
475 }; |
|
476 |
|
477 /* |
|
478 * Index expressions. |
|
479 */ |
|
480 class |
|
481 tree_index_expression : public tree_expression |
|
482 { |
|
483 public: |
143
|
484 tree_index_expression (int l = -1, int c = -1); |
|
485 tree_index_expression (tree_identifier *i, int l = -1, int c = -1); |
|
486 tree_index_expression (tree_identifier *i, tree_argument_list *lst, |
|
487 int l = -1, int c = -1); |
1
|
488 |
|
489 ~tree_index_expression (void); |
|
490 |
164
|
491 int is_index_expression (void) const; |
1
|
492 |
|
493 tree_identifier *ident (void); |
|
494 |
|
495 tree_argument_list *arg_list (void); |
|
496 |
195
|
497 void mark_for_possible_ans_assign (void); |
|
498 |
1
|
499 tree_constant eval (int print); |
|
500 |
|
501 tree_constant *eval (int print, int nargout); |
|
502 |
143
|
503 void eval_error (void); |
|
504 |
1
|
505 private: |
|
506 tree_identifier *id; |
|
507 tree_argument_list *list; |
|
508 }; |
|
509 |
|
510 /* |
|
511 * Argument lists. |
|
512 */ |
|
513 class |
|
514 tree_argument_list : public tree |
|
515 { |
|
516 public: |
|
517 tree_argument_list (void); |
|
518 tree_argument_list (tree *t); |
|
519 |
|
520 ~tree_argument_list (void); |
|
521 |
|
522 tree_argument_list *chain (tree *t); |
|
523 tree_argument_list *reverse (void); |
|
524 int length (void); |
|
525 |
|
526 tree_argument_list *next_elem (void); |
|
527 |
|
528 tree_constant *convert_to_const_vector (int& nargs); |
|
529 |
|
530 tree_constant eval (int print); |
|
531 |
|
532 private: |
|
533 tree *arg; |
|
534 tree_argument_list *next; |
|
535 }; |
|
536 |
|
537 /* |
|
538 * Parameter lists. Almost like argument lists, except that the |
|
539 * elements are only supposed to be identifiers, never constants or |
|
540 * expressions. |
|
541 */ |
|
542 class |
|
543 tree_parameter_list : public tree |
|
544 { |
|
545 public: |
|
546 tree_parameter_list (void); |
|
547 tree_parameter_list (tree_identifier *t); |
|
548 |
|
549 ~tree_parameter_list (void); |
|
550 |
|
551 tree_parameter_list *chain (tree_identifier *t); |
|
552 tree_parameter_list *reverse (void); |
|
553 int length (void); |
|
554 |
200
|
555 char *name (void) const; |
1
|
556 |
|
557 void mark_as_formal_parameters (void); |
|
558 |
|
559 tree_identifier *define (tree_constant *t); |
|
560 |
|
561 tree_parameter_list *next_elem (void); |
|
562 |
|
563 tree_constant eval (int print); |
|
564 |
|
565 private: |
|
566 tree_identifier *param; |
|
567 tree_parameter_list *next; |
|
568 }; |
|
569 |
|
570 /* |
|
571 * Return lists. Almost like parameter lists, except that the |
|
572 * elements may also be index expressions. |
|
573 */ |
|
574 class |
|
575 tree_return_list : public tree |
|
576 { |
|
577 public: |
|
578 tree_return_list (void); |
|
579 tree_return_list (tree_identifier *t); |
|
580 tree_return_list (tree_index_expression *t); |
|
581 |
|
582 ~tree_return_list (void); |
|
583 |
|
584 tree_return_list *chain (tree_identifier *t); |
|
585 tree_return_list *chain (tree_index_expression *t); |
|
586 tree_return_list *reverse (void); |
|
587 int length (void); |
|
588 |
|
589 tree_index_expression *idx_expr (void); |
|
590 |
|
591 tree_return_list *next_elem (void); |
|
592 |
|
593 tree_constant eval (int print); |
|
594 |
|
595 private: |
|
596 tree_index_expression *retval; |
|
597 tree_return_list *next; |
|
598 }; |
|
599 |
|
600 /* |
|
601 * Word lists. |
|
602 */ |
|
603 class |
|
604 tree_word_list : public tree |
|
605 { |
|
606 public: |
|
607 tree_word_list (void); |
|
608 tree_word_list (char *s); |
|
609 |
|
610 ~tree_word_list (void); |
|
611 |
|
612 tree_word_list *chain (char *s); |
|
613 tree_word_list *reverse (void); |
|
614 int length (void); |
|
615 |
200
|
616 char *name (void) const; |
1
|
617 |
|
618 tree_word_list *next_elem (void); |
|
619 |
|
620 tree_constant eval (int print); |
|
621 |
|
622 private: |
|
623 char *word; |
|
624 tree_word_list *next; |
|
625 }; |
|
626 |
|
627 /* |
|
628 * A base class for commands. |
|
629 */ |
|
630 class |
|
631 tree_command : public tree |
|
632 { |
|
633 }; |
|
634 |
|
635 /* |
|
636 * A command or two to be executed. |
|
637 */ |
|
638 class |
|
639 tree_command_list : public tree_command |
|
640 { |
|
641 public: |
|
642 tree_command_list (void); |
|
643 tree_command_list (tree *t); |
|
644 |
|
645 ~tree_command_list (void); |
|
646 |
|
647 tree_command_list *chain (tree *t); |
|
648 tree_command_list *reverse (void); |
|
649 |
|
650 void set_print_flag (int print); |
|
651 |
|
652 tree_constant eval (int print); |
|
653 |
|
654 private: |
|
655 tree *command; // Command to execute. |
|
656 int print_flag; // Print result of eval for this command? |
|
657 tree_command_list *next; // Next command in list. |
|
658 }; |
|
659 |
|
660 /* |
195
|
661 * Global. |
|
662 */ |
|
663 class |
|
664 tree_global_command : public tree_command |
|
665 { |
|
666 public: |
|
667 tree_global_command (int l = -1, int c = -1); |
|
668 tree_global_command (symbol_record *s, int l = -1, int c = -1); |
|
669 tree_global_command (symbol_record *s, tree *e, int l = -1, int c = -1); |
|
670 |
|
671 ~tree_global_command (void); |
|
672 |
|
673 tree_global_command *chain (symbol_record *s, int l = -1, int c = -1); |
|
674 tree_global_command *chain (symbol_record *s, tree *e, int l = -1, int c = -1); |
|
675 tree_global_command *reverse (void); |
|
676 |
|
677 tree_constant eval (int print); |
|
678 |
|
679 void eval_error (void); |
|
680 |
|
681 private: |
|
682 symbol_record *sr; // Symbol record from local symbol table. |
|
683 tree *rhs; // RHS of assignment. |
|
684 tree_global_command *next; // Next global command. |
|
685 }; |
|
686 |
|
687 /* |
1
|
688 * While. |
|
689 */ |
|
690 class |
|
691 tree_while_command : public tree_command |
|
692 { |
|
693 public: |
191
|
694 tree_while_command (int l = -1, int c = -1); |
|
695 tree_while_command (tree *e, int l = -1, int c = -1); |
|
696 tree_while_command (tree *e, tree *lst, int l = -1, int c = -1); |
1
|
697 |
|
698 ~tree_while_command (void); |
|
699 |
|
700 tree_constant eval (int print); |
|
701 |
191
|
702 void eval_error (void); |
|
703 |
1
|
704 private: |
|
705 tree *expr; // Expression to test. |
|
706 tree *list; // List of commands to execute. |
|
707 }; |
|
708 |
|
709 /* |
|
710 * For. |
|
711 */ |
|
712 class |
|
713 tree_for_command : public tree_command |
|
714 { |
|
715 public: |
191
|
716 tree_for_command (int l = -1, int c = -1); |
|
717 tree_for_command (tree_index_expression *id, tree *e, tree *lst, |
|
718 int l = -1, int c = -1); |
1
|
719 |
|
720 ~tree_for_command (void); |
|
721 |
|
722 tree_constant eval (int print); |
|
723 |
191
|
724 void eval_error (void); |
|
725 |
1
|
726 private: |
117
|
727 tree_index_expression *id; // Identifier to modify. |
1
|
728 tree *expr; // Expression to evaluate. |
|
729 tree *list; // List of commands to execute. |
|
730 }; |
|
731 |
|
732 /* |
|
733 * Simple if. |
|
734 */ |
|
735 class |
|
736 tree_if_command : public tree_command |
|
737 { |
|
738 public: |
191
|
739 tree_if_command (int l = -1, int c = -1); |
|
740 tree_if_command (tree *t, int l = -1, int c = -1); |
|
741 tree_if_command (tree *e, tree *t, int l = -1, int c = -1); |
1
|
742 |
|
743 ~tree_if_command (void); |
|
744 |
191
|
745 tree_if_command *chain (tree *t, int l = -1, int c = -1); |
|
746 tree_if_command *chain (tree *t1, tree *t2, int l = -1, int c = -1); |
1
|
747 tree_if_command *reverse (void); |
|
748 |
|
749 tree_constant eval (int print); |
|
750 |
191
|
751 void eval_error (void); |
|
752 |
1
|
753 private: |
|
754 tree *expr; // Expression to test. |
|
755 tree *list; // Commands to execute. |
|
756 tree_if_command *next; // Next if command. |
|
757 }; |
|
758 |
|
759 /* |
|
760 * Break. |
|
761 */ |
|
762 class |
|
763 tree_break_command : public tree_command |
|
764 { |
|
765 public: |
191
|
766 tree_break_command (int l = -1, int c = -1); |
1
|
767 |
|
768 ~tree_break_command (void); |
|
769 |
|
770 tree_constant eval (int print); |
|
771 }; |
|
772 |
|
773 /* |
|
774 * Continue. |
|
775 */ |
|
776 class |
|
777 tree_continue_command : public tree_command |
|
778 { |
|
779 public: |
191
|
780 tree_continue_command (int l = -1, int c = -1); |
1
|
781 |
|
782 ~tree_continue_command (void); |
|
783 |
|
784 tree_constant eval (int print); |
|
785 }; |
|
786 |
|
787 /* |
|
788 * Return. |
|
789 */ |
|
790 class |
|
791 tree_return_command : public tree_command |
|
792 { |
|
793 public: |
191
|
794 tree_return_command (int l = -1, int c = -1); |
1
|
795 |
|
796 ~tree_return_command (void); |
|
797 |
|
798 tree_constant eval (int print); |
|
799 }; |
|
800 |
|
801 /* |
|
802 * Functions that take a list of strings as arguments. |
|
803 */ |
|
804 class |
|
805 tree_word_list_command : public tree_command |
|
806 { |
|
807 public: |
|
808 tree_word_list_command (void); |
|
809 tree_word_list_command (tree_identifier *id, tree_word_list *wl); |
|
810 |
|
811 ~tree_word_list_command (void); |
|
812 |
|
813 tree_constant eval (int print); |
|
814 |
|
815 private: |
|
816 tree_identifier *ident; |
|
817 tree_word_list *word_list; |
|
818 }; |
|
819 |
|
820 class |
|
821 tree_plot_command : public tree_command |
|
822 { |
|
823 public: |
|
824 tree_plot_command (void); |
|
825 tree_plot_command (tree_subplot_list *plt, int nd); |
|
826 tree_plot_command (tree_subplot_list *plt, tree_plot_limits *rng, int nd); |
|
827 |
|
828 ~tree_plot_command (void); |
|
829 |
|
830 tree_constant eval (int print); |
|
831 |
|
832 private: |
|
833 int ndim; |
|
834 tree_plot_limits *range; |
|
835 tree_subplot_list *plot_list; |
|
836 }; |
|
837 |
|
838 class |
|
839 tree_subplot_list : public tree |
|
840 { |
|
841 public: |
|
842 tree_subplot_list (void); |
|
843 tree_subplot_list (tree *data); |
|
844 tree_subplot_list (tree_subplot_list *t); |
|
845 tree_subplot_list (tree_subplot_using *u, tree *t, tree_subplot_style *s); |
|
846 |
|
847 ~tree_subplot_list (void); |
|
848 |
|
849 tree_subplot_list *set_data (tree *data); |
|
850 |
|
851 tree_subplot_list *chain (tree_subplot_list *t); |
|
852 |
|
853 tree_subplot_list *reverse (void); |
|
854 |
|
855 tree_subplot_list *next_elem (void); |
|
856 |
|
857 tree_constant eval (int print); |
|
858 // tree_constant *eval (int print, int nargout); |
|
859 |
|
860 int print (int ndim, ostrstream& plot_buf); |
|
861 |
|
862 private: |
|
863 tree *plot_data; |
|
864 tree_subplot_using *using; |
|
865 tree *title; |
|
866 tree_subplot_style *style; |
|
867 tree_subplot_list *next; |
|
868 }; |
|
869 |
|
870 class |
|
871 tree_plot_limits : public tree |
|
872 { |
|
873 public: |
|
874 tree_plot_limits (void); |
|
875 tree_plot_limits (tree_plot_range *xlim); |
|
876 tree_plot_limits (tree_plot_range *xlim, tree_plot_range *ylim); |
|
877 tree_plot_limits (tree_plot_range *xlim, tree_plot_range *ylim, |
|
878 tree_plot_range *zlim); |
|
879 |
|
880 ~tree_plot_limits (void); |
|
881 |
|
882 tree_constant eval (int print); |
|
883 |
|
884 void print (int print, ostrstream& plot_buf); |
|
885 |
|
886 private: |
|
887 tree_plot_range *x_range; |
|
888 tree_plot_range *y_range; |
|
889 tree_plot_range *z_range; |
|
890 }; |
|
891 |
|
892 class |
|
893 tree_plot_range : public tree |
|
894 { |
|
895 public: |
|
896 tree_plot_range (void); |
|
897 tree_plot_range (tree *l, tree *u); |
|
898 |
|
899 ~tree_plot_range (void); |
|
900 |
|
901 tree_constant eval (int print); |
|
902 |
|
903 void print (ostrstream& plot_buf); |
|
904 |
|
905 private: |
|
906 tree *lower; |
|
907 tree *upper; |
|
908 }; |
|
909 |
|
910 class |
|
911 tree_subplot_using : public tree |
|
912 { |
|
913 public: |
|
914 tree_subplot_using (void); |
|
915 tree_subplot_using (tree *fmt); |
|
916 |
|
917 ~tree_subplot_using (void); |
|
918 |
|
919 tree_subplot_using *set_format (tree *fmt); |
|
920 |
|
921 tree_subplot_using *add_qualifier (tree *t); |
|
922 |
|
923 tree_constant eval (int print); |
|
924 |
|
925 int print (int ndim, int n_max, ostrstream& plot_buf); |
|
926 |
|
927 private: |
|
928 int qualifier_count; |
|
929 tree *x[4]; |
|
930 tree *scanf_fmt; |
|
931 }; |
|
932 |
|
933 class |
|
934 tree_subplot_style : public tree |
|
935 { |
|
936 public: |
|
937 tree_subplot_style (void); |
|
938 tree_subplot_style (char *s); |
|
939 tree_subplot_style (char *s, tree *lt); |
|
940 tree_subplot_style (char *s, tree *lt, tree *pt); |
|
941 |
|
942 ~tree_subplot_style (void); |
|
943 |
|
944 tree_constant eval (int print); |
|
945 |
|
946 int print (ostrstream& plot_buf); |
|
947 |
|
948 private: |
|
949 char *style; |
|
950 tree *linetype; |
|
951 tree *pointtype; |
|
952 }; |
|
953 |
|
954 #endif |
|
955 |
|
956 /* |
|
957 ;;; Local Variables: *** |
|
958 ;;; mode: C++ *** |
|
959 ;;; page-delimiter: "^/\\*" *** |
|
960 ;;; End: *** |
|
961 */ |