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