From 8245e24b6fda8308b348a0e180090ada9203acac Mon Sep 17 00:00:00 2001
From: viniciusmioto <vsmioto@gmail.com>
Date: Mon, 2 Dec 2024 21:52:22 -0300
Subject: [PATCH] verifica parametros (constade e referencia)

---
 MEPA         | 4 ++++
 compilador.y | 6 +++++-
 teste9.pas   | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/MEPA b/MEPA
index 9acacb3..ef04081 100644
--- a/MEPA
+++ b/MEPA
@@ -15,6 +15,10 @@ R00: NADA
      ARMZ 0,0
      CREN 0,0
      CRCT 2
+     SOMA
+     CRCT 2
+     CRCT 3
+     SOMA
      CHPR R01,0
      DMEM 0
      PARA
diff --git a/compilador.y b/compilador.y
index c386917..d684230 100644
--- a/compilador.y
+++ b/compilador.y
@@ -441,7 +441,11 @@ fator: IDENT {
 | NUMERO {
     // Empilha constante
     char buffer[50];
-    sprintf(buffer, "CRCT %s", token);
+    if (val_ou_ref == VLR)
+      sprintf(buffer, "CRCT %s", token);
+    else {
+      yyerror("Erro: passagem de constante por REFERENCIA.\n");
+    }
     geraCodigo(NULL, buffer);
 };
 
diff --git a/teste9.pas b/teste9.pas
index 2a56b69..5e3e87b 100644
--- a/teste9.pas
+++ b/teste9.pas
@@ -8,5 +8,5 @@ program proc1 (input, output);
     end;
 begin
     x := 8;
-    p(x, 2);
+    p(x, 2+3);
 end.
\ No newline at end of file
-- 
GitLab