diff options
| author | Li Jin <dragon-fly@qq.com> | 2017-07-19 15:26:04 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2017-07-19 15:26:04 +0800 |
| commit | 3b270690501cfcc9220c8d5b63ab6f13fc2bd6b0 (patch) | |
| tree | 0f3c76f1318269b8d70d646794b3424be145dd2d /MoonParser/ast.hpp | |
| parent | 65dd230959dbab99b52b99fd807534c254fb4ed9 (diff) | |
| download | yuescript-3b270690501cfcc9220c8d5b63ab6f13fc2bd6b0.tar.gz yuescript-3b270690501cfcc9220c8d5b63ab6f13fc2bd6b0.tar.bz2 yuescript-3b270690501cfcc9220c8d5b63ab6f13fc2bd6b0.zip | |
stop implementing moon compiler.
Diffstat (limited to 'MoonParser/ast.hpp')
| -rw-r--r-- | MoonParser/ast.hpp | 13 |
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 | ||
| 82 | template<class T> | 82 | template<class T> |
| 83 | T* ast_cast(ast_node *node) | 83 | T* 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 | ||
| 87 | template <class ...Args> | ||
| 88 | bool 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 | |||
| 88 | class ast_member; | 97 | class ast_member; |
| 89 | 98 | ||
| 90 | 99 | ||
