Bash++
Bash++ compiler internal documentation
PrimitiveAssignment.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <AST/ASTNode.h>
10
11namespace AST {
12
14 protected:
16 bool m_local = false;
17 public:
19 constexpr AST::NodeType getType() const override { return static_type; }
20
22 return m_IDENTIFIER;
23 }
24 void setIdentifier(const AST::Token<std::string>& identifier) {
25 m_IDENTIFIER = identifier;
26 }
27
28 bool isLocal() const {
29 return m_local;
30 }
31 void setLocal(bool local) {
32 m_local = local;
33 }
34
35 std::ostream& prettyPrint(std::ostream& os, int indentation_level = 0) const override {
36 std::string indent(indentation_level * PRETTYPRINT_INDENTATION_AMOUNT, ' ');
37 os << indent << "(PrimitiveAssignment\n"
38 << indent << " " << (m_local ? "local " : "") << m_IDENTIFIER << "=";
39 for (const auto& child : children) {
40 os << std::endl;
41 child->prettyPrint(os, indentation_level + 1);
42 }
43 os << ")" << std::flush;
44 return os;
45 }
46};
47
48} // namespace AST
#define PRETTYPRINT_INDENTATION_AMOUNT
Definition ASTNode.h:19
The base class for all non-terminal nodes in the Bash++ AST. Each ASTNode contains information about ...
Definition ASTNode.h:29
std::vector< std::shared_ptr< ASTNode > > children
Definition ASTNode.h:31
Definition PrimitiveAssignment.h:13
constexpr AST::NodeType getType() const override
Definition PrimitiveAssignment.h:19
std::ostream & prettyPrint(std::ostream &os, int indentation_level=0) const override
Definition PrimitiveAssignment.h:35
AST::Token< std::string > m_IDENTIFIER
Definition PrimitiveAssignment.h:15
void setIdentifier(const AST::Token< std::string > &identifier)
Definition PrimitiveAssignment.h:24
bool isLocal() const
Definition PrimitiveAssignment.h:28
bool m_local
Definition PrimitiveAssignment.h:16
static constexpr AST::NodeType static_type
Definition PrimitiveAssignment.h:18
const AST::Token< std::string > & IDENTIFIER() const
Definition PrimitiveAssignment.h:21
void setLocal(bool local)
Definition PrimitiveAssignment.h:31
A class representing a token in the Bash++ AST. Tokens store their value along with line and column i...
Definition Token.h:22
Definition AccessModifier.h:9
NodeType
Definition NodeTypes.h:10