-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstruc.cpp
More file actions
68 lines (67 loc) · 1.74 KB
/
struc.cpp
File metadata and controls
68 lines (67 loc) · 1.74 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
#include<bits/stdc++.h>
#include"head.h"
using namespace std;
extern vector<Word> words;
extern vector<Quadruple> qua_list;
extern vector<vector<Synbl> > sbl;
extern vector<vector<Synbl> > vall;
extern struct Quadruple qua;
extern struct Synbl symbol;
extern int token_i;
extern int t_k; //用来表示算数表达式tk中的k
extern string tk;
extern ofstream fout7;
extern vector<string> struc_symbol; //第一个值是结构体名字,第二个开始是结构体中变量名
int stru()
{
if(words[token_i].value == "struct") {
token_i++;
if(id()) {
if(words[token_i].value == "{") {
token_i++;
stru_v();
if(words[token_i].value == "}") {
token_i++;
if(id()) {
struc_symbol.push_back(words[token_i-1].value);
fout7<<words[token_i-1].value<<endl;
if(words[token_i].value == ";") {
token_i++;
return 1;
}
}
}
}
}
}
return 0;
}
int stru_v()
{
int token_i_tmp = token_i;
if(type()) {
if(id()) {
struc_symbol.push_back(words[token_i-1].value);
fout7<<words[token_i-1].value<<endl;
if(words[token_i].value == ";") {
token_i++;
if(stru_v()) {
return 1;
}
}
else {
token_i = token_i_tmp;
return 0;
}
}
else {
token_i = token_i_tmp;
return 0;
}
}
else {
token_i = token_i_tmp;
return 0;
}
return 0;
}