-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTree.cpp
More file actions
94 lines (93 loc) · 1.97 KB
/
STree.cpp
File metadata and controls
94 lines (93 loc) · 1.97 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
#define _CRT_SECURE_NO_WARNINGS
#include "STree.h"
#include <iostream>
#include<string.h>
using namespace std;
STree::STree()
{
for (int i = 0; i < MAX_CHILD_NUM; i++)
{
child[i] = NULL;
QLchild[i] = NULL;
}
QLparent = new Quadruples_List;
QLparent->head = NULL;
QLparent->tail = NULL;
begin = NULL;
next = NULL;
True = NULL;
False = NULL;
child_num = 0;
ProNo = -1;
}
STree::STree(const char* str)
{
data=str;
for (int i = 0; i < MAX_CHILD_NUM; i++)
{
child[i] = NULL;
QLchild[i] = NULL;
}
QLparent = new Quadruples_List;
QLparent->head = NULL;
QLparent->tail = NULL;
begin = NULL;
next = NULL;
True = NULL;
False = NULL;
child_num = 0;
ProNo = -1;
}
void STree::setData(const char *str)
{
data=str;
}
void STree::setName(const char *str)
{
strcpy(name, str);
}
const char* STree::getData()
{
return data;
}
char* STree::getName()
{
return name;
}
int STree::getchild_num()
{
return child_num;
}
STree* STree::getChild(int position)
{
return child[position];
}
void STree::Add_Child(STree T, int position)
{
child[position] = new STree;
child[position]->data = T.data;
for (int i = 0; i < MAX_CHILD_NUM; i++)
child[position]->child[i] = NULL;
child_num++;
}
void STree::QuadOut(STree* T)
{
Quadruples* Temp;
cout << setiosflags(ios::left) << setw(16) << "label" << setw(16) << "op" << setw(16) << "arg1" << setw(16)
<< "arg2" << setw(16) << "result" << endl;
Temp = T->QLparent->head;
while (Temp != NULL)
{
if(Temp->label)
{
cout << setiosflags(ios::left) << setw(16)<< Temp->label;
}
else
{
cout<< setiosflags(ios::left) << setw(16)<< " ";
}
cout << setiosflags(ios::left) << setw(16) << Temp->op << setw(16) << Temp->arg1 << setw(16)
<< Temp->arg2 << setw(16) << Temp->result << endl;
Temp = Temp->next;
}
}