User Guide
identifier.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/expression.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief Base class for all identifiers
35  *
36  * Base class for all variable types like ast::Name, ast::PrimeName and ast::Argument.
37  *
38  * \sa ast::Number
39  *
40 */
41 class Identifier : public Expression {
42 
43  public:
44  /// \name Ctor & dtor
45  /// \{
46  virtual ~Identifier() = default;
47  /// \}
48 
49  /**
50  * \brief Check if the ast node is an instance of ast::Identifier
51  * \return true as object is of type ast::Identifier
52  */
53  bool is_identifier () const noexcept override {
54  return true;
55  }
56 
57  /**
58  * \brief Return a copy of the current node
59  *
60  * Recursively make a new copy/clone of the current node including
61  * all members and return a pointer to the node. This is used for
62  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
63  * ast.
64  *
65  * \return pointer to the clone/copy of the current node
66  */
67  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
68  Identifier* clone() const override {
69  return new Identifier(*this);
70  }
71  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
72 
73  /// \name Getters
74  /// \{
75 
76  /**
77  * \brief Return type (ast::AstNodeType) of ast node
78  *
79  * Every node in the ast has a type defined in ast::AstNodeType and this
80  * function is used to retrieve the same.
81  *
82  * \return ast node type i.e. ast::AstNodeType::IDENTIFIER
83  *
84  * \sa Ast::get_node_type_name
85  */
86  AstNodeType get_node_type() const noexcept override {
88  }
89 
90  /**
91  * \brief Return type (ast::AstNodeType) of ast node as std::string
92  *
93  * Every node in the ast has a type defined in ast::AstNodeType.
94  * This type name can be returned as a std::string for printing
95  * node to text/json form.
96  *
97  * \return name of the node type as a string i.e. "Identifier"
98  *
99  * \sa Ast::get_node_name
100  */
101  std::string get_node_type_name() const noexcept override {
102  return "Identifier";
103  }
104 
105 
106  /**
107  * \brief Get std::shared_ptr from `this` pointer of the current ast node
108  */
109  std::shared_ptr<Ast> get_shared_ptr() override {
110  return std::static_pointer_cast<Identifier>(shared_from_this());
111  }
112 
113  /**
114  * \brief Get std::shared_ptr from `this` pointer of the current ast node
115  */
116  std::shared_ptr<const Ast> get_shared_ptr() const override {
117  return std::static_pointer_cast<const Identifier>(shared_from_this());
118  }
119 
120  /// \}
121 
122 
123 
124  /// \name Visitor
125  /// \{
126  /**
127  * \brief visit children i.e. member variables of current node using provided visitor
128  *
129  * Different nodes in the AST have different members (i.e. children). This method
130  * recursively visits children using provided visitor.
131  *
132  * \param v Concrete visitor that will be used to recursively visit children
133  *
134  * \sa Ast::visit_children for example.
135  */
136  void visit_children(visitor::Visitor& v) override;
137 
138  /**
139  * \brief visit children i.e. member variables of current node using provided visitor
140  *
141  * Different nodes in the AST have different members (i.e. children). This method
142  * recursively visits children using provided visitor.
143  *
144  * \param v Concrete constant visitor that will be used to recursively visit children
145  *
146  * \sa Ast::visit_children for example.
147  */
148  void visit_children(visitor::ConstVisitor& v) const override;
149 
150  /**
151  * \brief accept (or visit) the current AST node using provided visitor
152  *
153  * Instead of visiting children of AST node, like Ast::visit_children,
154  * accept allows to visit the current node itself using provided concrete
155  * visitor.
156  *
157  * \param v Concrete visitor that will be used to recursively visit node
158  *
159  * \sa Ast::accept for example.
160  */
161  void accept(visitor::Visitor& v) override;
162 
163  /**
164  * \copydoc accept(visitor::Visitor&)
165  */
166  void accept(visitor::ConstVisitor& v) const override;
167  /// \}
168 
169 };
170 
171 /** \} */ // end of ast_class
172 
173 
174 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::Identifier::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:414
nmodl::ast::Identifier
Base class for all identifiers.
Definition: identifier.hpp:41
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::Identifier::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: identifier.hpp:101
nmodl::ast::Identifier::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: identifier.hpp:86
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
nmodl::ast::AstNodeType::IDENTIFIER
@ IDENTIFIER
type of ast::Identifier
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::Identifier::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: identifier.hpp:109
nmodl::ast::Identifier::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:420
nmodl::ast::Identifier::~Identifier
virtual ~Identifier()=default
nmodl::ast::Identifier::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: identifier.hpp:116
expression.hpp
Auto generated AST classes declaration.
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ast::Identifier::clone
Identifier * clone() const override
Return a copy of the current node.
Definition: identifier.hpp:68
nmodl::ast::Identifier::is_identifier
bool is_identifier() const noexcept override
Check if the ast node is an instance of ast::Identifier.
Definition: identifier.hpp:53