User Guide
lag_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 Represents a LAG statement in the mod file
35  *
36  * An example of LAG statement usage:
37  *
38  * \code{.mod}
39  * PROCEDURE lates() {
40  * LAG ina BY tau
41  * neo = lag_ina_tau
42  * if (ena < 70) {ena = 70}
43  * }
44  * \endcode
45  *
46 */
47 class LagStatement : public Statement {
48  private:
49  /// Name of the variable (TODO)
50  std::shared_ptr<Identifier> name;
51  /// Name of the variable (TODO)
52  std::shared_ptr<Name> byname;
53  /// token with location information
54  std::shared_ptr<ModToken> token;
55 
56  public:
57  /// \name Ctor & dtor
58  /// \{
59  explicit LagStatement(Identifier* name, Name* byname);
60  explicit LagStatement(std::shared_ptr<Identifier> name, std::shared_ptr<Name> byname);
61  LagStatement(const LagStatement& obj);
62  virtual ~LagStatement() = default;
63  /// \}
64 
65  /**
66  * \brief Check if the ast node is an instance of ast::LagStatement
67  * \return true as object is of type ast::LagStatement
68  */
69  bool is_lag_statement () const noexcept override {
70  return true;
71  }
72 
73  /**
74  * \brief Return a copy of the current node
75  *
76  * Recursively make a new copy/clone of the current node including
77  * all members and return a pointer to the node. This is used for
78  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
79  * ast.
80  *
81  * \return pointer to the clone/copy of the current node
82  */
83  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
84  LagStatement* clone() const override {
85  return new LagStatement(*this);
86  }
87  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
88 
89  /// \name Getters
90  /// \{
91 
92  /**
93  * \brief Return type (ast::AstNodeType) of ast node
94  *
95  * Every node in the ast has a type defined in ast::AstNodeType and this
96  * function is used to retrieve the same.
97  *
98  * \return ast node type i.e. ast::AstNodeType::LAG_STATEMENT
99  *
100  * \sa Ast::get_node_type_name
101  */
102  AstNodeType get_node_type() const noexcept override {
104  }
105 
106  /**
107  * \brief Return type (ast::AstNodeType) of ast node as std::string
108  *
109  * Every node in the ast has a type defined in ast::AstNodeType.
110  * This type name can be returned as a std::string for printing
111  * node to text/json form.
112  *
113  * \return name of the node type as a string i.e. "LagStatement"
114  *
115  * \sa Ast::get_node_name
116  */
117  std::string get_node_type_name() const noexcept override {
118  return "LagStatement";
119  }
120 
121  /**
122  * \brief Return NMODL statement of ast node as std::string
123  *
124  * Every node is related to a special statement in the NMODL. This
125  * statement can be returned as a std::string for printing to
126  * text/json form.
127  *
128  * \return name of the statement as a string i.e. "LAG "
129  *
130  * \sa Ast::get_nmodl_name
131  */
132  std::string get_nmodl_name() const noexcept override {
133  return "LAG ";
134  }
135 
136  /**
137  * \brief Get std::shared_ptr from `this` pointer of the current ast node
138  */
139  std::shared_ptr<Ast> get_shared_ptr() override {
140  return std::static_pointer_cast<LagStatement>(shared_from_this());
141  }
142 
143  /**
144  * \brief Get std::shared_ptr from `this` pointer of the current ast node
145  */
146  std::shared_ptr<const Ast> get_shared_ptr() const override {
147  return std::static_pointer_cast<const LagStatement>(shared_from_this());
148  }
149 
150  /**
151  * \brief Return associated token for the current ast node
152  *
153  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
154  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
155  * nullptr to store in the nmodl::symtab::SymbolTable.
156  *
157  * \return pointer to token if exist otherwise nullptr
158  */
159  const ModToken* get_token() const noexcept override {
160  return token.get();
161  }
162 
163 
164 
165  /**
166  * \brief Getter for member variable \ref LagStatement.name
167  */
168  std::shared_ptr<Identifier> get_name() const noexcept {
169  return name;
170  }
171 
172 
173 
174  /**
175  * \brief Getter for member variable \ref LagStatement.byname
176  */
177  std::shared_ptr<Name> get_byname() const noexcept {
178  return byname;
179  }
180  /// \}
181 
182  /// \name Setters
183  /// \{
184  /**
185  * \brief Set token for the current ast node
186  */
187  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
188 
189  /**
190  * \brief Setter for member variable \ref LagStatement.name (rvalue reference)
191  */
192  void set_name(std::shared_ptr<Identifier>&& name);
193 
194  /**
195  * \brief Setter for member variable \ref LagStatement.name
196  */
197  void set_name(const std::shared_ptr<Identifier>& name);
198 
199 
200  /**
201  * \brief Setter for member variable \ref LagStatement.byname (rvalue reference)
202  */
203  void set_byname(std::shared_ptr<Name>&& byname);
204 
205  /**
206  * \brief Setter for member variable \ref LagStatement.byname
207  */
208  void set_byname(const std::shared_ptr<Name>& byname);
209 
210  /// \}
211 
212  /// \name Visitor
213  /// \{
214  /**
215  * \brief visit children i.e. member variables of current node using provided visitor
216  *
217  * Different nodes in the AST have different members (i.e. children). This method
218  * recursively visits children using provided visitor.
219  *
220  * \param v Concrete visitor that will be used to recursively visit children
221  *
222  * \sa Ast::visit_children for example.
223  */
224  void visit_children(visitor::Visitor& v) override;
225 
226  /**
227  * \brief visit children i.e. member variables of current node using provided visitor
228  *
229  * Different nodes in the AST have different members (i.e. children). This method
230  * recursively visits children using provided visitor.
231  *
232  * \param v Concrete constant visitor that will be used to recursively visit children
233  *
234  * \sa Ast::visit_children for example.
235  */
236  void visit_children(visitor::ConstVisitor& v) const override;
237 
238  /**
239  * \brief accept (or visit) the current AST node using provided visitor
240  *
241  * Instead of visiting children of AST node, like Ast::visit_children,
242  * accept allows to visit the current node itself using provided concrete
243  * visitor.
244  *
245  * \param v Concrete visitor that will be used to recursively visit node
246  *
247  * \sa Ast::accept for example.
248  */
249  void accept(visitor::Visitor& v) override;
250 
251  /**
252  * \copydoc accept(visitor::Visitor&)
253  */
254  void accept(visitor::ConstVisitor& v) const override;
255  /// \}
256 
257  private:
258  /**
259  * \brief Set this object as parent for all the children
260  *
261  * This should be called in every object (with children) constructor
262  * to set parents. Since it is called only in the constructors it
263  * should not be virtual to avoid ambiguities (issue #295).
264  */
265  void set_parent_in_children();
266 };
267 
268 /** \} */ // end of ast_class
269 
270 
271 
272 
273 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::LagStatement::LagStatement
LagStatement(Identifier *name, Name *byname)
Definition: ast.cpp:10843
nmodl::ast::Identifier
Base class for all identifiers.
Definition: identifier.hpp:41
nmodl::ast::AstNodeType::LAG_STATEMENT
@ LAG_STATEMENT
type of ast::LagStatement
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::LagStatement::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: lag_statement.hpp:102
nmodl::ast::LagStatement::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:10873
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::LagStatement::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:10834
nmodl::ast::LagStatement::get_name
std::shared_ptr< Identifier > get_name() const noexcept
Getter for member variable LagStatement::name.
Definition: lag_statement.hpp:168
nmodl::ast::LagStatement::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: lag_statement.hpp:132
nmodl::ast::LagStatement::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:10816
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::LagStatement::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: lag_statement.hpp:187
nmodl::ast::LagStatement::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: lag_statement.hpp:139
nmodl::ast::LagStatement::name
std::shared_ptr< Identifier > name
Name of the variable (TODO)
Definition: lag_statement.hpp:50
nmodl::ast::LagStatement::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: lag_statement.hpp:117
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::LagStatement::set_name
void set_name(std::shared_ptr< Identifier > &&name)
Setter for member variable LagStatement::name (rvalue reference)
Definition: ast.cpp:10888
nmodl::ast::LagStatement
Represents a LAG statement in the mod file.
Definition: lag_statement.hpp:47
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::LagStatement::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: lag_statement.hpp:146
nmodl::ast::LagStatement::clone
LagStatement * clone() const override
Return a copy of the current node.
Definition: lag_statement.hpp:84
nmodl::ast::LagStatement::token
std::shared_ptr< ModToken > token
token with location information
Definition: lag_statement.hpp:54
nmodl::ast::Name
Represents a name.
Definition: name.hpp:44
nmodl::ast::LagStatement::~LagStatement
virtual ~LagStatement()=default
nmodl::ast::LagStatement::get_byname
std::shared_ptr< Name > get_byname() const noexcept
Getter for member variable LagStatement::byname.
Definition: lag_statement.hpp:177
nmodl::ast::LagStatement::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: lag_statement.hpp:159
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::LagStatement::is_lag_statement
bool is_lag_statement() const noexcept override
Check if the ast node is an instance of ast::LagStatement.
Definition: lag_statement.hpp:69
nmodl::ast::LagStatement::set_byname
void set_byname(std::shared_ptr< Name > &&byname)
Setter for member variable LagStatement::byname (rvalue reference)
Definition: ast.cpp:10905
nmodl::ast::LagStatement::byname
std::shared_ptr< Name > byname
Name of the variable (TODO)
Definition: lag_statement.hpp:52