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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2980
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_tree_unop_h) |
|
25 #define octave_tree_unop_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 class tree_walker; |
|
30 |
|
31 class octave_value; |
|
32 class octave_value_list; |
|
33 class octave_lvalue; |
|
34 |
|
35 #include "pt-exp.h" |
|
36 |
|
37 // Unary expressions. |
|
38 |
|
39 class |
|
40 tree_unary_expression : public tree_expression |
|
41 { |
|
42 public: |
|
43 |
3203
|
44 tree_unary_expression (int l = -1, int c = -1, |
|
45 octave_value::unary_op t |
|
46 = octave_value::unknown_unary_op) |
|
47 : tree_expression (l, c), op (0), etype (t) { } |
2980
|
48 |
3203
|
49 tree_unary_expression (tree_expression *e, int l = -1, int c = -1, |
|
50 octave_value::unary_op t |
|
51 = octave_value::unknown_unary_op) |
|
52 : tree_expression (l, c), op (e), etype (t) { } |
2980
|
53 |
|
54 ~tree_unary_expression (void) { delete op; } |
|
55 |
4267
|
56 bool has_magic_end (void) const { return (op && op->has_magic_end ()); } |
|
57 |
2980
|
58 tree_expression *operand (void) { return op; } |
|
59 |
3523
|
60 std::string oper (void) const; |
3203
|
61 |
2980
|
62 protected: |
|
63 |
|
64 // The operand for the expression. |
|
65 tree_expression *op; |
2988
|
66 |
3203
|
67 // The type of the expression. |
|
68 octave_value::unary_op etype; |
|
69 |
|
70 private: |
|
71 |
2988
|
72 // No copying! |
|
73 |
|
74 tree_unary_expression (const tree_unary_expression&); |
|
75 |
|
76 tree_unary_expression& operator = (const tree_unary_expression&); |
2980
|
77 }; |
|
78 |
|
79 // Prefix expressions. |
|
80 |
|
81 class |
|
82 tree_prefix_expression : public tree_unary_expression |
|
83 { |
|
84 public: |
|
85 |
|
86 tree_prefix_expression (int l = -1, int c = -1) |
3203
|
87 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980
|
88 |
3195
|
89 tree_prefix_expression (tree_expression *e, int l = -1, int c = -1, |
3203
|
90 octave_value::unary_op t |
|
91 = octave_value::unknown_unary_op) |
|
92 : tree_unary_expression (e, l, c, t) { } |
2980
|
93 |
|
94 ~tree_prefix_expression (void) { } |
|
95 |
3933
|
96 bool rvalue_ok (void) const { return true; } |
2980
|
97 |
|
98 octave_value rvalue (void); |
|
99 |
3010
|
100 octave_value_list rvalue (int nargout); |
2980
|
101 |
|
102 void eval_error (void); |
|
103 |
|
104 void accept (tree_walker& tw); |
|
105 |
|
106 private: |
|
107 |
2988
|
108 // No copying! |
|
109 |
|
110 tree_prefix_expression (const tree_prefix_expression&); |
|
111 |
|
112 tree_prefix_expression& operator = (const tree_prefix_expression&); |
2980
|
113 }; |
|
114 |
|
115 // Postfix expressions. |
|
116 |
|
117 class |
|
118 tree_postfix_expression : public tree_unary_expression |
|
119 { |
|
120 public: |
|
121 |
|
122 tree_postfix_expression (int l = -1, int c = -1) |
3203
|
123 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980
|
124 |
3195
|
125 tree_postfix_expression (tree_expression *e, int l = -1, int c = -1, |
3203
|
126 octave_value::unary_op t |
|
127 = octave_value::unknown_unary_op) |
|
128 : tree_unary_expression (e, l, c, t) { } |
2980
|
129 |
|
130 ~tree_postfix_expression (void) { } |
|
131 |
3933
|
132 bool rvalue_ok (void) const { return true; } |
2980
|
133 |
|
134 octave_value rvalue (void); |
|
135 |
|
136 octave_value_list rvalue (int nargout); |
|
137 |
|
138 void eval_error (void); |
|
139 |
|
140 void accept (tree_walker& tw); |
|
141 |
|
142 private: |
|
143 |
2988
|
144 // No copying! |
|
145 |
|
146 tree_postfix_expression (const tree_postfix_expression&); |
|
147 |
|
148 tree_postfix_expression& operator = (const tree_postfix_expression&); |
2980
|
149 }; |
|
150 |
|
151 #endif |
|
152 |
|
153 /* |
|
154 ;;; Local Variables: *** |
|
155 ;;; mode: C++ *** |
|
156 ;;; End: *** |
|
157 */ |