ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Private Attributes | List of all members
meta::parser::node Class Referenceabstract

A single node in a parse tree for a sentence. More...

#include <node.h>

Public Member Functions

 node (class_label cat)
 Constructs a new node with the given category. More...
 
const class_label & category () const
 
virtual bool is_leaf () const =0
 
bool is_temporary () const
 
virtual bool equal (const node &other) const =0
 
virtual std::unique_ptr< nodeclone () const =0
 Clones the given node. More...
 
template<class Visitor >
std::remove_reference< Visitor >::type::result_type accept (Visitor &&vtor)
 Accepts a visitor. More...
 
template<class Visitor >
std::remove_reference< Visitor >::type::result_type accept (Visitor &&vtor) const
 Accepts a visitor (const version). More...
 
template<class Node >
Node & as ()
 Casting operation for nodes to derived types. More...
 
template<class Node >
std::add_const< Node >::type & as () const
 Casting operation for nodes to derived types. More...
 
virtual ~node ()=default
 Default virtual destructor for deriving classes.
 

Private Attributes

const class_label category_
 The category for this node.
 

Detailed Description

A single node in a parse tree for a sentence.

Constructor & Destructor Documentation

meta::parser::node::node ( class_label  cat)

Constructs a new node with the given category.

Parameters
catThe category for the new node

Member Function Documentation

const class_label & meta::parser::node::category ( ) const
Returns
the category for the node
bool meta::parser::node::is_leaf ( ) const
pure virtual
Returns
whether this node is a leaf node
bool meta::parser::node::is_temporary ( ) const
Returns
whether this node is a temporary node inserted during binarization
virtual bool meta::parser::node::equal ( const node other) const
pure virtual
Parameters
otherThe other subtree to compare with
Returns
whether this subtree is equal to the other subtree
virtual std::unique_ptr<node> meta::parser::node::clone ( ) const
pure virtual

Clones the given node.

Returns
a unique_ptr to a copy of this object
template<class Visitor >
std::remove_reference<Visitor>::type::result_type meta::parser::node::accept ( Visitor &&  vtor)
inline

Accepts a visitor.

Parameters
vtorThe visitor to visit each of the nodes in this subtree
Returns
the visitor result for this subtree
template<class Visitor >
std::remove_reference<Visitor>::type::result_type meta::parser::node::accept ( Visitor &&  vtor) const
inline

Accepts a visitor (const version).

Can only accept visitors that do not modify the tree directly.

Parameters
vtorThe visitor to visit each of the nodes in this subtree
Returns
the visitor result for this subtree
template<class Node >
Node& meta::parser::node::as ( )
inline

Casting operation for nodes to derived types.

Node can only be a parser::leaf_node or parser::internal_node, and must be consistent with is_leaf().

Returns
this node cast to the given node type
template<class Node >
std::add_const<Node>::type& meta::parser::node::as ( ) const
inline

Casting operation for nodes to derived types.

Node can only be a parser::leaf_node or parser::internal_node, and must be consistent with is_leaf().

Returns
this node cast to the given node type

The documentation for this class was generated from the following files: