Skip to content
Snippets Groups Projects
Commit aebda399 authored by viniciusmioto's avatar viniciusmioto
Browse files

chamada de procedimento com parâmetros (falta verificar num_params)

parent 5bffea1e
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,14 @@ R01: ENPR 1 ...@@ -5,11 +5,14 @@ R01: ENPR 1
AMEM 1 AMEM 1
DSVS R02 DSVS R02
R02: NADA R02: NADA
CRVL 1,-6 CRVL 1,-5
ARMZ 1,0 ARMZ 1,0
DMEM 1 DMEM 1
R00: NADA R00: NADA
CRCT 8 CRCT 8
ARMZ 0,0 ARMZ 0,0
CRVL 0,0
CRCT 2
CHPR R01,0
DMEM 0 DMEM 0
PARA PARA
This diff is collapsed.
...@@ -265,18 +265,37 @@ atribuicao: { ...@@ -265,18 +265,37 @@ atribuicao: {
}; };
chamada_procedimento: { chamada_procedimento:
{
if (l_elem == NULL || l_elem->categ != PR) { if (l_elem == NULL || l_elem->categ != PR) {
yyerror("Procedimento não declarado"); yyerror("Procedimento não declarado");
} else { } else {
// Gera código para chamar o procedimento // Gera código para chamar o procedimento
empilha(l_elem->ident, proc);
}
}
lista_parametros
{
char buffer[50]; char buffer[50];
mostra_ts(ts); mostra_ts(ts);
desempilha(buffer, proc);
l_elem = busca(buffer, ts);
sprintf(buffer, "CHPR %s,%d", l_elem->info.pr.rot, nivel_lexico); sprintf(buffer, "CHPR %s,%d", l_elem->info.pr.rot, nivel_lexico);
geraCodigo(NULL, buffer); geraCodigo(NULL, buffer);
} }
;
} lista_parametros: ABRE_PARENTESES
lista_parametros_parenteses
FECHA_PARENTESES
|
;
lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples
| expressao_simples
; ;
leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES
......
program proc1 (input, output);
var x: integer;
procedure p(a, b: integer);
var z: integer;
begin
z := a;
end;
begin
x := 8;
p(x, 2);
end.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment