summaryrefslogtreecommitdiffhomepage
path: root/cppbnf.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-31 12:19:09 +0200
committerRoland Reichwein <mail@reichwein.it>2020-03-31 12:19:09 +0200
commitbed46a062c442656b1bc16d965e12405297029d3 (patch)
treebce809234bf987ebae36ff3d7e89d21bbf99565c /cppbnf.cpp
parent3c8e6cc25e414fed9dbaadef6fed9cc7efaf3068 (diff)
Remove redundant code
Diffstat (limited to 'cppbnf.cpp')
-rw-r--r--cppbnf.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/cppbnf.cpp b/cppbnf.cpp
index 4f0b758..d5ffa12 100644
--- a/cppbnf.cpp
+++ b/cppbnf.cpp
@@ -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())