summaryrefslogtreecommitdiffhomepage
path: root/cpp.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-30 18:33:01 +0200
committerRoland Reichwein <mail@reichwein.it>2020-03-30 18:33:01 +0200
commit79fbc8bf495770e4a8b7c66c46acf07f4e47e568 (patch)
tree174c0f3c194013c39a73f6a50ed8866784388c07 /cpp.cpp
parent2eb2383387d16fc919c07e1a6b9211406576b893 (diff)
Speed up compile
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();