Skip to content
Snippets Groups Projects
Commit eac8bcd9 authored by zhaochaoyi's avatar zhaochaoyi
Browse files

Lab2 left func exp stmt, finish add check on Struct and ExtDef, next:Fun test,Exp,CompSt

parent 6fdb6f98
No related branches found
No related tags found
No related merge requests found
...@@ -24,8 +24,6 @@ type line:1 ...@@ -24,8 +24,6 @@ type line:1
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5
type : 0 BASIC : 0
field finish field finish
--- ---
Symbol Table Insert: s1 deep:1 Symbol Table Insert: s1 deep:1
...@@ -37,8 +35,6 @@ s1 line:7 ...@@ -37,8 +35,6 @@ s1 line:7
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5
type : 0 BASIC : 0
field finish field finish
--- ---
Symbol Table Insert: s2 deep:1 Symbol Table Insert: s2 deep:1
...@@ -50,10 +46,29 @@ s2 line:7 ...@@ -50,10 +46,29 @@ s2 line:7
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5 field finish
---
Symbol Table Insert: s3 deep:1
s3 line:7
type : 2
type line:1
type : 2
a line:3
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4
type : 0 BASIC : 1
field finish field finish
--- ---
Symbol Table remove: s3 1
s3 line:7
type : 2
type line:1
type : 2
a line:3
type : 0 BASIC : 0
b line:4
type : 0 BASIC : 1
---
Symbol Table remove: s2 1 Symbol Table remove: s2 1
s2 line:7 s2 line:7
type : 2 type : 2
...@@ -63,8 +78,6 @@ s2 line:7 ...@@ -63,8 +78,6 @@ s2 line:7
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5
type : 0 BASIC : 0
--- ---
Symbol Table remove: s1 1 Symbol Table remove: s1 1
s1 line:7 s1 line:7
...@@ -75,8 +88,6 @@ s1 line:7 ...@@ -75,8 +88,6 @@ s1 line:7
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5
type : 0 BASIC : 0
--- ---
Symbol Table remove: type 1 Symbol Table remove: type 1
type line:1 type line:1
...@@ -85,5 +96,3 @@ type line:1 ...@@ -85,5 +96,3 @@ type line:1
type : 0 BASIC : 0 type : 0 BASIC : 0
b line:4 b line:4
type : 0 BASIC : 1 type : 0 BASIC : 1
a line:5
type : 0 BASIC : 0
No preview for this file type
...@@ -300,6 +300,7 @@ Dec : VarDec ...@@ -300,6 +300,7 @@ Dec : VarDec
static FieldList * Semantic_Check_DefList(Node_t * cur) { static FieldList * Semantic_Check_DefList(Node_t * cur) {
if(cur == NULL) return NULL; if(cur == NULL) return NULL;
FieldList * ret = Semantic_Check_Def(cur->lchild); FieldList * ret = Semantic_Check_Def(cur->lchild);
if(!ret) return NULL;
FieldList * temp = ret; FieldList * temp = ret;
while (temp->tail) { while (temp->tail) {
temp = temp->tail; temp = temp->tail;
...@@ -317,9 +318,15 @@ static FieldList * Semantic_Check_Def(Node_t * cur) { ...@@ -317,9 +318,15 @@ static FieldList * Semantic_Check_Def(Node_t * cur) {
static FieldList * Semantic_Check_DecList(Node_t * cur,const FieldList * field) { static FieldList * Semantic_Check_DecList(Node_t * cur,const FieldList * field) {
if(cur == NULL) return NULL; if(cur == NULL) return NULL;
FieldList * ret = Semantic_Check_Dec(cur->lchild,field); FieldList * ret = Semantic_Check_Dec(cur->lchild,field);
if(cur->rchild != cur->lchild) if(cur->rchild != cur->lchild) {
ret->tail = Semantic_Check_DecList(cur->rchild,field); if(ret) {
return ret; ret->tail = Semantic_Check_DecList(cur->rchild,field);
} else {
return Semantic_Check_DecList(cur->rchild,field);
}
} else {
return ret;
}
} }
static FieldList * Semantic_Check_Dec(Node_t * cur,const FieldList * field) { static FieldList * Semantic_Check_Dec(Node_t * cur,const FieldList * field) {
...@@ -337,6 +344,8 @@ static FieldList * Semantic_Check_Dec(Node_t * cur,const FieldList * field) { ...@@ -337,6 +344,8 @@ static FieldList * Semantic_Check_Dec(Node_t * cur,const FieldList * field) {
} }
if(!symbol_table->insert(node)) { if(!symbol_table->insert(node)) {
nodeop->delete(node,INFONODE); nodeop->delete(node,INFONODE);
type_ops->field_delete(ret);
return NULL;
} }
return ret; return ret;
} }
......
...@@ -4,8 +4,8 @@ struct type ...@@ -4,8 +4,8 @@ struct type
float b; float b;
int a; int a;
}; };
struct type s1,s2,s3;
struct type s1,s2,s1; struct type s1,s2,s1;
/* /*
Program (1) Program (1)
ExtDefList (1) ExtDefList (1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment