Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
icstp-compiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaoyi Zhao
icstp-compiler
Commits
eac8bcd9
Commit
eac8bcd9
authored
2 years ago
by
zhaochaoyi
Browse files
Options
Downloads
Patches
Plain Diff
Lab2 left func exp stmt, finish add check on Struct and ExtDef, next:Fun test,Exp,CompSt
parent
6fdb6f98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Code/a.txt
+20
-11
20 additions, 11 deletions
Code/a.txt
Code/parser
+0
-0
0 additions, 0 deletions
Code/parser
Code/semantic.c
+12
-3
12 additions, 3 deletions
Code/semantic.c
Test/test1.cmm
+1
-1
1 addition, 1 deletion
Test/test1.cmm
with
33 additions
and
15 deletions
Code/a.txt
+
20
−
11
View file @
eac8bcd9
...
@@ -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
This diff is collapsed.
Click to expand it.
Code/parser
+
0
−
0
View file @
eac8bcd9
No preview for this file type
This diff is collapsed.
Click to expand it.
Code/semantic.c
+
12
−
3
View file @
eac8bcd9
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Test/test1.cmm
+
1
−
1
View file @
eac8bcd9
...
@@ -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)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment