Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compilador
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hm19
compilador
Commits
b518960a
Commit
b518960a
authored
6 months ago
by
hm19
Browse files
Options
Downloads
Patches
Plain Diff
retorno funcao certo
parent
3af03988
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
MEPA
+2
-1
2 additions, 1 deletion
MEPA
compilador
+0
-0
0 additions, 0 deletions
compilador
compilador.tab.c
+16
-16
16 additions, 16 deletions
compilador.tab.c
compilador.y
+8
-8
8 additions, 8 deletions
compilador.y
with
26 additions
and
25 deletions
MEPA
+
2
−
1
View file @
b518960a
...
@@ -41,11 +41,12 @@ R04: NADA
...
@@ -41,11 +41,12 @@ R04: NADA
CRVI 1,-4
CRVI 1,-4
IMPR
IMPR
DMEM 2
DMEM 2
RTPR 1,2
R00: NADA
R00: NADA
AMEM 1
AMEM 1
CRCT 3
CRCT 3
CREN 0,0
CREN 0,0
CHPR R01,
-1
CHPR R01,
0
IMPR
IMPR
CRVL 0,0
CRVL 0,0
IMPR
IMPR
...
...
This diff is collapsed.
Click to expand it.
compilador
+
0
−
0
View file @
b518960a
No preview for this file type
This diff is collapsed.
Click to expand it.
compilador.tab.c
+
16
−
16
View file @
b518960a
...
@@ -563,8 +563,8 @@ static const yytype_int16 yyrline[] =
...
@@ -563,8 +563,8 @@ static const yytype_int16 yyrline[] =
{
{
0
,
47
,
47
,
47
,
63
,
74
,
60
,
93
,
94
,
97
,
0
,
47
,
47
,
47
,
63
,
74
,
60
,
93
,
94
,
97
,
101
,
101
,
102
,
105
,
106
,
110
,
113
,
110
,
121
,
134
,
101
,
101
,
102
,
105
,
106
,
110
,
113
,
110
,
121
,
134
,
143
,
154
,
155
,
159
,
161
,
162
,
167
,
191
,
167
,
2
1
0
,
143
,
154
,
155
,
159
,
161
,
162
,
167
,
191
,
167
,
20
5
,
2
34
,
23
8
,
2
1
0
,
246
,
247
,
245
,
255
,
258
,
259
,
263
,
2
29
,
23
3
,
20
5
,
246
,
247
,
245
,
255
,
258
,
259
,
263
,
262
,
272
,
272
,
280
,
281
,
284
,
294
,
297
,
298
,
299
,
262
,
272
,
272
,
280
,
281
,
284
,
294
,
297
,
298
,
299
,
302
,
303
,
306
,
307
,
308
,
309
,
310
,
311
,
314
,
314
,
302
,
303
,
306
,
307
,
308
,
309
,
310
,
311
,
314
,
314
,
318
,
319
,
322
,
322
,
353
,
353
,
395
,
398
,
402
,
401
,
318
,
319
,
322
,
322
,
353
,
353
,
395
,
398
,
402
,
401
,
...
@@ -1639,21 +1639,16 @@ yyreduce:
...
@@ -1639,21 +1639,16 @@ yyreduce:
char
buffer
[
50
];
char
buffer
[
50
];
desempilha
(
buffer
,
proc
);
desempilha
(
buffer
,
proc
);
l_elem
=
busca
(
buffer
,
ts
);
l_elem
=
busca
(
buffer
,
ts
);
int
n
;
sprintf
(
buffer
,
"RTPR %d,%d"
,
l_elem
->
nivel
,
l_elem
->
info
.
pr
.
quant
);
if
(
l_elem
->
categ
==
PR
)
n
=
l_elem
->
info
.
pr
.
quant
;
else
if
(
l_elem
->
categ
==
FUN
)
n
=
l_elem
->
info
.
pr
.
quant
;
sprintf
(
buffer
,
"RTPR %d,%d"
,
l_elem
->
nivel
,
n
);
geraCodigo
(
NULL
,
buffer
);
geraCodigo
(
NULL
,
buffer
);
desloc
=
retira_vs_pf
(
ts
);
desloc
=
retira_vs_pf
(
ts
);
mostra_ts
(
ts
);
mostra_ts
(
ts
);
}
}
#line 16
53
"compilador.tab.c"
#line 16
48
"compilador.tab.c"
break
;
break
;
case
29
:
case
29
:
#line 2
1
0 "compilador.y"
#line 20
5
"compilador.y"
{
{
// Insere o funcao na tabela de símbolos
// Insere o funcao na tabela de símbolos
info_t
info
;
info_t
info
;
...
@@ -1677,22 +1672,27 @@ yyreduce:
...
@@ -1677,22 +1672,27 @@ yyreduce:
geraCodigo
(
r_func
,
buffer
);
geraCodigo
(
r_func
,
buffer
);
mostra_ts
(
ts
);
mostra_ts
(
ts
);
}
}
#line 16
81
"compilador.tab.c"
#line 16
76
"compilador.tab.c"
break
;
break
;
case
30
:
case
30
:
#line 2
34
"compilador.y"
#line 2
29
"compilador.y"
{
{
num_vars
=
1
;
num_vars
=
1
;
}
}
#line 168
9
"compilador.tab.c"
#line 168
4
"compilador.tab.c"
break
;
break
;
case
31
:
case
31
:
#line 23
8
"compilador.y"
#line 23
3
"compilador.y"
{
{
// Retorna ao nível léxico anterior e mantém o deslocamento atualizado
char
buffer
[
50
];
nivel_lexico
-=
1
;
desempilha
(
buffer
,
proc
);
l_elem
=
busca
(
buffer
,
ts
);
sprintf
(
buffer
,
"RTPR %d,%d"
,
l_elem
->
nivel
,
l_elem
->
info
.
fun
.
quant
);
geraCodigo
(
NULL
,
buffer
);
desloc
=
retira_vs_pf
(
ts
);
mostra_ts
(
ts
);
}
}
#line 1698 "compilador.tab.c"
#line 1698 "compilador.tab.c"
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
compilador.y
+
8
−
8
View file @
b518960a
...
@@ -192,12 +192,7 @@ declaracao_procedimento: PROCEDURE IDENT {
...
@@ -192,12 +192,7 @@ declaracao_procedimento: PROCEDURE IDENT {
char buffer[50];
char buffer[50];
desempilha(buffer,proc);
desempilha(buffer,proc);
l_elem = busca(buffer,ts);
l_elem = busca(buffer,ts);
int n;
sprintf(buffer,"RTPR %d,%d",l_elem->nivel,l_elem->info.pr.quant);
if(l_elem->categ == PR)
n = l_elem->info.pr.quant;
else if (l_elem->categ == FUN)
n = l_elem->info.pr.quant;
sprintf(buffer,"RTPR %d,%d",l_elem->nivel,n);
geraCodigo(NULL,buffer);
geraCodigo(NULL,buffer);
desloc = retira_vs_pf(ts);
desloc = retira_vs_pf(ts);
mostra_ts(ts);
mostra_ts(ts);
...
@@ -236,8 +231,13 @@ declaracao_funcao: FUNCTION IDENT {
...
@@ -236,8 +231,13 @@ declaracao_funcao: FUNCTION IDENT {
} tipo
} tipo
PONTO_E_VIRGULA bloco
PONTO_E_VIRGULA bloco
{
{
// Retorna ao nível léxico anterior e mantém o deslocamento atualizado
char buffer[50];
nivel_lexico -= 1;
desempilha(buffer,proc);
l_elem = busca(buffer,ts);
sprintf(buffer,"RTPR %d,%d",l_elem->nivel,l_elem->info.fun.quant);
geraCodigo(NULL,buffer);
desloc = retira_vs_pf(ts);
mostra_ts(ts);
}
}
PONTO_E_VIRGULA
PONTO_E_VIRGULA
;
;
...
...
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