NEURON
ast_common.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 /**
11  * \dir
12  * \brief AST Implementation
13  *
14  * \file
15  * \brief Implementation of AST base class and it's properties
16  */
17 
18 #include <memory>
19 #include <string>
20 
21 #include "ast/ast_decl.hpp"
22 #include "lexer/modtoken.hpp"
23 #include "symtab/symbol_table.hpp"
24 #include "visitors/visitor.hpp"
25 
26 namespace nmodl {
27 
28 /// Abstract Syntax Tree (AST) related implementations
29 namespace ast {
30 
31 /**
32  * @defgroup ast AST Implementation
33  * @brief All AST related implementation details
34  *
35  * @defgroup ast_prop AST Properties
36  * @ingroup ast
37  * @brief Properties and types used with of AST classes
38  * @{
39  */
40 
41 /**
42  * \brief enum Type for binary operators in NMODL
43  *
44  * NMODL support different binary operators and this
45  * type is used to store their value in the AST.
46  */
47 typedef enum {
48  BOP_ADDITION, ///< \+
49  BOP_SUBTRACTION, ///< --
50  BOP_MULTIPLICATION, ///< \c *
51  BOP_DIVISION, ///< \/
52  BOP_POWER, ///< ^
53  BOP_AND, ///< &&
54  BOP_OR, ///< ||
55  BOP_GREATER, ///< >
56  BOP_LESS, ///< <
58  BOP_LESS_EQUAL, ///< <=
59  BOP_ASSIGN, ///< =
60  BOP_NOT_EQUAL, ///< !=
61  BOP_EXACT_EQUAL ///< ==
63 
64 /**
65  * \brief string representation of ast::BinaryOp
66  *
67  * When AST is converted back to NMODL or C code, ast::BinaryOpNames
68  * is used to lookup the corresponding symbol for the operator.
69  */
70 static const std::string BinaryOpNames[] =
71  {"+", "-", "*", "/", "^", "&&", "||", ">", "<", ">=", "<=", "=", "!=", "=="};
72 
73 /// enum type for unary operators
74 typedef enum { UOP_NOT, UOP_NEGATION } UnaryOp;
75 
76 /// string representation of ast::UnaryOp
77 static const std::string UnaryOpNames[] = {"!", "-"};
78 
79 /// enum type to distinguish BEFORE or AFTER blocks
81 
82 /// string representation of ast::BAType
83 static const std::string BATypeNames[] = {"BREAKPOINT", "SOLVE", "INITIAL", "STEP"};
84 
85 /// enum type used for UNIT_ON or UNIT_OFF state
86 typedef enum { UNIT_ON, UNIT_OFF } UnitStateType;
87 
88 /// string representation of ast::UnitStateType
89 static const std::string UnitStateTypeNames[] = {"UNITSON", "UNITSOFF"};
90 
91 /// enum type used for Reaction statement
92 typedef enum { LTMINUSGT, LTLT, MINUSGT } ReactionOp;
93 
94 /// string representation of ast::ReactionOp
95 static const std::string ReactionOpNames[] = {"<->", "<<", "->"};
96 
97 /** @} */ // end of ast_prop
98 
99 } // namespace ast
100 } // namespace nmodl
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
BinaryOp
enum Type for binary operators in NMODL
Definition: ast_common.hpp:47
ReactionOp
enum type used for Reaction statement
Definition: ast_common.hpp:92
static const std::string ReactionOpNames[]
string representation of ast::ReactionOp
Definition: ast_common.hpp:95
UnitStateType
enum type used for UNIT_ON or UNIT_OFF state
Definition: ast_common.hpp:86
static const std::string BinaryOpNames[]
string representation of ast::BinaryOp
Definition: ast_common.hpp:70
static const std::string UnaryOpNames[]
string representation of ast::UnaryOp
Definition: ast_common.hpp:77
static const std::string UnitStateTypeNames[]
string representation of ast::UnitStateType
Definition: ast_common.hpp:89
BAType
enum type to distinguish BEFORE or AFTER blocks
Definition: ast_common.hpp:80
UnaryOp
enum type for unary operators
Definition: ast_common.hpp:74
static const std::string BATypeNames[]
string representation of ast::BAType
Definition: ast_common.hpp:83
@ BOP_EXACT_EQUAL
==
Definition: ast_common.hpp:61
@ BOP_GREATER_EQUAL
>=
Definition: ast_common.hpp:57
@ BOP_NOT_EQUAL
!=
Definition: ast_common.hpp:60
@ BOP_DIVISION
\/
Definition: ast_common.hpp:51
@ BOP_SUBTRACTION
Definition: ast_common.hpp:49
@ BOP_LESS_EQUAL
<=
Definition: ast_common.hpp:58
@ BOP_MULTIPLICATION
*
Definition: ast_common.hpp:50
@ BATYPE_BREAKPOINT
Definition: ast_common.hpp:80
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
Implement classes for representing symbol table at block and file scope.