tipc
A TIP to LLVM compiler
PreOrderIterator.h
Go to the documentation of this file.
1 #pragma once
2 #include "IteratorImpl.h"
3 #include "SyntaxTree.h"
4 #include <stack>
5 
8 class PreOrderIterator : public IteratorImpl {
9 
10 public:
11  explicit PreOrderIterator(SyntaxTree const &tree, bool end);
12 
13  ~PreOrderIterator() override;
14 
15  SyntaxTree operator*() override;
16 
17  void operator++() override;
18 
19  SyntaxTree *operator->() override;
20 
21  bool operator==(const IteratorImpl &rhs) const override;
22 
23  bool operator!=(const IteratorImpl &rhs) const override;
24 
25  IteratorImpl *clone() override;
26 
27  // private:
28  std::stack<SyntaxTree> stack;
29 };
30 
31 #include "IteratorUtils.tpp"
The interface that an iterator should follow.
Definition: IteratorImpl.h:9
SyntaxTree const & tree
Definition: IteratorImpl.h:31
An iterator implementation for a depth-first, pre-order, transversal.
Definition: PreOrderIterator.h:8
PreOrderIterator(SyntaxTree const &tree, bool end)
Definition: PreOrderIterator.cpp:4
SyntaxTree * operator->() override
Definition: PreOrderIterator.cpp:15
~PreOrderIterator() override
SyntaxTree operator*() override
Definition: PreOrderIterator.cpp:13
bool operator!=(const IteratorImpl &rhs) const override
Definition: PreOrderIterator.cpp:21
void operator++() override
Definition: PreOrderIterator.cpp:25
IteratorImpl * clone() override
Definition: PreOrderIterator.cpp:43
bool operator==(const IteratorImpl &rhs) const override
Definition: PreOrderIterator.cpp:17
std::stack< SyntaxTree > stack
Definition: PreOrderIterator.h:28
A convenient interface to the AST nodes.
Definition: SyntaxTree.h:16