diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-31 12:19:09 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-31 12:19:09 +0200 |
commit | bed46a062c442656b1bc16d965e12405297029d3 (patch) | |
tree | bce809234bf987ebae36ff3d7e89d21bbf99565c | |
parent | 3c8e6cc25e414fed9dbaadef6fed9cc7efaf3068 (diff) |
Remove redundant code
-rw-r--r-- | cppbnf.cpp | 20 |
1 files changed, 1 insertions, 19 deletions
@@ -21,30 +21,12 @@ namespace { return result; } - std::unordered_map<std::string, std::unordered_set<std::string>> reverseBNF(const BNF& bnf) - { - std::unordered_map<std::string, std::unordered_set<std::string>> result; - for (const auto& [symbol, lists] : bnf) { - for (const auto& list : lists) { - for (const auto& i : list) { - auto it = result.find(i); - if (it == result.end()) - result.emplace(i, std::unordered_set<std::string>{symbol}); - else - it->second.insert(symbol); - } - } - } - - return result; - } - size_t numberOfStartSymbols(const BNF& bnf) { // exactly 1 start symbol std::vector<std::string> startSymbols; - auto reverse{ reverseBNF(bnf) }; + auto reverse{ Reverse(bnf) }; for (const auto& [symbol, lists] : bnf) { if (reverse.find(symbol) == reverse.end()) |