21#define CHILD_OF(t) std::dynamic_pointer_cast<t##Decl>(child)
22#define NESTED_DECL(t, cond, msg, I, ...) \
23 if (const auto decl = std::dynamic_pointer_cast<t##Decl>(node)) { \
24 if (!handle##t##Begin(context, *decl, out, indent)) { \
28 for (auto i = 0; i < decl->children().size(); ++i) { \
29 auto &child = decl->children()[i]; \
34 if (!handleDecl(context, child, out, indent + 1 + I)) { \
40 if (!handle##t##End(context, *decl, out, indent)) { \
46 else NESTED_DECL(Namespace,
CHILD_OF(Assembly),
"AssemblyDecl cannot be the child of NamespaceDecl", 0)
47 else NESTED_DECL(Object,
CHILD_OF(Namespace) ||
CHILD_OF(Assembly),
"AssemblyDecl or NamespaceDecl cannot be the child of ObjectDecl", 0)
50 "Only ParamDecl can be the child of MethodDecl", 0,
51 if (i != decl->children().size() - 1) { writeParamDelimiter(out); })
54 "Only ParamDecl can be the child of FunctionDecl", 0,
55 if (i != decl->children().size() - 1) { writeParamDelimiter(out); })
56 else if (
const auto decl = std::dynamic_pointer_cast<ParamDecl>(node)) {
57 if (!handleParam(context, *decl, out, indent)) {
60 if (decl->children().size()) {
61 context.
error(
"ParamDecl cannot have any children");
void error(const std::string &what)