aboutsummaryrefslogtreecommitdiff
path: root/MoonParser/ast.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'MoonParser/ast.hpp')
-rw-r--r--MoonParser/ast.hpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/MoonParser/ast.hpp b/MoonParser/ast.hpp
index 1b40e1b..955cdc0 100644
--- a/MoonParser/ast.hpp
+++ b/MoonParser/ast.hpp
@@ -80,11 +80,20 @@ private:
80}; 80};
81 81
82template<class T> 82template<class T>
83T* ast_cast(ast_node *node) 83T* ast_cast(ast_node *node) {
84{
85 return node && ast_type<T>() == node->get_type() ? static_cast<T*>(node) : nullptr; 84 return node && ast_type<T>() == node->get_type() ? static_cast<T*>(node) : nullptr;
86} 85}
87 86
87template <class ...Args>
88bool ast_is(ast_node* node) {
89 if (!node) return false;
90 bool result = false;
91 int type = node->get_type();
92 using swallow = bool[];
93 (void)swallow{result || (result = ast_type<Args>() == type)...};
94 return result;
95}
96
88class ast_member; 97class ast_member;
89 98
90 99