1739
|
1 /* |
|
2 |
1827
|
3 Copyright (C) 1996 John W. Eaton |
1739
|
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_expr2_h) |
|
24 #define octave_tree_expr2_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class ostream; |
|
31 |
|
32 class tree_identifier; |
|
33 class tree_index_expression; |
|
34 class tree_indirect_ref; |
|
35 class tree_argument_list; |
|
36 |
|
37 #include "pt-exp-base.h" |
|
38 |
|
39 // Prefix expressions. |
|
40 |
|
41 class |
|
42 tree_prefix_expression : public tree_expression |
|
43 { |
|
44 public: |
|
45 tree_prefix_expression (int l = -1, int c = -1) |
|
46 : tree_expression (l, c), id (0) { } |
|
47 |
|
48 tree_prefix_expression (tree_identifier *t, tree_expression::type et, |
|
49 int l = -1, int c = -1) |
|
50 : tree_expression (l, c, et), id (t) { } |
|
51 |
|
52 ~tree_prefix_expression (void); |
|
53 |
2086
|
54 octave_value eval (bool print); |
1739
|
55 |
|
56 void eval_error (void); |
|
57 |
1827
|
58 bool is_prefix_expression (void) const |
|
59 { return true; } |
1739
|
60 |
|
61 char *oper (void) const; |
|
62 |
|
63 void print_code (ostream& os); |
|
64 |
|
65 private: |
|
66 tree_identifier *id; |
|
67 }; |
|
68 |
|
69 // Postfix expressions. |
|
70 |
|
71 class |
|
72 tree_postfix_expression : public tree_expression |
|
73 { |
|
74 public: |
|
75 tree_postfix_expression (int l = -1, int c = -1) |
|
76 : tree_expression (l, c), id (0) { } |
|
77 |
|
78 tree_postfix_expression (tree_identifier *t, tree_expression::type et, |
|
79 int l = -1, int c = -1) |
|
80 : tree_expression (l, c, et), id (t) { } |
|
81 |
|
82 ~tree_postfix_expression (void); |
|
83 |
2086
|
84 octave_value eval (bool print); |
1739
|
85 |
|
86 void eval_error (void); |
|
87 |
|
88 char *oper (void) const; |
|
89 |
|
90 void print_code (ostream& os); |
|
91 |
|
92 private: |
|
93 tree_identifier *id; |
|
94 }; |
|
95 |
|
96 // Unary expressions. |
|
97 |
|
98 class |
|
99 tree_unary_expression : public tree_expression |
|
100 { |
|
101 public: |
|
102 tree_unary_expression (int l = -1, int c = -1) |
|
103 : tree_expression (l, c), op (0) { } |
|
104 |
|
105 tree_unary_expression (tree_expression *a, tree_expression::type t, |
|
106 int l = -1, int c = -1) |
|
107 : tree_expression (l, c, t), op (a) { } |
|
108 |
|
109 ~tree_unary_expression (void) |
|
110 { delete op; } |
|
111 |
2086
|
112 octave_value eval (bool print); |
1739
|
113 |
|
114 void eval_error (void); |
|
115 |
|
116 char *oper (void) const; |
|
117 |
|
118 void print_code (ostream& os); |
|
119 |
|
120 private: |
|
121 tree_expression *op; |
|
122 }; |
|
123 |
|
124 // Binary expressions. |
|
125 |
|
126 class |
|
127 tree_binary_expression : public tree_expression |
|
128 { |
|
129 public: |
|
130 tree_binary_expression (int l = -1, int c = -1) |
|
131 : tree_expression (l, c), op1 (0), op2 (0) { } |
|
132 |
|
133 tree_binary_expression (tree_expression *a, tree_expression *b, |
|
134 tree_expression::type t, int l = -1, int c = -1) |
|
135 : tree_expression (l, c, t), op1 (a), op2 (b) { } |
|
136 |
|
137 ~tree_binary_expression (void) |
|
138 { |
|
139 delete op1; |
|
140 delete op2; |
|
141 } |
|
142 |
2086
|
143 octave_value eval (bool print); |
1739
|
144 |
|
145 void eval_error (void); |
|
146 |
|
147 char *oper (void) const; |
|
148 |
|
149 void print_code (ostream& os); |
|
150 |
|
151 private: |
|
152 tree_expression *op1; |
|
153 tree_expression *op2; |
|
154 }; |
|
155 |
|
156 // Simple assignment expressions. |
|
157 |
|
158 class |
|
159 tree_simple_assignment_expression : public tree_expression |
|
160 { |
|
161 private: |
1827
|
162 void init (bool plhs, bool ans_assign) |
1739
|
163 { |
|
164 etype = tree_expression::assignment; |
|
165 lhs_idx_expr = 0; |
|
166 lhs = 0; |
|
167 index = 0; |
|
168 rhs = 0; |
|
169 preserve = plhs; |
|
170 ans_ass = ans_assign; |
|
171 } |
|
172 |
|
173 public: |
1827
|
174 tree_simple_assignment_expression (bool plhs = false, |
|
175 bool ans_assign = false, |
1739
|
176 int l = -1, int c = -1) |
|
177 : tree_expression (l, c) |
|
178 { init (plhs, ans_assign); } |
|
179 |
|
180 tree_simple_assignment_expression (tree_identifier *i, |
|
181 tree_expression *r, |
1827
|
182 bool plhs = false, |
|
183 bool ans_assign = false, |
1739
|
184 int l = -1, int c = -1); |
|
185 |
|
186 tree_simple_assignment_expression (tree_indirect_ref *i, |
|
187 tree_expression *r, |
1827
|
188 bool plhs = false, |
|
189 bool ans_assign = false, |
1739
|
190 int l = -1, int c = -1) |
|
191 : tree_expression (l, c) |
|
192 { |
|
193 init (plhs, ans_assign); |
|
194 lhs = i; |
|
195 rhs = r; |
|
196 } |
|
197 |
|
198 tree_simple_assignment_expression (tree_index_expression *idx_expr, |
|
199 tree_expression *r, |
1827
|
200 bool plhs = false, |
|
201 bool ans_assign = false, |
1739
|
202 int l = -1, int c = -1); |
|
203 |
|
204 ~tree_simple_assignment_expression (void); |
|
205 |
1827
|
206 bool left_hand_side_is_identifier_only (void); |
1739
|
207 |
|
208 tree_identifier *left_hand_side_id (void); |
|
209 |
1827
|
210 bool is_ans_assign (void) |
1739
|
211 { return ans_ass; } |
|
212 |
2086
|
213 octave_value eval (bool print); |
1739
|
214 |
1827
|
215 bool is_assignment_expression (void) const |
|
216 { return true; } |
1739
|
217 |
|
218 void eval_error (void); |
|
219 |
|
220 void print_code (ostream& os); |
|
221 |
|
222 private: |
|
223 tree_index_expression *lhs_idx_expr; |
|
224 tree_indirect_ref *lhs; |
|
225 tree_argument_list *index; |
|
226 tree_expression *rhs; |
1827
|
227 bool preserve; |
|
228 bool ans_ass; |
1739
|
229 }; |
|
230 |
|
231 // Colon expressions. |
|
232 |
|
233 class |
|
234 tree_colon_expression : public tree_expression |
|
235 { |
|
236 public: |
|
237 tree_colon_expression (int l = -1, int c = -1) |
|
238 : tree_expression (l, c, tree_expression::colon), |
|
239 op1(0), op2 (0), op3 (0) { } |
|
240 |
|
241 tree_colon_expression (tree_expression *a, tree_expression *b, |
|
242 int l = -1, int c = -1) |
|
243 : tree_expression (l, c, tree_expression::colon), |
|
244 op1 (a), op2 (b), op3 (0) { } |
|
245 |
|
246 ~tree_colon_expression (void) |
|
247 { |
|
248 delete op1; |
|
249 delete op2; |
|
250 delete op3; |
|
251 } |
|
252 |
1827
|
253 bool is_range_constant (void) const; |
1739
|
254 |
|
255 tree_colon_expression *chain (tree_expression *t); |
|
256 |
2086
|
257 octave_value eval (bool print); |
1739
|
258 |
|
259 void eval_error (const char *s); |
|
260 |
|
261 void print_code (ostream& os); |
|
262 |
|
263 private: |
|
264 tree_expression *op1; |
|
265 tree_expression *op2; |
|
266 tree_expression *op3; |
|
267 }; |
|
268 |
|
269 #endif |
|
270 |
|
271 /* |
|
272 ;;; Local Variables: *** |
|
273 ;;; mode: C++ *** |
|
274 ;;; End: *** |
|
275 */ |