21#define AST_LISTENER_NODE_LIST(X) \
24 X(Bash53NativeSupershell) \
25 X(BashArithmeticForCondition) \
26 X(BashArithmeticForStatement) \
27 X(BashArithmeticStatement) \
28 X(BashArithmeticSubstitution) \
31 X(BashCasePatternHeader) \
32 X(BashCaseStatement) \
34 X(BashCommandSequence) \
44 X(BashSelectStatement) \
45 X(BashTestConditionCommand) \
46 X(BashUntilStatement) \
48 X(BashWhileOrUntilCondition) \
49 X(BashWhileStatement) \
53 X(ConstructorDefinition) \
54 X(DatamemberDeclaration) \
56 X(DestructorDefinition) \
57 X(DoublequotedString) \
59 X(DynamicCastTarget) \
66 X(ObjectInstantiation) \
68 X(ParameterExpansion) \
69 X(PointerDeclaration) \
70 X(PrimitiveAssignment) \
71 X(ProcessSubstitution) \
76 X(SubshellSubstitution) \
110template <
class Derived>
114 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;
159 this->parser_errors = errors;
160 if (!errors.empty()) this->program_has_errors =
true;
#define AST_LISTENER_NODE_LIST(X)
Definition BaseListener.h:21
CRTP base class for AST listeners. CRTP is a kind of language hack that makes static polymorphism pos...
Definition BaseListener.h:111
void set_parser_errors(const std::vector< AST::ParserError > &errors)
Definition BaseListener.h:158
bool program_has_errors
Definition BaseListener.h:118
void walk(std::shared_ptr< AST::ASTNode > node)
Definition BaseListener.h:122
std::vector< AST::ParserError > parser_errors
Definition BaseListener.h:119
void set_has_errors(bool has_errors)
Definition BaseListener.h:154
Derived & self()
Definition BaseListener.h:113
void print() const
Definition SyntaxError.h:102
An exception thrown when a syntax error is encountered This exception can be constructed from any lis...
Definition SyntaxError.h:125
Definition AccessModifier.h:10
An exception thrown when an internal error occurs.
Definition InternalError.h:21