summaryrefslogtreecommitdiffhomepage
path: root/cpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp.cpp')
-rw-r--r--cpp.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/cpp.cpp b/cpp.cpp
index 3b450c2..6e8a28e 100644
--- a/cpp.cpp
+++ b/cpp.cpp
@@ -13,9 +13,12 @@
#include <functional>
#include <unordered_set>
#include <unordered_map>
+#include <filesystem>
using namespace Gram;
+namespace fs = std::filesystem;
+
CPP::CPP(){}
CPP::~CPP(){}
@@ -227,15 +230,27 @@ std::vector<Gram::TreeNode> CPP::analysis(const std::vector<Token>& tokens)
namespace {
CPP::map_type map_translation_unit {
- //{"top-level-declaration-seq", [](){}},
- {"top-level-declaration-seq/top-level-declaration/declaration/function-definition", [](){}},
+ {"/translation-unit/top-level-declaration-seq/top-level-declaration/declaration/function-definition", [](){}},
};
} // anonymous namespace
-void CPP::traverse(index_t node_id, map_type& map)
+void CPP::traverse(index_t node_id, map_type& map, fs::path parent_path)
{
- // TODO
+ fs::path current_path{parent_path / m_nodes[node_id].type};
+
+ // execute callbacks
+ auto it{map.find(current_path.generic_string())};
+ if (it != map.end()) {
+ std::cout << "DEBUG: Found " << current_path << std::endl;
+ }
+
+ // recurse tree
+ for (const auto& child_id: m_nodes[node_id].child_ids) {
+ if (ChildIdIsNode(child_id)) {
+ traverse(child_id, map, current_path);
+ }
+ }
}
// Phase 7.c: Translate