-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeGenerator.h
52 lines (43 loc) · 1.08 KB
/
TreeGenerator.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
52
//
// Created by Max Wang on 2022/5/11.
//
#include <iostream>
#include <fstream>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <iomanip>
#include <vector>
#include <sstream>
#ifndef LL1_TRY_TREEGENERATOR_H
#define LL1_TRY_TREEGENERATOR_H
using namespace std;
struct TNode{
int layer;
string name;
deque<TNode*> child;
};
class TreeGenerator {
map<pair<string,string>,string>Table;
string prog;
vector<string>T;//终结符号集合
vector<string>NT;//非终结符号集合
string S;//开始符号
map<string,vector<string>>production;//产生式
public:
void dps(TNode * S,stack<string> &Analysis,deque<string> &stream,int layer);
void printSystem();
void printTable();
void setTable(const map<pair<string, string>, string> &table);
void setT(const vector<string> &t);
void setNt(const vector<string> &nt);
void setS(const string &s);
void setProg(const string &prog);
void printTree();
};
#endif //LL1_TRY_TREEGENERATOR_H