GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-unop.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pt_unop_h)
24 #define octave_pt_unop_h 1
25 
26 #include <string>
27 
28 class tree_walker;
29 
30 class octave_value;
31 class octave_value_list;
32 class octave_lvalue;
33 
34 #include "pt-exp.h"
35 #include "symtab.h"
36 
37 // Unary expressions.
38 
39 class
41 {
42 public:
43 
44  tree_unary_expression (int l = -1, int c = -1,
47  : tree_expression (l, c), op (0), etype (t) { }
48 
49  tree_unary_expression (tree_expression *e, int l = -1, int c = -1,
52  : tree_expression (l, c), op (e), etype (t) { }
53 
54  ~tree_unary_expression (void) { delete op; }
55 
56  bool is_unary_expression (void) const { return true; }
57 
58  bool has_magic_end (void) const { return (op && op->has_magic_end ()); }
59 
60  tree_expression *operand (void) { return op; }
61 
62  std::string oper (void) const;
63 
64  octave_value::unary_op op_type (void) const { return etype; }
65 
66 protected:
67 
68  // The operand for the expression.
70 
71  // The type of the expression.
73 
74 private:
75 
76  // No copying!
77 
79 
81 };
82 
83 // Prefix expressions.
84 
85 class
87 {
88 public:
89 
90  tree_prefix_expression (int l = -1, int c = -1)
91  : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
92 
93  tree_prefix_expression (tree_expression *e, int l = -1, int c = -1,
96  : tree_unary_expression (e, l, c, t) { }
97 
99 
100  bool rvalue_ok (void) const { return true; }
101 
102  octave_value rvalue1 (int nargout = 1);
103 
104  octave_value_list rvalue (int nargout);
105 
108 
109  void accept (tree_walker& tw);
110 
111 private:
112 
113  // No copying!
114 
116 
118 };
119 
120 // Postfix expressions.
121 
122 class
124 {
125 public:
126 
127  tree_postfix_expression (int l = -1, int c = -1)
128  : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
129 
130  tree_postfix_expression (tree_expression *e, int l = -1, int c = -1,
133  : tree_unary_expression (e, l, c, t) { }
134 
136 
137  bool rvalue_ok (void) const { return true; }
138 
139  octave_value rvalue1 (int nargout = 1);
140 
141  octave_value_list rvalue (int nargout);
142 
145 
146  void accept (tree_walker& tw);
147 
148 private:
149 
150  // No copying!
151 
153 
155 };
156 
157 #endif