22#define AST_LISTENER_NODE_LIST(X) \
25 X(Bash53NativeSupershell) \
26 X(BashArithmeticForCondition) \
27 X(BashArithmeticForStatement) \
28 X(BashArithmeticStatement) \
29 X(BashArithmeticSubstitution) \
32 X(BashCasePatternHeader) \
33 X(BashCaseStatement) \
35 X(BashCommandSequence) \
45 X(BashSelectStatement) \
46 X(BashTestConditionCommand) \
47 X(BashUntilStatement) \
49 X(BashWhileOrUntilCondition) \
50 X(BashWhileStatement) \
54 X(ConstructorDefinition) \
55 X(DatamemberDeclaration) \
57 X(DestructorDefinition) \
58 X(DoublequotedString) \
60 X(DynamicCastTarget) \
67 X(ObjectInstantiation) \
69 X(ParameterExpansion) \
70 X(PointerDeclaration) \
71 X(PrimitiveAssignment) \
72 X(ProcessSubstitution) \
77 X(SubshellSubstitution) \
111template <
class Derived>
115 return static_cast<Derived&
>(*this);
125 void walk(std::shared_ptr<AST::ASTNode> node) {
127 switch (node->getType()) {
128 #define AST_CASE(Name) \
129 case AST::NodeType::Name: \
130 if constexpr (requires(Derived& d, std::shared_ptr<AST::Name> x) { d.enter##Name(x); }) { \
131 self().enter##Name(std::static_pointer_cast<AST::Name>(node)); \
133 for (const auto& child : node->getChildren()) { \
136 if constexpr (requires(Derived& d, std::shared_ptr<AST::Name> x) { d.exit##Name(x); }) { \
137 self().exit##Name(std::static_pointer_cast<AST::Name>(node)); \
150 this->program_has_errors =
true;
155 #undef AST_LISTENER_NODE_LIST
158 this->program_has_errors = has_errors;
162 this->parser_errors = errors;
163 if (!errors.empty()) this->program_has_errors =
true;
#define AST_LISTENER_NODE_LIST(X)
Definition BaseListener.h:22
CRTP base class for AST listeners. CRTP is a kind of language hack that makes static polymorphism pos...
Definition BaseListener.h:112
void set_parser_errors(const std::vector< AST::ParserError > &errors)
Definition BaseListener.h:161
bool program_has_errors
Definition BaseListener.h:119
virtual ~BaseListener()=default
void walk(std::shared_ptr< AST::ASTNode > node)
Definition BaseListener.h:125
std::vector< AST::ParserError > parser_errors
Definition BaseListener.h:120
void set_has_errors(bool has_errors)
Definition BaseListener.h:157
Derived & self()
Definition BaseListener.h:114
void print() const
Definition SyntaxError.h:104
An exception thrown when a syntax error is encountered This exception can be constructed from any lis...
Definition SyntaxError.h:127
Definition AccessModifier.h:9
An exception thrown when an internal error occurs.
Definition InternalError.h:22