User Guide
table_statement.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 ///
9 /// THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
10 ///
11 
12 #pragma once
13 
14 /**
15  * \dir
16  * \brief Auto generated AST Implementations
17  *
18  * \file
19  * \brief Auto generated AST classes declaration
20  */
21 
22 #include "ast/ast_decl.hpp"
23 #include "ast/name.hpp"
24 #include "ast/statement.hpp"
25 
26 namespace nmodl::ast {
27 
28 /**
29  * \addtogroup ast_class
30  * \ingroup ast
31  * \{
32  */
33 
34 /**
35  * \brief Represents TABLE statement in NMODL
36  *
37  *
38 */
39 class TableStatement : public Statement {
40  private:
41  /// Variables in the table
43  /// dependent variables
45  /// from value
46  std::shared_ptr<Expression> from;
47  /// to values
48  std::shared_ptr<Expression> to;
49  /// an increment factor
50  std::shared_ptr<Integer> with;
51  /// token with location information
52  std::shared_ptr<ModToken> token;
53 
54  public:
55  /// \name Ctor & dtor
56  /// \{
58  explicit TableStatement(const NameVector& table_vars, const NameVector& depend_vars, std::shared_ptr<Expression> from, std::shared_ptr<Expression> to, std::shared_ptr<Integer> with);
59  TableStatement(const TableStatement& obj);
60  virtual ~TableStatement() = default;
61  /// \}
62 
63  /**
64  * \brief Check if the ast node is an instance of ast::TableStatement
65  * \return true as object is of type ast::TableStatement
66  */
67  bool is_table_statement () const noexcept override {
68  return true;
69  }
70 
71  /**
72  * \brief Return a copy of the current node
73  *
74  * Recursively make a new copy/clone of the current node including
75  * all members and return a pointer to the node. This is used for
76  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
77  * ast.
78  *
79  * \return pointer to the clone/copy of the current node
80  */
81  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
82  TableStatement* clone() const override {
83  return new TableStatement(*this);
84  }
85  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
86 
87  /// \name Getters
88  /// \{
89 
90  /**
91  * \brief Return type (ast::AstNodeType) of ast node
92  *
93  * Every node in the ast has a type defined in ast::AstNodeType and this
94  * function is used to retrieve the same.
95  *
96  * \return ast node type i.e. ast::AstNodeType::TABLE_STATEMENT
97  *
98  * \sa Ast::get_node_type_name
99  */
100  AstNodeType get_node_type() const noexcept override {
102  }
103 
104  /**
105  * \brief Return type (ast::AstNodeType) of ast node as std::string
106  *
107  * Every node in the ast has a type defined in ast::AstNodeType.
108  * This type name can be returned as a std::string for printing
109  * node to text/json form.
110  *
111  * \return name of the node type as a string i.e. "TableStatement"
112  *
113  * \sa Ast::get_node_name
114  */
115  std::string get_node_type_name() const noexcept override {
116  return "TableStatement";
117  }
118 
119  /**
120  * \brief Return NMODL statement of ast node as std::string
121  *
122  * Every node is related to a special statement in the NMODL. This
123  * statement can be returned as a std::string for printing to
124  * text/json form.
125  *
126  * \return name of the statement as a string i.e. "TABLE "
127  *
128  * \sa Ast::get_nmodl_name
129  */
130  std::string get_nmodl_name() const noexcept override {
131  return "TABLE ";
132  }
133 
134  /**
135  * \brief Get std::shared_ptr from `this` pointer of the current ast node
136  */
137  std::shared_ptr<Ast> get_shared_ptr() override {
138  return std::static_pointer_cast<TableStatement>(shared_from_this());
139  }
140 
141  /**
142  * \brief Get std::shared_ptr from `this` pointer of the current ast node
143  */
144  std::shared_ptr<const Ast> get_shared_ptr() const override {
145  return std::static_pointer_cast<const TableStatement>(shared_from_this());
146  }
147 
148  /**
149  * \brief Return associated token for the current ast node
150  *
151  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
152  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
153  * nullptr to store in the nmodl::symtab::SymbolTable.
154  *
155  * \return pointer to token if exist otherwise nullptr
156  */
157  const ModToken* get_token() const noexcept override {
158  return token.get();
159  }
160 
161 
162 
163  /**
164  * \brief Getter for member variable \ref TableStatement.table_vars
165  */
166  const NameVector& get_table_vars() const noexcept {
167  return table_vars;
168  }
169 
170 
171 
172  /**
173  * \brief Getter for member variable \ref TableStatement.depend_vars
174  */
175  const NameVector& get_depend_vars() const noexcept {
176  return depend_vars;
177  }
178 
179 
180 
181  /**
182  * \brief Getter for member variable \ref TableStatement.from
183  */
184  std::shared_ptr<Expression> get_from() const noexcept {
185  return from;
186  }
187 
188 
189 
190  /**
191  * \brief Getter for member variable \ref TableStatement.to
192  */
193  std::shared_ptr<Expression> get_to() const noexcept {
194  return to;
195  }
196 
197 
198 
199  /**
200  * \brief Getter for member variable \ref TableStatement.with
201  */
202  std::shared_ptr<Integer> get_with() const noexcept {
203  return with;
204  }
205  /// \}
206 
207  /// \name Setters
208  /// \{
209  /**
210  * \brief Set token for the current ast node
211  */
212  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
213 
214  /**
215  * \brief Setter for member variable \ref TableStatement.table_vars (rvalue reference)
216  */
218 
219  /**
220  * \brief Setter for member variable \ref TableStatement.table_vars
221  */
222  void set_table_vars(const NameVector& table_vars);
223 
224 
225  /**
226  * \brief Setter for member variable \ref TableStatement.depend_vars (rvalue reference)
227  */
229 
230  /**
231  * \brief Setter for member variable \ref TableStatement.depend_vars
232  */
234 
235 
236  /**
237  * \brief Setter for member variable \ref TableStatement.from (rvalue reference)
238  */
239  void set_from(std::shared_ptr<Expression>&& from);
240 
241  /**
242  * \brief Setter for member variable \ref TableStatement.from
243  */
244  void set_from(const std::shared_ptr<Expression>& from);
245 
246 
247  /**
248  * \brief Setter for member variable \ref TableStatement.to (rvalue reference)
249  */
250  void set_to(std::shared_ptr<Expression>&& to);
251 
252  /**
253  * \brief Setter for member variable \ref TableStatement.to
254  */
255  void set_to(const std::shared_ptr<Expression>& to);
256 
257 
258  /**
259  * \brief Setter for member variable \ref TableStatement.with (rvalue reference)
260  */
261  void set_with(std::shared_ptr<Integer>&& with);
262 
263  /**
264  * \brief Setter for member variable \ref TableStatement.with
265  */
266  void set_with(const std::shared_ptr<Integer>& with);
267 
268  /// \}
269 
270  /// \name Visitor
271  /// \{
272  /**
273  * \brief visit children i.e. member variables of current node using provided visitor
274  *
275  * Different nodes in the AST have different members (i.e. children). This method
276  * recursively visits children using provided visitor.
277  *
278  * \param v Concrete visitor that will be used to recursively visit children
279  *
280  * \sa Ast::visit_children for example.
281  */
282  void visit_children(visitor::Visitor& v) override;
283 
284  /**
285  * \brief visit children i.e. member variables of current node using provided visitor
286  *
287  * Different nodes in the AST have different members (i.e. children). This method
288  * recursively visits children using provided visitor.
289  *
290  * \param v Concrete constant visitor that will be used to recursively visit children
291  *
292  * \sa Ast::visit_children for example.
293  */
294  void visit_children(visitor::ConstVisitor& v) const override;
295 
296  /**
297  * \brief accept (or visit) the current AST node using provided visitor
298  *
299  * Instead of visiting children of AST node, like Ast::visit_children,
300  * accept allows to visit the current node itself using provided concrete
301  * visitor.
302  *
303  * \param v Concrete visitor that will be used to recursively visit node
304  *
305  * \sa Ast::accept for example.
306  */
307  void accept(visitor::Visitor& v) override;
308 
309  /**
310  * \copydoc accept(visitor::Visitor&)
311  */
312  void accept(visitor::ConstVisitor& v) const override;
313  /// \}
314 
315  private:
316  /**
317  * \brief Set this object as parent for all the children
318  *
319  * This should be called in every object (with children) constructor
320  * to set parents. Since it is called only in the constructors it
321  * should not be virtual to avoid ambiguities (issue #295).
322  */
323  void set_parent_in_children();
324 };
325 
326 /** \} */ // end of ast_class
327 
328 
329 
330 
331 
332 
333 
334 } // namespace nmodl::ast
nmodl::ast::TableStatement::get_depend_vars
const NameVector & get_depend_vars() const noexcept
Getter for member variable TableStatement::depend_vars.
Definition: table_statement.hpp:175
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::TableStatement::set_table_vars
void set_table_vars(NameVector &&table_vars)
Setter for member variable TableStatement::table_vars (rvalue reference)
Definition: ast.cpp:11151
nmodl::ast::TableStatement::table_vars
NameVector table_vars
Variables in the table.
Definition: table_statement.hpp:42
nmodl::ast::TableStatement::with
std::shared_ptr< Integer > with
an increment factor
Definition: table_statement.hpp:50
nmodl::ast::TableStatement::get_with
std::shared_ptr< Integer > get_with() const noexcept
Getter for member variable TableStatement::with.
Definition: table_statement.hpp:202
nmodl::ast::TableStatement::set_to
void set_to(std::shared_ptr< Expression > &&to)
Setter for member variable TableStatement::to (rvalue reference)
Definition: ast.cpp:11202
nmodl::ast::TableStatement::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:11122
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
name.hpp
Auto generated AST classes declaration.
nmodl::ast::TableStatement::token
std::shared_ptr< ModToken > token
token with location information
Definition: table_statement.hpp:52
nmodl::ast::TableStatement
Represents TABLE statement in NMODL.
Definition: table_statement.hpp:39
nmodl::ast::Integer
Represents an integer variable.
Definition: integer.hpp:49
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::TableStatement::depend_vars
NameVector depend_vars
dependent variables
Definition: table_statement.hpp:44
nmodl::ast::TableStatement::set_depend_vars
void set_depend_vars(NameVector &&depend_vars)
Setter for member variable TableStatement::depend_vars (rvalue reference)
Definition: ast.cpp:11168
nmodl::ast::TableStatement::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:11071
nmodl::ast::TableStatement::clone
TableStatement * clone() const override
Return a copy of the current node.
Definition: table_statement.hpp:82
nmodl::ast::TableStatement::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: table_statement.hpp:157
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
statement.hpp
Auto generated AST classes declaration.
nmodl::ast::TableStatement::set_with
void set_with(std::shared_ptr< Integer > &&with)
Setter for member variable TableStatement::with (rvalue reference)
Definition: ast.cpp:11219
nmodl::ast::TableStatement::~TableStatement
virtual ~TableStatement()=default
nmodl::ast::TableStatement::get_from
std::shared_ptr< Expression > get_from() const noexcept
Getter for member variable TableStatement::from.
Definition: table_statement.hpp:184
nmodl::ast::TableStatement::is_table_statement
bool is_table_statement() const noexcept override
Check if the ast node is an instance of ast::TableStatement.
Definition: table_statement.hpp:67
nmodl::ast::TableStatement::get_to
std::shared_ptr< Expression > get_to() const noexcept
Getter for member variable TableStatement::to.
Definition: table_statement.hpp:193
nmodl::ast::NameVector
std::vector< std::shared_ptr< Name > > NameVector
Definition: ast_decl.hpp:312
nmodl::ast::TableStatement::set_from
void set_from(std::shared_ptr< Expression > &&from)
Setter for member variable TableStatement::from (rvalue reference)
Definition: ast.cpp:11185
nmodl::ast::TableStatement::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: table_statement.hpp:130
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::TableStatement::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: table_statement.hpp:212
nmodl::ast::TableStatement::TableStatement
TableStatement(const NameVector &table_vars, const NameVector &depend_vars, Expression *from, Expression *to, Integer *with)
Definition: ast.cpp:11080
nmodl::ast::TableStatement::get_shared_ptr
std::shared_ptr< const Ast > get_shared_ptr() const override
Get std::shared_ptr from this pointer of the current ast node.
Definition: table_statement.hpp:144
nmodl::ast::TableStatement::to
std::shared_ptr< Expression > to
to values
Definition: table_statement.hpp:48
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::TableStatement::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: table_statement.hpp:137
nmodl::ast::TableStatement::get_table_vars
const NameVector & get_table_vars() const noexcept
Getter for member variable TableStatement::table_vars.
Definition: table_statement.hpp:166
nmodl::ast::TableStatement::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:11027
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ast::TableStatement::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: table_statement.hpp:115
nmodl::ast::AstNodeType::TABLE_STATEMENT
@ TABLE_STATEMENT
type of ast::TableStatement
nmodl::ast::TableStatement::from
std::shared_ptr< Expression > from
from value
Definition: table_statement.hpp:46
nmodl::ast::TableStatement::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: table_statement.hpp:100
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50