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
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
f8d45dd1
Commit
f8d45dd1
authored
7 months ago
by
Henrique Margotte
Browse files
Options
Downloads
Patches
Plain Diff
em processo de paramentros
parent
0cb193d0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
compilador.y
+15
-0
15 additions, 0 deletions
compilador.y
ts/ts.c
+16
-0
16 additions, 0 deletions
ts/ts.c
ts/ts.h
+2
-0
2 additions, 0 deletions
ts/ts.h
with
33 additions
and
0 deletions
compilador.y
+
15
−
0
View file @
f8d45dd1
...
@@ -176,6 +176,7 @@ declaracao_procedimento: PROCEDURE IDENT {
...
@@ -176,6 +176,7 @@ declaracao_procedimento: PROCEDURE IDENT {
geraCodigo(r_proc,buffer);
geraCodigo(r_proc,buffer);
mostra_ts(ts);
mostra_ts(ts);
}
}
parametros_ou_nada
PONTO_E_VIRGULA bloco
PONTO_E_VIRGULA bloco
{
{
// Retorna ao nível léxico anterior e mantém o deslocamento atualizado
// Retorna ao nível léxico anterior e mantém o deslocamento atualizado
...
@@ -183,6 +184,20 @@ declaracao_procedimento: PROCEDURE IDENT {
...
@@ -183,6 +184,20 @@ declaracao_procedimento: PROCEDURE IDENT {
}
}
;
;
parametros_ou_nada: ABRE_PARENTESES paramentros_formais FECHA_PARENTESES
|
;
paramentros_formais: secao_pfs
| paramentros PONTO_E_VIRGULA secao_pfs
;
secao_pfs: lista_id_pf DOIS_PONTOS tipo
parametro: IDENT {
}
;
comando_composto: T_BEGIN comandos T_END
comando_composto: T_BEGIN comandos T_END
;
;
...
...
This diff is collapsed.
Click to expand it.
ts/ts.c
+
16
−
0
View file @
f8d45dd1
...
@@ -82,6 +82,22 @@ void atualiza_tipo(int n, int tipo, ts_t *ts){
...
@@ -82,6 +82,22 @@ void atualiza_tipo(int n, int tipo, ts_t *ts){
}
}
}
}
void
adiciona_param
(
char
*
ident
,
int
n
,
int
tipo
,
int
passagem
,
ts_t
*
ts
){
if
(
ts
==
NULL
||
ts
->
topo
==
NULL
||
n
<=
0
)
return
;
// Add n parameters to ident procedure params
simb_t
*
p
=
busca
(
ident
,
ts
);
if
(
p
==
NULL
||
p
->
categ
!=
PR
)
return
;
p
->
info
.
pr
.
param
=
(
int
**
)
realloc
(
p
->
info
.
pr
.
param
,
(
p
->
info
.
pr
.
quant
+
n
)
*
sizeof
(
int
*
));
for
(
int
i
=
p
->
info
.
pr
.
quant
;
i
<
p
->
info
.
pr
.
quant
+
n
;
i
++
)
{
p
->
info
.
pr
.
param
[
i
]
=
(
int
*
)
malloc
(
2
*
sizeof
(
int
));
p
->
info
.
pr
.
param
[
i
][
0
]
=
tipo
;
p
->
info
.
pr
.
param
[
i
][
1
]
=
passagem
;
}
p
->
info
.
pr
.
quant
+=
n
;
}
void
mostra_ts
(
ts_t
*
ts
)
{
void
mostra_ts
(
ts_t
*
ts
)
{
if
(
ts
==
NULL
||
ts
->
topo
==
NULL
)
{
if
(
ts
==
NULL
||
ts
->
topo
==
NULL
)
{
printf
(
"Tabela de Símbolos está vazia ou não inicializada.
\n
"
);
printf
(
"Tabela de Símbolos está vazia ou não inicializada.
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
ts/ts.h
+
2
−
0
View file @
f8d45dd1
...
@@ -61,6 +61,8 @@ void retira(int n, ts_t *ts);
...
@@ -61,6 +61,8 @@ void retira(int n, ts_t *ts);
void
atualiza_tipo
(
int
n
,
int
tipo
,
ts_t
*
ts
);
void
atualiza_tipo
(
int
n
,
int
tipo
,
ts_t
*
ts
);
void
adiciona_param
(
char
*
ident
,
int
n
,
int
tipo
,
int
passagem
,
ts_t
*
ts
);
void
mostra_ts
(
ts_t
*
ts
);
void
mostra_ts
(
ts_t
*
ts
);
#endif
#endif
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