summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/visitor.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/src/ast/visitor.hxx')
-rw-r--r--tiger-compiler/src/ast/visitor.hxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/visitor.hxx b/tiger-compiler/src/ast/visitor.hxx
new file mode 100644
index 0000000..2765f80
--- /dev/null
+++ b/tiger-compiler/src/ast/visitor.hxx
@@ -0,0 +1,36 @@
+/**
+ ** \file ast/visitor.hxx
+ ** \brief Definition of ast::Visitor.
+ */
+
+#pragma once
+
+#include <ast/ast.hh>
+#include <ast/visitor.hh>
+
+namespace ast
+{
+ template <template <typename> class Const> GenVisitor<Const>::~GenVisitor() {}
+
+ template <template <typename> class Const>
+ void GenVisitor<Const>::operator()(const_t<ast::Ast>& e)
+ {
+ e.accept(*this);
+ }
+
+ template <template <typename> class Const>
+ template <class E>
+ void GenVisitor<Const>::operator()(E* e)
+ {
+ e->accept(*this);
+ }
+
+ template <template <typename> class Const>
+ template <typename E>
+ void GenVisitor<Const>::accept(E* e)
+ {
+ if (e)
+ e->accept(*this);
+ }
+
+} // namespace ast