comparison src/pt-binop.h @ 2980:cd5ad3fd8049

[project @ 1997-05-16 01:12:13 by jwe]
author jwe
date Fri, 16 May 1997 01:13:19 +0000
parents
children daa1ed1f5462
comparison
equal deleted inserted replaced
2979:a3556d2adec9 2980:cd5ad3fd8049
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
65 bool rvalue_ok (void) const
66 { return true; }
67
68 octave_value rvalue (void);
69
70 octave_value_list rvalue (int nargou);
71
72 void eval_error (void);
73
74 string oper (void) const;
75
76 tree_expression *lhs (void) { return op_lhs; }
77 tree_expression *rhs (void) { return op_rhs; }
78
79 void accept (tree_walker& tw);
80
81 protected:
82
83 // The operands for the expression.
84 tree_expression *op_lhs;
85 tree_expression *op_rhs;
86
87 private:
88
89 // The type of the expression.
90 octave_value::binary_op etype;
91 };
92
93 // Boolean expressions.
94
95 class
96 tree_boolean_expression : public tree_binary_expression
97 {
98 public:
99
100 enum type
101 {
102 unknown,
103 bool_and,
104 bool_or
105 };
106
107 tree_boolean_expression (int l = -1, int c = -1, type t = unknown)
108 : tree_binary_expression (l, c), etype (t) { }
109
110 tree_boolean_expression (tree_expression *a, tree_expression *b,
111 int l = -1, int c = -1, type t = unknown)
112 : tree_binary_expression (a, b, l, c), etype (t) { }
113
114 ~tree_boolean_expression (void) { }
115
116 bool rvalue_ok (void) const
117 { return true; }
118
119 octave_value rvalue (void);
120
121 octave_value_list rvalue (int nargout);
122
123 string oper (void) const;
124
125 private:
126
127 // The type of the expression.
128 type etype;
129 };
130
131 #endif
132
133 /*
134 ;;; Local Variables: ***
135 ;;; mode: C++ ***
136 ;;; End: ***
137 */