ModErn Text Analysis
META Enumerates Textual Applications
parse_tree.h
Go to the documentation of this file.
1 
9 #ifndef META_PARSE_PARSE_TREE_H_
10 #define META_PARSE_PARSE_TREE_H_
11 
12 #include <memory>
13 #include "parser/trees/node.h"
15 
16 namespace meta
17 {
18 namespace parser
19 {
20 
33 {
34  public:
41  parse_tree(std::unique_ptr<node> root);
42 
46  parse_tree(const parse_tree&);
47 
51  parse_tree(parse_tree&&) = default;
52 
57 
61  void swap(parse_tree&);
62 
67 
73  template <class Visitor>
74  typename std::remove_reference<Visitor>::type::result_type
75  visit(Visitor&& vtor)
76  {
77  return root_->accept(vtor);
78  }
79 
85  template <class Visitor>
86  typename std::remove_reference<Visitor>::type::result_type
87  visit(Visitor&& vtor) const
88  {
89  return root_->accept(vtor);
90  }
91 
98  friend std::ostream& operator<<(std::ostream& os, const parse_tree& tree);
99 
104  void pretty_print(std::ostream& os) const;
105 
111  friend bool operator==(const parse_tree& lhs, const parse_tree& rhs);
112 
113  private:
117  std::unique_ptr<node> root_;
118 };
119 }
120 }
121 
122 #endif
std::remove_reference< Visitor >::type::result_type visit(Visitor &&vtor) const
Runs a visitor over the parse tree.
Definition: parse_tree.h:87
friend bool operator==(const parse_tree &lhs, const parse_tree &rhs)
Definition: parse_tree.cpp:104
Represents the parse tree for a sentence.
Definition: parse_tree.h:32
void transform(tree_transformer &)
Transforms the current parse tree by using the given tree_transformer.
Definition: parse_tree.cpp:88
void pretty_print(std::ostream &os) const
Prints a parse tree to a stream.
Definition: parse_tree.cpp:93
parse_tree(std::unique_ptr< node > root)
Creates a new parse tree by taking ownership of a subtree pointed to by the argument.
Definition: parse_tree.cpp:67
std::unique_ptr< node > root_
The root of the parse tree.
Definition: parse_tree.h:117
std::remove_reference< Visitor >::type::result_type visit(Visitor &&vtor)
Runs a visitor over the parse tree.
Definition: parse_tree.h:75
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
Abstract base class for tree transformers.
Definition: tree_transformer.h:25
void swap(parse_tree &)
Swaps this parse tree with the given parse tree.
Definition: parse_tree.cpp:83
friend std::ostream & operator<<(std::ostream &os, const parse_tree &tree)
Prints a parse tree to a stream.
Definition: parse_tree.cpp:98
parse_tree & operator=(parse_tree)
Assignment operator.
Definition: parse_tree.cpp:77