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