From 79fbc8bf495770e4a8b7c66c46acf07f4e47e568 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 30 Mar 2020 18:33:01 +0200 Subject: Speed up compile --- bnf.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'bnf.h') diff --git a/bnf.h b/bnf.h index 148b6d1..0430a2c 100644 --- a/bnf.h +++ b/bnf.h @@ -1,17 +1,32 @@ #pragma once +#include "minicc.h" + #include -#include -#include #include +#include +#include #include #include using BNF = std::unordered_map>>; -std::unordered_map> Reverse(BNF bnf); // unused now, remove? -std::unordered_map> reverseFirst(BNF bnf); +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 -- cgit v1.2.3