GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-unop.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pt_unop_h)
24 #define octave_pt_unop_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 class octave_value;
31 class octave_value_list;
32 
33 #include "pt-exp.h"
34 #include "pt-walk.h"
35 
36 namespace octave
37 {
38  class symbol_scope;
39 
40  // Unary expressions.
41 
43  {
44  protected:
45 
46  tree_unary_expression (int l = -1, int c = -1,
49  : tree_expression (l, c), m_op (nullptr), m_etype (t) { }
50 
51  tree_unary_expression (tree_expression *e, int l = -1, int c = -1,
54  : tree_expression (l, c), m_op (e), m_etype (t) { }
55 
56  public:
57 
58  // No copying!
59 
61 
63 
64  ~tree_unary_expression (void) { delete m_op; }
65 
66  bool is_unary_expression (void) const { return true; }
67 
68  bool has_magic_end (void) const { return (m_op && m_op->has_magic_end ()); }
69 
70  tree_expression * operand (void) { return m_op; }
71 
72  std::string oper (void) const;
73 
74  octave_value::unary_op op_type (void) const { return m_etype; }
75 
76  protected:
77 
78  // The operand for the expression.
80 
81  // The type of the expression.
83  };
84 
85  // Prefix expressions.
86 
88  {
89  public:
90 
91  tree_prefix_expression (int l = -1, int c = -1)
92  : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
93 
94  tree_prefix_expression (tree_expression *e, int l = -1, int c = -1,
97  : tree_unary_expression (e, l, c, t) { }
98 
99  // No copying!
100 
102 
104 
105  ~tree_prefix_expression (void) = default;
106 
107  bool rvalue_ok (void) const { return true; }
108 
109  tree_expression * dup (symbol_scope& scope) const;
110 
111  void accept (tree_walker& tw)
112  {
113  tw.visit_prefix_expression (*this);
114  }
115 
116  std::string profiler_name (void) const { return "prefix " + oper (); }
117  };
118 
119  // Postfix expressions.
120 
122  {
123  public:
124 
125  tree_postfix_expression (int l = -1, int c = -1)
126  : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
127 
128  tree_postfix_expression (tree_expression *e, int l = -1, int c = -1,
131  : tree_unary_expression (e, l, c, t) { }
132 
133  // No copying!
134 
136 
138 
139  ~tree_postfix_expression (void) = default;
140 
141  bool rvalue_ok (void) const { return true; }
142 
143  tree_expression * dup (symbol_scope& scope) const;
144 
145  void accept (tree_walker& tw)
146  {
147  tw.visit_postfix_expression (*this);
148  }
149 
150  std::string profiler_name (void) const { return "postfix " + oper (); }
151  };
152 }
153 
154 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
155 
156 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_unary_expression' instead")
157 typedef octave::tree_unary_expression tree_unary_expression;
158 
159 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_prefix_expression' instead")
160 typedef octave::tree_prefix_expression tree_prefix_expression;
161 
162 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_postfix_expression' instead")
163 typedef octave::tree_postfix_expression tree_postfix_expression;
164 
165 #endif
166 
167 #endif
tree_unary_expression(int l=-1, int c=-1, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition: pt-unop.h:46
octave_value::unary_op op_type(void) const
Definition: pt-unop.h:74
tree_unary_expression & operator=(const tree_unary_expression &)=delete
virtual bool has_magic_end(void) const =0
tree_expression * dup(symbol_scope &scope) const
Definition: pt-unop.cc:43
std::string profiler_name(void) const
Definition: pt-unop.h:116
~tree_postfix_expression(void)=default
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
i e
Definition: data.cc:2591
std::string profiler_name(void) const
Definition: pt-unop.h:150
~tree_prefix_expression(void)=default
tree_prefix_expression & operator=(const tree_prefix_expression &)=delete
bool rvalue_ok(void) const
Definition: pt-unop.h:141
bool is_unary_expression(void) const
Definition: pt-unop.h:66
std::string oper(void) const
Definition: pt-unop.cc:35
bool has_magic_end(void) const
Definition: pt-unop.h:68
tree_expression * m_op
Definition: pt-unop.h:79
void accept(tree_walker &tw)
Definition: pt-unop.h:111
void accept(tree_walker &tw)
Definition: pt-unop.h:145
tree_postfix_expression(int l=-1, int c=-1)
Definition: pt-unop.h:125
tree_postfix_expression(tree_expression *e, int l=-1, int c=-1, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition: pt-unop.h:128
octave_value::unary_op m_etype
Definition: pt-unop.h:82
virtual void visit_prefix_expression(tree_prefix_expression &)=0
bool rvalue_ok(void) const
Definition: pt-unop.h:107
tree_expression * dup(symbol_scope &scope) const
Definition: pt-unop.cc:57
virtual void visit_postfix_expression(tree_postfix_expression &)=0
tree_postfix_expression & operator=(const tree_postfix_expression &)=delete
tree_expression * operand(void)
Definition: pt-unop.h:70
unary_op
Definition: ov.h:81
tree_prefix_expression(tree_expression *e, int l=-1, int c=-1, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition: pt-unop.h:94
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
tree_unary_expression(tree_expression *e, int l=-1, int c=-1, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition: pt-unop.h:51
tree_prefix_expression(int l=-1, int c=-1)
Definition: pt-unop.h:91