9 #ifndef META_PARSE_TREE_NODE_H_
10 #define META_PARSE_TREE_NODE_H_
14 #include "parser/trees/visitors/visitor.h"
31 node(class_label cat);
41 virtual bool is_leaf()
const = 0;
53 virtual bool equal(
const node& other)
const = 0;
59 virtual std::unique_ptr<node>
clone()
const = 0;
66 template <
class Visitor>
67 typename std::remove_reference<Visitor>::type::result_type
73 return vtor(as<leaf_node>());
74 return vtor(as<internal_node>());
84 template <
class Visitor>
85 typename std::remove_reference<Visitor>::type::result_type
89 return vtor(as<leaf_node>());
90 return vtor(as<internal_node>());
100 template <
class Node>
103 return static_cast<Node&
>(*this);
113 template <
class Node>
114 typename std::add_const<Node>::type&
as()
const
116 return static_cast<typename std::add_const<Node>::type&
>(*this);
122 virtual ~node() =
default;