GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-args-block.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2021-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_pt_args_block_h)
27 #define octave_pt_args_block_h 1
28 
29 #include "octave-config.h"
30 
31 #include "pt-arg-list.h"
32 #include "pt-cmd.h"
33 #include "pt-exp.h"
34 #include "pt-id.h"
35 #include "pt-walk.h"
36 
37 #include "base-list.h"
38 
39 // FIXME: We could maybe re-think the naming of some of these objects
40 // before releasing a version that contains these new classes...
41 
43 
45 {
46 public:
47 
49  : m_size_args (size_args)
50  { }
51 
52  // No copying!
53 
55 
56  tree_arg_size_spec& operator = (const tree_arg_size_spec&) = delete;
57 
59  {
60  delete m_size_args;
61  }
62 
63  tree_argument_list * size_args (void) { return m_size_args; }
64 
65  void accept (tree_walker& tw)
66  {
67  tw.visit_arg_size_spec (*this);
68  }
69 
70 private:
71 
73 };
74 
76 {
77 public:
78 
81  { }
82 
83  // No copying!
84 
86 
88 
90  {
91  delete m_fcn_args;
92  }
93 
94  tree_argument_list * fcn_args (void) { return m_fcn_args; }
95 
96  void accept (tree_walker& tw)
97  {
98  tw.visit_arg_validation_fcns (*this);
99  }
100 
101 private:
102 
104 };
105 
107 {
108 public:
109 
113  tree_expression *default_value)
114  : m_arg_name (nullptr), m_size_spec (size_spec),
116  m_default_value (default_value)
117  { }
118 
119  // No copying!
120 
122 
124 
126  {
127  delete m_arg_name;
128  delete m_size_spec;
129  delete m_class_name;
130  delete m_validation_fcns;
131  delete m_default_value;
132  }
133 
135  {
136  m_arg_name = name;
137  }
138 
140 
142 
144 
147 
150 
151  void accept (tree_walker& tw)
152  {
153  tw.visit_arg_validation (*this);
154  }
155 
156 private:
157 
158  // May be a simple identifier or an identifier followed by a single
159  // field name.
165 };
166 
168  : public base_list<tree_arg_validation *>
169 {
170 public:
171 
173 
175 
178  { }
179 
180  // No copying!
181 
183 
185 
187 
188  void accept (tree_walker& tw)
189  {
191  }
192 };
193 
194 // FIXME: Maybe make this object an actual list even though we don't
195 // currently need it?
196 
198 {
199 public:
200 
202  : m_attr (attr)
203  { }
204 
205  // No copying!
206 
208 
210 
212  {
213  delete m_attr;
214  }
215 
216  tree_identifier * attribute (void) { return m_attr; }
217 
218  void accept (tree_walker& tw)
219  {
221  }
222 
223 private:
224 
226 };
227 
228 // Arguments block.
229 
231 {
232 public:
233 
236  int l = -1, int c = -1)
237  : tree_command (l, c), m_attr_list (attr_list),
239  m_lead_comm (nullptr), m_trail_comm (nullptr)
240  { }
241 
242  // No copying!
243 
245 
247 
249  {
250  delete m_attr_list;
251  delete m_validation_list;
252 
253  delete m_lead_comm;
254  delete m_trail_comm;
255  }
256 
258  {
259  return m_attr_list;
260  }
261 
263  {
264  return m_validation_list;
265  }
266 
268 
270 
271  void accept (tree_walker& tw)
272  {
273  tw.visit_arguments_block (*this);
274  }
275 
276 private:
277 
279 
281 
282  // Comment preceding ARGUMENTS token.
284 
285  // Comment preceding ENDARGUMENTS token.
287 };
288 
290 
291 #endif
OCTAVE_END_NAMESPACE(octave)
void append(const tree_arg_validation * &s)
Definition: base-list.h:92
void accept(tree_walker &tw)
Definition: pt-args-block.h:65
tree_argument_list * size_args(void)
Definition: pt-args-block.h:63
tree_argument_list * m_size_args
Definition: pt-args-block.h:72
tree_arg_size_spec(tree_argument_list *size_args)
Definition: pt-args-block.h:48
tree_arg_size_spec(const tree_arg_size_spec &)=delete
void accept(tree_walker &tw)
Definition: pt-args-block.h:96
tree_arg_validation_fcns(const tree_arg_validation_fcns &)=delete
tree_argument_list * m_fcn_args
tree_arg_validation_fcns & operator=(const tree_arg_validation_fcns &)=delete
tree_argument_list * fcn_args(void)
Definition: pt-args-block.h:94
tree_arg_validation_fcns(tree_argument_list *fcn_args)
Definition: pt-args-block.h:79
tree_expression * m_default_value
tree_identifier * m_class_name
tree_arg_validation_fcns * m_validation_fcns
tree_arg_validation(const tree_arg_validation &)=delete
tree_arg_size_spec * size_spec(void)
tree_expression * m_arg_name
tree_expression * initializer_expression(void)
tree_arg_validation(tree_arg_size_spec *size_spec, tree_identifier *class_name, tree_arg_validation_fcns *validation_fcns, tree_expression *default_value)
void arg_name(tree_expression *name)
tree_arg_size_spec * m_size_spec
tree_identifier * class_name(void)
void accept(tree_walker &tw)
tree_arg_validation & operator=(const tree_arg_validation &)=delete
tree_expression * identifier_expression(void)
tree_arg_validation_fcns * validation_fcns(void)
tree_args_block_attribute_list(const tree_args_block_attribute_list &)=delete
tree_args_block_attribute_list & operator=(const tree_args_block_attribute_list &)=delete
tree_args_block_attribute_list(tree_identifier *attr=nullptr)
tree_identifier * attribute(void)
void accept(tree_walker &tw)
tree_args_block_validation_list(tree_arg_validation *a)
tree_args_block_validation_list(const tree_args_block_validation_list &)=delete
void accept(tree_walker &tw)
tree_args_block_validation_list(const base_list< tree_arg_validation * > &a)
tree_args_block_validation_list & operator=(const tree_args_block_validation_list &)=delete
tree_arguments_block(tree_args_block_attribute_list *attr_list, tree_args_block_validation_list *validation_list, int l=-1, int c=-1)
void accept(tree_walker &tw)
comment_list * m_lead_comm
comment_list * trailing_comment(void)
tree_arguments_block(const tree_arguments_block &)=delete
comment_list * leading_comment(void)
comment_list * m_trail_comm
tree_args_block_validation_list * validation_list(void)
tree_arguments_block & operator=(const tree_arguments_block &)=delete
tree_args_block_validation_list * m_validation_list
tree_args_block_attribute_list * attribute_list(void)
tree_args_block_attribute_list * m_attr_list
virtual void visit_args_block_validation_list(tree_args_block_validation_list &)
Definition: pt-walk.cc:81
virtual void visit_arg_size_spec(tree_arg_size_spec &)
Definition: pt-walk.cc:118
virtual void visit_args_block_attribute_list(tree_args_block_attribute_list &)
Definition: pt-walk.cc:73
virtual void visit_arguments_block(tree_arguments_block &)
Definition: pt-walk.cc:60
virtual void visit_arg_validation_fcns(tree_arg_validation_fcns &)
Definition: pt-walk.cc:126
virtual void visit_arg_validation(tree_arg_validation &)
Definition: pt-walk.cc:90
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn