From ce77838c4f32b9dc237f0c4b17d1f1e1741254d4 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 26 Oct 2020 15:38:54 +0100 Subject: Added ProgramOpts --- cpp.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index 3b450c2..6e8a28e 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -13,9 +13,12 @@ #include #include #include +#include using namespace Gram; +namespace fs = std::filesystem; + CPP::CPP(){} CPP::~CPP(){} @@ -227,15 +230,27 @@ std::vector CPP::analysis(const std::vector& 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 -- cgit v1.2.3