Skip to content
Snippets Groups Projects
Commit b518960a authored by hm19's avatar hm19
Browse files

retorno funcao certo

parent 3af03988
Branches
No related tags found
No related merge requests found
...@@ -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
......
No preview for this file type
...@@ -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, 210, 143, 154, 155, 159, 161, 162, 167, 191, 167, 205,
234, 238, 210, 246, 247, 245, 255, 258, 259, 263, 229, 233, 205, 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 1653 "compilador.tab.c" #line 1648 "compilador.tab.c"
break; break;
case 29: case 29:
#line 210 "compilador.y" #line 205 "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 1681 "compilador.tab.c" #line 1676 "compilador.tab.c"
break; break;
case 30: case 30:
#line 234 "compilador.y" #line 229 "compilador.y"
{ {
num_vars = 1; num_vars = 1;
} }
#line 1689 "compilador.tab.c" #line 1684 "compilador.tab.c"
break; break;
case 31: case 31:
#line 238 "compilador.y" #line 233 "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;
......
...@@ -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
; ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment