-
Notifications
You must be signed in to change notification settings - Fork 0
/
STree.h
61 lines (53 loc) · 1.43 KB
/
STree.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
53
54
55
56
57
58
59
60
61
#ifndef STREE_H
#define STREE_H
#define MAX_CHILD_NUM 6
#define NAME_LENGTH 50
#define LABEL_LENGTH 50
#include <iomanip>
struct Quadruples {
char op[20];
char arg1[NAME_LENGTH];
char arg2[NAME_LENGTH];
char result[NAME_LENGTH];
struct Quadruples* next;
char* label; //该四元式所在行对应的标号
};
struct Quadruples_List {
Quadruples* head;
Quadruples* tail;
};
class Semantic;
class Grammar;
class MainWindow;
class STree{
private:
const char* data;
int child_num;
STree* child[MAX_CHILD_NUM];
//变量名
char name[NAME_LENGTH];
//各种Label
char* True;
char* False;
char* next;
char* begin;
bool flag; //访问标志,区分语法树的遍历是进去还是回来的时候
Quadruples_List* QLparent;
Quadruples_List* QLchild[MAX_CHILD_NUM];
public:
int ProNo;
STree();
STree(const char* str);
void setData(const char *str);
void setName(const char *str);
const char* getData();
char* getName();
int getchild_num();
STree* getChild(int position);
void Add_Child(STree T,int position);
friend Semantic;
friend MainWindow;
friend bool Analyze(STree* &root);
void QuadOut(STree* T);
};
#endif // STREE_H