diff options
Diffstat (limited to 'grammer.cpp')
-rw-r--r-- | grammer.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/grammer.cpp b/grammer.cpp index 9df4703..a54b65d 100644 --- a/grammer.cpp +++ b/grammer.cpp @@ -374,7 +374,7 @@ std::map<std::string, std::string> Compiler::traverse(const std::string& lower, std::deque<std::pair<std::string, std::string>> todo{{lower, ""}}; // node, child while (!todo.empty()) { - auto& [current_node, current_child] = todo.front(); + auto [current_node, current_child] = todo.front(); std::string& current_node2{current_node}; // workaround for lambda capture below (clang 8) todo.pop_front(); @@ -387,11 +387,13 @@ std::map<std::string, std::string> Compiler::traverse(const std::string& lower, visited[current_node] = current_child; - std::for_each(parents.begin(), parents.end(), [&](const auto&x) {todo.emplace_back(x, current_node2);}); + std::for_each(parents.begin(), parents.end(), [&](const auto&x) { + todo.push_back({x, current_node2}); + }); } } } - + return visited; } @@ -413,8 +415,9 @@ std::vector<std::string> Compiler::GetPath(std::string upper, std::string lower) result.push_back(current); current = child; - } else + } else { return {}; + } } return result; } |