summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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())