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