-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.h
More file actions
112 lines (87 loc) · 1.85 KB
/
Copy pathTreeNode.h
File metadata and controls
112 lines (87 loc) · 1.85 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Created by Freddie on 8/29/2016.
//
#ifndef C_COMPILER_TREENODE_H
#define C_COMPILER_TREENODE_H
#include <stack>
#include "string"
#include "AutomataNode.h"
#include <set>
class TreeNode {
char value;
TreeNode* left;
TreeNode* right;
Automata* automata;
set<TreeNode*> firstPos;
set<TreeNode*> lastPos;
bool nullable;
set<TreeNode*> followPos;
public:
TreeNode(char elem){
value = elem;
left = nullptr;
right = nullptr;
}
void setRight(TreeNode* newRight){
right = newRight;
}
void setLeft(TreeNode* newLeft){
left = newLeft;
}
void setValue(char elem){
value = elem;
}
void setAutomata(Automata* autom){
automata= autom;
}
Automata* getAutomata(){
return automata;
}
TreeNode* getLeft(){
return left;
}
TreeNode* getRight(){
return right;
}
char getValue(){
return value;
}
bool operator<( const TreeNode& other ) const{
return (automata)<other.automata;
}
void setFirstPos(set<TreeNode*> t){
firstPos = t;
}
void setLastPos(set<TreeNode*> t){
lastPos = t;
}
void setFollowPos(set<TreeNode*> t){
followPos=t;
}
void setFirstPos(TreeNode* t){
firstPos.insert(t);
}
void setLastPos(TreeNode* t){
lastPos.insert(t);
}
void setFollowPos(TreeNode* t){
followPos.insert(t);
}
void setNullable(bool bo){
nullable = bo;
}
set<TreeNode*> getFirstPos(){
return firstPos;
}
set<TreeNode*> getLastPos(){
return lastPos;
}
set<TreeNode*> getFollowPos(){
return followPos;
}
bool getNullable(){
return nullable;
}
};
stack<TreeNode*> postfix2Tree(string postfix);
#endif //C_COMPILER_TREENODE_H