User Guide
docstrings.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 #pragma once
9 
10 namespace nmodl {
11 namespace docstring {
12 
13 constexpr const char* binary_op_enum() {
14  return R"(
15  Enum type for binary operators in NMODL
16 
17  NMODL support different binary operators and this
18  type is used to store their value in the AST. See
19  nmodl::ast::Ast for details.
20 )";
21 }
22 
23 constexpr const char* ast_nodetype_enum() {
24  return R"(
25  Enum type for every AST node type
26 
27  Every node in the ast has associated type represented by
28  this enum class. See nmodl::ast::AstNodeType for details.
29 
30 )";
31 }
32 
33 constexpr const char* ast_class() {
34  return R"(
35  Base class for all Abstract Syntax Tree node types
36 
37  Every node in the Abstract Syntax Tree is inherited from base class
38  Ast. This class provides base properties and functions that are implemented
39  by base classes.
40 )";
41 }
42 
43 constexpr const char* accept_method() {
44  return R"(
45  Accept (or visit) the current AST node using current visitor
46 
47  Instead of visiting children of AST node, like Ast::visit_children,
48  accept allows to visit the current node itself using the concrete
49  visitor provided.
50 
51  Args:
52  v (Visitor): Concrete visitor that will be used to recursively visit node
53 )";
54 }
55 
56 constexpr const char* visit_children_method() {
57  return R"(
58  Visit children i.e. member of current AST node using provided visitor
59 
60  Different nodes in the AST have different members (i.e. children). This method
61  recursively visits children using provided concrete visitor.
62 
63  Args:
64  v (Visitor): Concrete visitor that will be used to recursively visit node
65 )";
66 }
67 
68 constexpr const char* get_node_type_method() {
69  return R"(
70  Return type (ast.AstNodeType) of the ast node
71 )";
72 }
73 
74 constexpr const char* get_node_type_name_method() {
75  return R"(
76  Return type (ast.AstNodeType) of the ast node as string
77 )";
78 }
79 
80 constexpr const char* get_node_name_method() {
81  return R"(
82  Return name of the node
83 
84  Some ast nodes have a member designated as node name. For example,
85  in case of ast.FunctionCall, name of the function is returned as a node
86  name. Note that this is different from ast node type name and not every
87  ast node has name.
88 )";
89 }
90 
91 constexpr const char* get_nmodl_name_method() {
92  return R"(
93  Return nmodl statement of the node
94 
95  Some ast nodes have a member designated as nmodl name. For example,
96  in case of "NEURON { }" the statement of NMODL which is stored as nmodl
97  name is "NEURON". This function is only implemented by node types that
98  have a nmodl statement.
99 )";
100 }
101 
102 
103 constexpr const char* clone_method() {
104  return R"(
105  Create a copy of the AST node
106 )";
107 }
108 
109 constexpr const char* get_token_method() {
110  return R"(
111  Return associated token for the AST node
112 )";
113 }
114 
115 constexpr const char* get_symbol_table_method() {
116  return R"(
117  Return associated symbol table for the AST node
118 
119  Certain ast nodes (e.g. inherited from ast.Block) have associated
120  symbol table. These nodes have nmodl.symtab.SymbolTable as member
121  and it can be accessed using this method.
122 )";
123 }
124 
125 constexpr const char* get_statement_block_method() {
126  return R"(
127  Return associated statement block for the AST node
128 
129  Top level block nodes encloses all statements in the ast::StatementBlock.
130  For example, ast.BreakpointBlock has all statements in curly brace (`{ }`)
131  stored in ast.StatementBlock :
132 
133  BREAKPOINT {
134  SOLVE states METHOD cnexp
135  gNaTs2_t = gNaTs2_tbar*m*m*m*h
136  ina = gNaTs2_t*(v-ena)
137  }
138 
139  This method return enclosing statement block.
140 )";
141 }
142 
143 constexpr const char* negate_method() {
144  return R"(
145  Negate the value of AST node
146 )";
147 }
148 
149 constexpr const char* set_name_method() {
150  return R"(
151  Set name for the AST node
152 )";
153 }
154 
155 constexpr const char* is_ast_method() {
156  return R"(
157  Check if current node is of type ast.Ast
158 )";
159 }
160 
161 constexpr const char* eval_method() {
162  return R"(
163  Return value of the ast node
164 )";
165 }
166 
167 constexpr const char* parent_property() {
168  return R"(
169  Get or set the parent of this node
170 )";
171 }
172 
173 } // namespace docstring
174 } // namespace nmodl
nmodl::docstring::set_name_method
constexpr const char * set_name_method()
Definition: docstrings.hpp:149
nmodl::docstring::get_node_type_method
constexpr const char * get_node_type_method()
Definition: docstrings.hpp:68
nmodl::docstring::accept_method
constexpr const char * accept_method()
Definition: docstrings.hpp:43
nmodl::docstring::clone_method
constexpr const char * clone_method()
Definition: docstrings.hpp:103
nmodl::docstring::get_node_type_name_method
constexpr const char * get_node_type_name_method()
Definition: docstrings.hpp:74
nmodl::docstring::parent_property
constexpr const char * parent_property()
Definition: docstrings.hpp:167
nmodl::docstring::negate_method
constexpr const char * negate_method()
Definition: docstrings.hpp:143
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::docstring::is_ast_method
constexpr const char * is_ast_method()
Definition: docstrings.hpp:155
nmodl::docstring::get_token_method
constexpr const char * get_token_method()
Definition: docstrings.hpp:109
nmodl::docstring::ast_nodetype_enum
constexpr const char * ast_nodetype_enum()
Definition: docstrings.hpp:23
nmodl::docstring::get_node_name_method
constexpr const char * get_node_name_method()
Definition: docstrings.hpp:80
nmodl::docstring::eval_method
constexpr const char * eval_method()
Definition: docstrings.hpp:161
nmodl::docstring::get_nmodl_name_method
constexpr const char * get_nmodl_name_method()
Definition: docstrings.hpp:91
nmodl::docstring::get_symbol_table_method
constexpr const char * get_symbol_table_method()
Definition: docstrings.hpp:115
nmodl::docstring::get_statement_block_method
constexpr const char * get_statement_block_method()
Definition: docstrings.hpp:125
nmodl::docstring::visit_children_method
constexpr const char * visit_children_method()
Definition: docstrings.hpp:56
nmodl::docstring::ast_class
constexpr const char * ast_class()
Definition: docstrings.hpp:33
nmodl::docstring::binary_op_enum
constexpr const char * binary_op_enum()
Definition: docstrings.hpp:13