#pragma once #include "minicc.h" #include #include #include #include #include #include using BNF = std::unordered_map>>; std::unordered_map> Reverse(const BNF& bnf); // unused now, remove? std::unordered_map> reverseFirst(const BNF& bnf); BNF SubBNF(const BNF& bnf, const std::string& top); bool isTerminal(const BNF& bnf, const std::string& symbol); std::unordered_set getTerminals(const BNF& bnf); struct PairHash { size_t operator()(const std::pair& p) const noexcept { size_t h0 {std::hash{}(p.first)}; size_t h1 {std::hash{}(p.second)}; return h0 ^ (h1 << 1); } }; std::unordered_set, PairHash> getEmptyPositions(const BNF& bnf); std::unordered_map, PairHash>> reversePosFirst(const BNF& bnf); // like reverseFirstPos, but including variant