20#define AST_LISTENER_NODE_LIST(X) \
23 X(Bash53NativeSupershell) \
24 X(BashArithmeticForCondition) \
25 X(BashArithmeticForStatement) \
26 X(BashArithmeticStatement) \
27 X(BashArithmeticSubstitution) \
30 X(BashCasePatternHeader) \
31 X(BashCaseStatement) \
33 X(BashCommandSequence) \
43 X(BashSelectStatement) \
44 X(BashTestConditionCommand) \
45 X(BashUntilStatement) \
47 X(BashWhileOrUntilCondition) \
48 X(BashWhileStatement) \
52 X(ConstructorDefinition) \
53 X(DatamemberDeclaration) \
55 X(DestructorDefinition) \
56 X(DoublequotedString) \
58 X(DynamicCastTarget) \
65 X(ObjectInstantiation) \
67 X(ParameterExpansion) \
68 X(PointerDeclaration) \
69 X(PrimitiveAssignment) \
70 X(ProcessSubstitution) \
75 X(SubshellSubstitution) \
109template <
class Derived>
113 return static_cast<Derived&
>(*this);
122 void walk(std::shared_ptr<AST::ASTNode> node) {
124 switch (node->getType()) {
125 #define AST_CASE(Name) \
126 case AST::NodeType::Name: \
127 if constexpr (requires(Derived& d, std::shared_ptr<AST::Name> x) { d.enter##Name(x); }) { \
128 self().enter##Name(std::static_pointer_cast<AST::Name>(node)); \
130 for (const auto& child : node->getChildren()) { \
133 if constexpr (requires(Derived& d, std::shared_ptr<AST::Name> x) { d.exit##Name(x); }) { \
134 self().exit##Name(std::static_pointer_cast<AST::Name>(node)); \
147 this->program_has_errors =
true;
152 #undef AST_LISTENER_NODE_LIST
155 this->program_has_errors = has_errors;
#define AST_LISTENER_NODE_LIST(X)
Definition BaseListener.h:20
CRTP base class for AST listeners. CRTP is a kind of language hack that makes static polymorphism pos...
Definition BaseListener.h:110
bool program_has_errors
Definition BaseListener.h:117
virtual ~BaseListener()=default
void walk(std::shared_ptr< AST::ASTNode > node)
Definition BaseListener.h:122
void set_has_errors(bool has_errors)
Definition BaseListener.h:154
Derived & self()
Definition BaseListener.h:112
void print() const
Definition SyntaxError.h:103
An exception thrown when a syntax error is encountered This exception can be constructed from any lis...
Definition SyntaxError.h:126
Definition AccessModifier.h:8
An exception thrown when an internal error occurs.
Definition InternalError.h:21