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 |
|
70 private: |
|
71 |
|
72 // Expression to test. |
|
73 tree_expression *expr; |
|
74 |
|
75 // List of commands to execute. |
|
76 tree_statement_list *list; |
|
77 }; |
|
78 |
|
79 // For. |
|
80 |
|
81 class |
|
82 tree_simple_for_command : public tree_command |
|
83 { |
|
84 public: |
|
85 |
|
86 tree_simple_for_command (int l = -1, int c = -1) |
|
87 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
88 |
|
89 tree_simple_for_command (tree_expression *le, tree_expression *re, |
|
90 tree_statement_list *lst, int l = -1, int c = -1) |
|
91 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
92 |
|
93 ~tree_simple_for_command (void); |
|
94 |
|
95 void eval (void); |
|
96 |
|
97 void eval_error (void); |
|
98 |
|
99 tree_expression *left_hand_side (void) { return lhs; } |
|
100 |
|
101 tree_expression *control_expr (void) { return expr; } |
|
102 |
|
103 tree_statement_list *body (void) { return list; } |
|
104 |
|
105 void accept (tree_walker& tw); |
|
106 |
|
107 private: |
|
108 |
|
109 // Expression to modify. |
|
110 tree_expression *lhs; |
|
111 |
|
112 // Expression to evaluate. |
|
113 tree_expression *expr; |
|
114 |
|
115 // List of commands to execute. |
|
116 tree_statement_list *list; |
|
117 |
|
118 void do_for_loop_once (octave_lvalue &ult, const octave_value& rhs, |
|
119 bool& quit); |
|
120 }; |
|
121 |
|
122 class |
|
123 tree_complex_for_command : public tree_command |
|
124 { |
|
125 public: |
|
126 |
|
127 tree_complex_for_command (int l = -1, int c = -1) |
|
128 : tree_command (l, c), lhs (0), expr (0), list (0) { } |
|
129 |
|
130 tree_complex_for_command (tree_argument_list *le, tree_expression *re, |
|
131 tree_statement_list *lst, int l = -1, int c = -1) |
|
132 : tree_command (l, c), lhs (le), expr (re), list (lst) { } |
|
133 |
|
134 ~tree_complex_for_command (void); |
|
135 |
|
136 void eval (void); |
|
137 |
|
138 void eval_error (void); |
|
139 |
|
140 tree_argument_list *left_hand_side (void) { return lhs; } |
|
141 |
|
142 tree_expression *control_expr (void) { return expr; } |
|
143 |
|
144 tree_statement_list *body (void) { return list; } |
|
145 |
|
146 void accept (tree_walker& tw); |
|
147 |
|
148 private: |
|
149 |
|
150 // Expression to modify. |
|
151 tree_argument_list *lhs; |
|
152 |
|
153 // Expression to evaluate. |
|
154 tree_expression *expr; |
|
155 |
|
156 // List of commands to execute. |
|
157 tree_statement_list *list; |
|
158 |
|
159 void do_for_loop_once (octave_lvalue &val_ref, octave_lvalue &key_ref, |
|
160 const octave_value& val, const octave_value& key, |
|
161 bool& quit); |
|
162 }; |
|
163 |
|
164 #endif |
|
165 |
|
166 /* |
|
167 ;;; Local Variables: *** |
|
168 ;;; mode: C++ *** |
|
169 ;;; End: *** |
|
170 */ |