blob: e5c62eda3eb49ed46e44b8345c8b09f6e341bce9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#pragma once
#include "minicc.h"
#include <deque>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using BNF = std::unordered_map<std::string, std::vector<std::vector<std::string>>>;
std::unordered_map<std::string, std::unordered_set<std::string>> Reverse(const BNF& bnf); // unused now, remove?
std::unordered_map<std::string, std::unordered_set<std::string>> 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<std::string> getTerminals(const BNF& bnf);
struct PairHash {
size_t operator()(const std::pair<std::string,size_t>& p) const noexcept
{
size_t h0 {std::hash<std::string>{}(p.first)};
size_t h1 {std::hash<size_t >{}(p.second)};
return h0 ^ (h1 << 1);
}
};
std::unordered_set<std::pair<std::string, size_t>, PairHash> getEmptyPositions(const BNF& bnf);
std::unordered_map<std::string, std::unordered_set<std::pair<std::string, index_t>, PairHash>> reversePosFirst(const BNF& bnf); // like reverseFirstPos, but including variant
|