summaryrefslogtreecommitdiffhomepage
path: root/cpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp.cpp')
-rw-r--r--cpp.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/cpp.cpp b/cpp.cpp
index ea40661..27f8570 100644
--- a/cpp.cpp
+++ b/cpp.cpp
@@ -10,7 +10,9 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <functional>
#include <unordered_set>
+#include <unordered_map>
using namespace Gram;
@@ -222,13 +224,26 @@ std::vector<Gram::TreeNode> CPP::analysis(const std::vector<Token>& tokens)
return compiler.compile(tokens);
}
+namespace {
+
+ CPP::map_type map_translation_unit {
+ {"top-level-declaration-seq", [](){}}
+ };
+
+} // anonymous namespace
+
+void CPP::traverse(index_t node_id, map_type& map)
+{
+ // TODO
+}
+
// Phase 7.c: Translate
-void CPP::translate(const std::vector<Gram::TreeNode>& tree)
+void CPP::translate()
{
- if (tree.size() == 0)
+ if (m_nodes.size() == 0)
throw std::runtime_error("ICE: Tree is empty");
- //traverse(i, );
+ traverse(0, map_translation_unit);
}
// Phase 8: Instantiate objects
@@ -259,8 +274,8 @@ void CPP::compile(const std::string& code)
concatenate_strings();
auto tokens = tokens_from_pptokens(pp_tokens);
- auto nodes = analysis(tokens);
- translate(nodes);
+ m_nodes = analysis(tokens);
+ translate();
instantiate();