User Guide
reaction_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"
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 TODO
36  *
37  *
38 */
39 class ReactionStatement : public Statement {
40  private:
41  /// TODO
42  std::shared_ptr<Expression> reaction1;
43  /// TODO
45  /// TODO
46  std::shared_ptr<Expression> reaction2;
47  /// TODO
48  std::shared_ptr<Expression> expression1;
49  /// TODO
50  std::shared_ptr<Expression> expression2;
51  /// token with location information
52  std::shared_ptr<ModToken> token;
53 
54  public:
55  /// \name Ctor & dtor
56  /// \{
58  explicit ReactionStatement(std::shared_ptr<Expression> reaction1, const ReactionOperator& op, std::shared_ptr<Expression> reaction2, std::shared_ptr<Expression> expression1, std::shared_ptr<Expression> expression2);
60  virtual ~ReactionStatement() = default;
61  /// \}
62 
63  /**
64  * \brief Check if the ast node is an instance of ast::ReactionStatement
65  * \return true as object is of type ast::ReactionStatement
66  */
67  bool is_reaction_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  ReactionStatement* clone() const override {
83  return new ReactionStatement(*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::REACTION_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. "ReactionStatement"
112  *
113  * \sa Ast::get_node_name
114  */
115  std::string get_node_type_name() const noexcept override {
116  return "ReactionStatement";
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. "~ "
127  *
128  * \sa Ast::get_nmodl_name
129  */
130  std::string get_nmodl_name() const noexcept override {
131  return "~ ";
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<ReactionStatement>(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 ReactionStatement>(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 ReactionStatement.reaction1
165  */
166  std::shared_ptr<Expression> get_reaction1() const noexcept {
167  return reaction1;
168  }
169 
170 
171 
172  /**
173  * \brief Getter for member variable \ref ReactionStatement.op
174  */
175  const ReactionOperator& get_op() const noexcept {
176  return op;
177  }
178 
179 
180 
181  /**
182  * \brief Getter for member variable \ref ReactionStatement.reaction2
183  */
184  std::shared_ptr<Expression> get_reaction2() const noexcept {
185  return reaction2;
186  }
187 
188 
189 
190  /**
191  * \brief Getter for member variable \ref ReactionStatement.expression1
192  */
193  std::shared_ptr<Expression> get_expression1() const noexcept {
194  return expression1;
195  }
196 
197 
198 
199  /**
200  * \brief Getter for member variable \ref ReactionStatement.expression2
201  */
202  std::shared_ptr<Expression> get_expression2() const noexcept {
203  return expression2;
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 ReactionStatement.reaction1 (rvalue reference)
216  */
217  void set_reaction1(std::shared_ptr<Expression>&& reaction1);
218 
219  /**
220  * \brief Setter for member variable \ref ReactionStatement.reaction1
221  */
222  void set_reaction1(const std::shared_ptr<Expression>& reaction1);
223 
224 
225  /**
226  * \brief Setter for member variable \ref ReactionStatement.op (rvalue reference)
227  */
228  void set_op(ReactionOperator&& op);
229 
230  /**
231  * \brief Setter for member variable \ref ReactionStatement.op
232  */
233  void set_op(const ReactionOperator& op);
234 
235 
236  /**
237  * \brief Setter for member variable \ref ReactionStatement.reaction2 (rvalue reference)
238  */
239  void set_reaction2(std::shared_ptr<Expression>&& reaction2);
240 
241  /**
242  * \brief Setter for member variable \ref ReactionStatement.reaction2
243  */
244  void set_reaction2(const std::shared_ptr<Expression>& reaction2);
245 
246 
247  /**
248  * \brief Setter for member variable \ref ReactionStatement.expression1 (rvalue reference)
249  */
250  void set_expression1(std::shared_ptr<Expression>&& expression1);
251 
252  /**
253  * \brief Setter for member variable \ref ReactionStatement.expression1
254  */
255  void set_expression1(const std::shared_ptr<Expression>& expression1);
256 
257 
258  /**
259  * \brief Setter for member variable \ref ReactionStatement.expression2 (rvalue reference)
260  */
261  void set_expression2(std::shared_ptr<Expression>&& expression2);
262 
263  /**
264  * \brief Setter for member variable \ref ReactionStatement.expression2
265  */
266  void set_expression2(const std::shared_ptr<Expression>& expression2);
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::ReactionStatement::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: reaction_statement.hpp:100
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::ReactionStatement::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: reaction_statement.hpp:115
nmodl::ast::ReactionStatement::is_reaction_statement
bool is_reaction_statement() const noexcept override
Check if the ast node is an instance of ast::ReactionStatement.
Definition: reaction_statement.hpp:67
nmodl::ast::ReactionStatement::expression1
std::shared_ptr< Expression > expression1
TODO.
Definition: reaction_statement.hpp:48
nmodl::ast::ReactionStatement::set_op
void set_op(ReactionOperator &&op)
Setter for member variable ReactionStatement::op (rvalue reference)
Definition: ast.cpp:10744
nmodl::ast::ReactionStatement::get_expression1
std::shared_ptr< Expression > get_expression1() const noexcept
Getter for member variable ReactionStatement::expression1.
Definition: reaction_statement.hpp:193
nmodl::ast::ReactionStatement::expression2
std::shared_ptr< Expression > expression2
TODO.
Definition: reaction_statement.hpp:50
nmodl::ast::ReactionStatement::reaction2
std::shared_ptr< Expression > reaction2
TODO.
Definition: reaction_statement.hpp:46
nmodl::ast::ReactionStatement::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: reaction_statement.hpp:137
nmodl::ast::ReactionStatement::set_expression2
void set_expression2(std::shared_ptr< Expression > &&expression2)
Setter for member variable ReactionStatement::expression2 (rvalue reference)
Definition: ast.cpp:10787
nmodl::ast::ReactionStatement::clone
ReactionStatement * clone() const override
Return a copy of the current node.
Definition: reaction_statement.hpp:82
nmodl::ast::ReactionStatement::get_expression2
std::shared_ptr< Expression > get_expression2() const noexcept
Getter for member variable ReactionStatement::expression2.
Definition: reaction_statement.hpp:202
nmodl::ast::ReactionStatement::op
ReactionOperator op
TODO.
Definition: reaction_statement.hpp:44
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::ReactionStatement::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: reaction_statement.hpp:144
nmodl::ast::ReactionStatement::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: reaction_statement.hpp:212
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::ReactionStatement::get_reaction2
std::shared_ptr< Expression > get_reaction2() const noexcept
Getter for member variable ReactionStatement::reaction2.
Definition: reaction_statement.hpp:184
nmodl::ast::ReactionStatement::~ReactionStatement
virtual ~ReactionStatement()=default
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
nmodl::ast::ReactionStatement::get_reaction1
std::shared_ptr< Expression > get_reaction1() const noexcept
Getter for member variable ReactionStatement::reaction1.
Definition: reaction_statement.hpp:166
statement.hpp
Auto generated AST classes declaration.
nmodl::ast::ReactionOperator
TODO.
Definition: reaction_operator.hpp:38
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::ReactionStatement::ReactionStatement
ReactionStatement(Expression *reaction1, const ReactionOperator &op, Expression *reaction2, Expression *expression1, Expression *expression2)
Definition: ast.cpp:10663
nmodl::ast::ReactionStatement::get_op
const ReactionOperator & get_op() const noexcept
Getter for member variable ReactionStatement::op.
Definition: reaction_statement.hpp:175
nmodl::ast::ReactionStatement::reaction1
std::shared_ptr< Expression > reaction1
TODO.
Definition: reaction_statement.hpp:42
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::ReactionStatement::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:10610
nmodl::ast::ReactionStatement::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:10703
nmodl::ast::ReactionStatement::set_reaction2
void set_reaction2(std::shared_ptr< Expression > &&reaction2)
Setter for member variable ReactionStatement::reaction2 (rvalue reference)
Definition: ast.cpp:10753
nmodl::ast::ReactionStatement
TODO.
Definition: reaction_statement.hpp:39
nmodl::ast::ReactionStatement::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: reaction_statement.hpp:130
nmodl::ast::ReactionStatement::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: reaction_statement.hpp:157
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ast::ReactionStatement::set_reaction1
void set_reaction1(std::shared_ptr< Expression > &&reaction1)
Setter for member variable ReactionStatement::reaction1 (rvalue reference)
Definition: ast.cpp:10727
nmodl::ast::ReactionStatement::set_expression1
void set_expression1(std::shared_ptr< Expression > &&expression1)
Setter for member variable ReactionStatement::expression1 (rvalue reference)
Definition: ast.cpp:10770
reaction_operator.hpp
Auto generated AST classes declaration.
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::ReactionStatement::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:10654
nmodl::ast::AstNodeType::REACTION_STATEMENT
@ REACTION_STATEMENT
type of ast::ReactionStatement
nmodl::ast::ReactionStatement::token
std::shared_ptr< ModToken > token
token with location information
Definition: reaction_statement.hpp:52