2980
|
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_binop_h) |
|
24 #define octave_tree_binop_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 class tree_walker; |
|
33 |
|
34 class octave_value; |
|
35 class octave_value_list; |
|
36 class octave_lvalue; |
|
37 |
|
38 #include "ov.h" |
|
39 #include "pt-exp.h" |
|
40 |
|
41 // Binary expressions. |
|
42 |
|
43 class |
|
44 tree_binary_expression : public tree_expression |
|
45 { |
|
46 public: |
|
47 |
|
48 tree_binary_expression (int l = -1, int c = -1, |
|
49 octave_value::binary_op t |
|
50 = octave_value::unknown_binary_op) |
|
51 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { } |
|
52 |
|
53 tree_binary_expression (tree_expression *a, tree_expression *b, |
|
54 int l = -1, int c = -1, |
|
55 octave_value::binary_op t |
|
56 = octave_value::unknown_binary_op) |
|
57 : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t) { } |
|
58 |
|
59 ~tree_binary_expression (void) |
|
60 { |
|
61 delete op_lhs; |
|
62 delete op_rhs; |
|
63 } |
|
64 |
4023
|
65 bool is_binary_expression (void) const { return true; } |
|
66 |
3933
|
67 bool rvalue_ok (void) const { return true; } |
2980
|
68 |
|
69 octave_value rvalue (void); |
|
70 |
3010
|
71 octave_value_list rvalue (int nargout); |
2980
|
72 |
|
73 void eval_error (void); |
|
74 |
3523
|
75 std::string oper (void) const; |
2980
|
76 |
4023
|
77 octave_value::binary_op op_type (void) const { return etype; } |
|
78 |
2980
|
79 tree_expression *lhs (void) { return op_lhs; } |
|
80 tree_expression *rhs (void) { return op_rhs; } |
|
81 |
|
82 void accept (tree_walker& tw); |
|
83 |
|
84 protected: |
|
85 |
|
86 // The operands for the expression. |
|
87 tree_expression *op_lhs; |
|
88 tree_expression *op_rhs; |
|
89 |
|
90 private: |
|
91 |
|
92 // The type of the expression. |
|
93 octave_value::binary_op etype; |
2988
|
94 |
|
95 // No copying! |
|
96 |
|
97 tree_binary_expression (const tree_binary_expression&); |
|
98 |
|
99 tree_binary_expression& operator = (const tree_binary_expression&); |
2980
|
100 }; |
|
101 |
|
102 // Boolean expressions. |
|
103 |
|
104 class |
|
105 tree_boolean_expression : public tree_binary_expression |
|
106 { |
|
107 public: |
|
108 |
|
109 enum type |
|
110 { |
|
111 unknown, |
|
112 bool_and, |
|
113 bool_or |
|
114 }; |
|
115 |
|
116 tree_boolean_expression (int l = -1, int c = -1, type t = unknown) |
|
117 : tree_binary_expression (l, c), etype (t) { } |
|
118 |
|
119 tree_boolean_expression (tree_expression *a, tree_expression *b, |
|
120 int l = -1, int c = -1, type t = unknown) |
|
121 : tree_binary_expression (a, b, l, c), etype (t) { } |
|
122 |
|
123 ~tree_boolean_expression (void) { } |
|
124 |
4023
|
125 bool is_boolean_expression (void) const { return true; } |
|
126 |
3933
|
127 bool rvalue_ok (void) const { return true; } |
2980
|
128 |
|
129 octave_value rvalue (void); |
|
130 |
|
131 octave_value_list rvalue (int nargout); |
|
132 |
3523
|
133 std::string oper (void) const; |
2980
|
134 |
4023
|
135 type op_type (void) const { return etype; } |
|
136 |
2980
|
137 private: |
|
138 |
|
139 // The type of the expression. |
|
140 type etype; |
2988
|
141 |
|
142 // No copying! |
|
143 |
|
144 tree_boolean_expression (const tree_boolean_expression&); |
|
145 |
|
146 tree_boolean_expression& operator = (const tree_boolean_expression&); |
2980
|
147 }; |
|
148 |
|
149 #endif |
|
150 |
|
151 /* |
|
152 ;;; Local Variables: *** |
|
153 ;;; mode: C++ *** |
|
154 ;;; End: *** |
|
155 */ |