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