Prism Ruby parser
Loading...
Searching...
No Matches
node_type.hpp
Go to the documentation of this file.
1
7#ifndef PRISM_NODE_TYPE_HPP
8#define PRISM_NODE_TYPE_HPP
9
10#include "prism/compiler/cplusplus.hpp"
11
12#include "prism/ast.h"
13
14#include <type_traits>
15
16namespace prism {
17
22template <typename T> struct node_type {};
23
25template <typename T> inline constexpr pm_node_type_t node_type_v = node_type<T>::value;
26
28template <typename T, typename = void> struct is_node : std::false_type {};
29
31template <typename T> struct is_node<T, std::void_t<decltype(node_type<T>::value)>> : std::true_type {};
32
34template <typename T> inline constexpr bool is_node_v = is_node<T>::value;
35
36}
37
38#endif
The abstract syntax tree.
uint16_t pm_node_type_t
This is the type of node embedded in the node struct.
Definition ast.h:1076
constexpr bool is_node_v
Whether the given type is one of the node structs declared in ast.h.
Definition node_type.hpp:34
constexpr pm_node_type_t node_type_v
The node type of the given node struct.
Definition node_type.hpp:25
Whether the given type is one of the node structs declared in ast.h.
Definition node_type.hpp:28
Maps a node struct to its node type, as in node_type<pm_call_node_t>::value being PM_CALL_NODE.
Definition node_type.hpp:22