GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt-arg-list.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2026 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_arg_list_h)
27#define octave_pt_arg_list_h 1
28
29#include "octave-config.h"
30
31#include <list>
32
33class octave_value;
35
36#include "str-vec.h"
37
38#include "pt-delimiter-list.h"
39#include "pt-exp.h"
40#include "pt-walk.h"
41#include "token.h"
42
44
45class symbol_scope;
46class tree_evaluator;
47class tree_expression;
48
49// Argument lists. Used to hold the list of expressions that are the
50// arguments in a function call or index expression.
51
52class OCTINTERP_API tree_argument_list : public std::list<tree_expression *>
53{
54public:
55
57
59
60 tree_argument_list (tree_expression *t) { push_back (t); }
61
62 OCTAVE_DISABLE_COPY_MOVE (tree_argument_list)
63
65
66 tree_argument_list * mark_in_delims (const token& open_delim, const token& close_delim)
67 {
68 m_delims.push (open_delim, close_delim);
69 return this;
70 }
71
73 {
74 if (m_delims.empty ())
75 {
76 if (empty ())
77 return filepos ();
78
79 tree_expression *elt = front ();
80 return elt->beg_pos ();
81 }
82
83 return m_delims.beg_pos ();
84 }
85
87 {
88 if (m_delims.empty ())
89 {
90 if (empty ())
91 return filepos ();
92
93 tree_expression *elt = back ();
94 return elt->end_pos ();
95 }
96
97 return m_delims.end_pos ();
98 }
99
101 {
102 if (m_delims.empty ())
103 {
104 if (empty ())
105 return comment_list ();
106
107 tree_expression *elt = front ();
108 return elt->leading_comments ();
109 }
110
111 return m_delims.leading_comments ();
112 }
113
115 {
116 if (m_delims.empty ())
117 {
118 if (empty ())
119 return comment_list ();
120
121 tree_expression *elt = back ();
122 return elt->trailing_comments ();
123 }
124
125 return m_delims.trailing_comments ();
126 }
127
128 bool has_magic_tilde () const
129 {
130 return m_list_includes_magic_tilde;
131 }
132
134 {
135 return m_list_includes_magic_tilde;
136 }
137
139 {
140 auto p = begin ();
141 tree_expression *retval = *p;
142 erase (p);
143 return retval;
144 }
145
146 void push_back (const element_type& s);
147
148 void mark_as_simple_assign_lhs () { m_simple_assign_lhs = true; }
149
150 bool is_simple_assign_lhs () { return m_simple_assign_lhs; }
151
152 tree_delimiter_list delims () const { return m_delims; }
153
154 bool all_elements_are_constant () const;
155
156 bool is_valid_lvalue_list () const;
157
158 string_vector get_arg_names () const;
159
160 std::list<std::string> variable_names () const;
161
162 tree_argument_list * dup (symbol_scope& scope) const;
163
165 {
166 tw.visit_argument_list (*this);
167 }
168
169private:
170
171 bool m_list_includes_magic_tilde {false};
172
173 bool m_simple_assign_lhs {false};
174
175 tree_delimiter_list m_delims;
176};
177
178OCTAVE_END_NAMESPACE(octave)
179
180#endif
Definition token.h:42
bool includes_magic_tilde() const
filepos end_pos() const
Definition pt-arg-list.h:86
comment_list leading_comments() const
tree_expression * remove_front()
filepos beg_pos() const
Definition pt-arg-list.h:72
void accept(tree_walker &tw)
tree_argument_list(tree_expression *t)
Definition pt-arg-list.h:60
tree_delimiter_list delims() const
void mark_as_simple_assign_lhs()
bool has_magic_tilde() const
tree_expression * element_type
Definition pt-arg-list.h:56
tree_argument_list * mark_in_delims(const token &open_delim, const token &close_delim)
Definition pt-arg-list.h:66
bool is_simple_assign_lhs()
comment_list trailing_comments() const
virtual void visit_argument_list(tree_argument_list &)
Definition pt-walk.cc:48
virtual filepos end_pos() const =0
virtual comment_list trailing_comments() const =0
virtual filepos beg_pos() const =0
virtual comment_list leading_comments() const =0
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn