#ifndef UTIL_H #define UTIL_H #include #include #include #include "types.h" class Node; #include "Node.h" namespace Util { void Die(const char *msg); void Die(const char * msg, const char * more); void Die(std::string msg); template T* FindNodeByType(Node *&root, const Name &type) { if (root->GetType() == type) { return dynamic_cast(root); } for (Node *child : root->children) { T* res = FindNodeByType(child, type); if (res) { return res; } } return nullptr; } } #endif /* UTIL_H */