Skip to content
Snippets Groups Projects
Commit dc1c13f6 authored by Henrique Margotte's avatar Henrique Margotte
Browse files

declara procedimento

parent 635d3103
Branches
No related tags found
No related merge requests found
INPP INPP
AMEM 2 AMEM 1
LEIT
ARMZ 0,1
CRCT 0
ARMZ 0,0
R00: NADA
CRVL 0,0
CRVL 0,1
CMME
DSVF R01
CRVL 0,0
CRCT 2
DIVI
CRCT 2
MULT
CRVL 0,0
CMIG
DSVF R02
CRVL 0,0
IMPR
CRCT 0
IMPR
CRVL 0,0
CRCT 0
CMIG
DSVF R04
CRCT 2
IMPR
DSVS R05
R04: NADA
CRCT 3
IMPR
R05: NADA
DSVS R03
R02: NADA
CRVL 0,0
IMPR
CRCT 1
IMPR
R03: NADA
CRVL 0,0
CRCT 1
SOMA
ARMZ 0,0
DSVS R00 DSVS R00
R01: NADA R01: ENPR 1
AMEM 1
DSVS R02
R02: NADA
CRCT 3
ARMZ 1,1
DMEM 2 DMEM 2
R00: NADA
CRCT 8
ARMZ 0,0
DMEM 0
PARA PARA
No preview for this file type
This diff is collapsed.
This diff is collapsed.
...@@ -54,7 +54,23 @@ programa :{ ...@@ -54,7 +54,23 @@ programa :{
bloco : bloco :
parte_declara_rotulos parte_declara_rotulos
parte_declara_vars parte_declara_vars
{
char r_main[4];
sprintf(r_main, "R%02d", rot_id);
empilha(r_main, rot);
rot_id += 1;
char buffer[50];
strcpy(buffer,"DSVS ");
strcat(buffer,r_main);
geraCodigo(NULL,buffer);
}
parte_declara_subrotinas parte_declara_subrotinas
{
char r_main[4];
desempilha(r_main,rot);
geraCodigo(r_main,"NADA");
}
comando_composto { comando_composto {
retira(desloc,ts); retira(desloc,ts);
...@@ -131,12 +147,31 @@ lista_idents: lista_idents VIRGULA IDENT ...@@ -131,12 +147,31 @@ lista_idents: lista_idents VIRGULA IDENT
; ;
// REGRA 11 // REGRA 11
parte_declara_subrotinas: declaracao_procedimento parte_declara_subrotinas: parte_declara_subrotinas
declaracao_procedimento
|
; ;
// REGRA 12 // REGRA 12
declaracao_procedimento: PROCEDURE IDENT declaracao_procedimento: PROCEDURE IDENT {
| // Insere o procedimento na tabela de símbolos
info_t info;
char r_proc[4];
sprintf(r_proc, "R%02d", rot_id);
rot_id += 1;
info.pr.rot = r_proc;
info.pr.quant = 0;
info.pr.param = NULL;
nivel_lexico += 1;
insere_ts(token, PR, nivel_lexico, info, ts);
char buffer[50];
sprintf(buffer,"ENPR %d",nivel_lexico);
geraCodigo(r_proc,buffer);
//mostra_ts(ts);
}
PONTO_E_VIRGULA bloco
{ nivel_lexico -= 1; }
; ;
......
program proc1 (input, output); program proc1 (input, output);
var x: integer; var x: integer;
procedure p;
var z: integer;
begin
z := 3;
end
begin begin
x := 8; x := 8;
end. 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