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
14486fde
Commit
14486fde
authored
6 months ago
by
viniciusmioto
Browse files
Options
Downloads
Patches
Plain Diff
declaracao de funcao (inicio)
parent
f6c59499
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
MEPA
+0
-19
0 additions, 19 deletions
MEPA
compilador.output
+918
-827
918 additions, 827 deletions
compilador.output
compilador.y
+36
-0
36 additions, 0 deletions
compilador.y
teste10.pas
+11
-0
11 additions, 0 deletions
teste10.pas
teste9.pas
+1
-1
1 addition, 1 deletion
teste9.pas
with
966 additions
and
847 deletions
MEPA
+
0
−
19
View file @
14486fde
...
@@ -2,22 +2,3 @@
...
@@ -2,22 +2,3 @@
AMEM 1
AMEM 1
DSVS R00
DSVS R00
R01: ENPR 1
R01: ENPR 1
AMEM 1
DSVS R02
R02: NADA
CRVI 1,-5
ARMZ 1,0
CRCT 1
ARMI 1,-5
DMEM 1
R00: NADA
CRCT 8
ARMZ 0,0
CREN 0,0
CRCT 8
CRCT 2
CRCT 3
SOMA
CHPR R01,0
DMEM 0
PARA
This diff is collapsed.
Click to expand it.
compilador.output
+
918
−
827
View file @
14486fde
This diff is collapsed.
Click to expand it.
compilador.y
+
36
−
0
View file @
14486fde
...
@@ -155,6 +155,7 @@ lista_idents: lista_idents VIRGULA IDENT
...
@@ -155,6 +155,7 @@ lista_idents: lista_idents VIRGULA IDENT
// REGRA 11
// REGRA 11
parte_declara_subrotinas: parte_declara_subrotinas
parte_declara_subrotinas: parte_declara_subrotinas
declaracao_procedimento
declaracao_procedimento
| declaracao_funcao
|
|
;
;
...
@@ -191,12 +192,47 @@ declaracao_procedimento: PROCEDURE IDENT {
...
@@ -191,12 +192,47 @@ declaracao_procedimento: PROCEDURE IDENT {
PONTO_E_VIRGULA
PONTO_E_VIRGULA
;
;
// REGRA 13
// Regra ajustada para declaração de procedimento
declaracao_funcao: FUNCTION IDENT {
// Insere o funcao na tabela de símbolos
info_t info;
char r_func[4];
sprintf(r_func, "R%02d", rot_id);
rot_id += 1;
strcpy(info.fun.rot,r_func);
info.fun.quant = 0;
info.fun.param = NULL;
info.fun.tipo = NSEI;
// Incrementa o nível léxico
nivel_lexico += 1;
desloc = 0; // Reinicia deslocamento para variáveis locais do novo nível
insere_ts(token, FUN, nivel_lexico, info, ts);
empilha(token,proc);
char buffer[50];
sprintf(buffer,"ENPR %d",nivel_lexico);
geraCodigo(r_func,buffer);
mostra_ts(ts);
}
parametros_ou_nada
PONTO_E_VIRGULA bloco
{
// Retorna ao nível léxico anterior e mantém o deslocamento atualizado
nivel_lexico -= 1;
}
PONTO_E_VIRGULA
;
parametros_ou_nada: ABRE_PARENTESES
parametros_ou_nada: ABRE_PARENTESES
{num_param = 0;}
{num_param = 0;}
paramentros_formais {
paramentros_formais {
char proc_ident[50];
char proc_ident[50];
desempilha(proc_ident,proc);
desempilha(proc_ident,proc);
adiciona_param(proc_ident,num_param,ts);
adiciona_param(proc_ident,num_param,ts);
mostra_ts(ts);
}
}
FECHA_PARENTESES
FECHA_PARENTESES
|
|
...
...
This diff is collapsed.
Click to expand it.
teste10.pas
0 → 100644
+
11
−
0
View file @
14486fde
program
proc1
(
input
,
output
);
var
x
:
integer
;
function
f
(
var
a
:
integer
;
b
:
integer
):
integer
;
var
z
:
integer
;
begin
z
:=
a
;
a
:=
1
;
end
;
begin
x
:=
f
(
x
,
2
+
3
);
end
.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
teste9.pas
+
1
−
1
View file @
14486fde
...
@@ -8,5 +8,5 @@ program proc1 (input, output);
...
@@ -8,5 +8,5 @@ program proc1 (input, output);
end
;
end
;
begin
begin
x
:=
8
;
x
:=
8
;
p
(
x
+
9
,
2
+
3
);
p
(
x
,
2
+
3
);
end
.
end
.
\ No newline at end of file
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