From 79fbc8bf495770e4a8b7c66c46acf07f4e47e568 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 30 Mar 2020 18:33:01 +0200 Subject: Speed up compile --- cpp.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index ea40661..27f8570 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -10,7 +10,9 @@ #include #include +#include #include +#include using namespace Gram; @@ -222,13 +224,26 @@ std::vector CPP::analysis(const std::vector& 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& 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(); -- cgit v1.2.3