-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsetable.h
51 lines (33 loc) · 996 Bytes
/
parsetable.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef KOMPILER_PARSETABLE_H
#define KOMPILER_PARSETABLE_H
#include <unordered_map>
#include <string>
#include "cfg.h"
#include "parsetable.pb.h"
#define EPS_STR "\\EPS"
class parsetable {
public:
class entry {
public:
enum States {
ERROR, SYNC, PROD
};
States state;
std::vector<std::string> productions;
entry();
entry(States _state);
};
parsetable(cfg);
parsetable();
entry get_entry(std::string nonterm, std::string next_input);
std::string get_starting_symbol_key() const;
bool is_nonterm(std::string symbol);
bool has_sync(std::string symbol);
bool serialize(std::string file_name);
bool deserialize(std::string file_name);
friend std::ostream &operator<<(std::ostream &stream, const parsetable &t);
private:
std::unordered_map<std::string, std::unordered_map<std::string, entry>> table;
std::string starting_symbol_key;
};
#endif //KOMPILER_PARSETABLE_H