diff --git a/MEPA b/MEPA index ef04081993b17c18acbd22b53eb484dc7bac894c..262e92eb980b02c290269fb7d03023b75a135ea6 100644 --- a/MEPA +++ b/MEPA @@ -14,8 +14,7 @@ R00: NADA CRCT 8 ARMZ 0,0 CREN 0,0 - CRCT 2 - SOMA + CRCT 8 CRCT 2 CRCT 3 SOMA diff --git a/compilador.y b/compilador.y index d684230ed5e210bbdd264d1d2f0d3a2be326550b..654f76f294519d935065d1b2983f0b988ffcf52d 100644 --- a/compilador.y +++ b/compilador.y @@ -338,6 +338,7 @@ lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples { num_param++; // Incrementa para cada parâmetro real + val_ou_ref = VLR; } | { char buffer[50]; @@ -349,6 +350,7 @@ lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples { num_param++; // Conta o primeiro parâmetro real + val_ou_ref = VLR; } ; @@ -401,10 +403,16 @@ expressao: expressao IGUAL expressao_simples { ; expressao_simples: expressao_simples MAIS termo { - geraCodigo(NULL, "SOMA"); // Adiciona operação de soma + if (val_ou_ref == REF) + yyerror("Erro: tentativa de EXPRESSAO em passagem por REFERENCIA\n"); + else + geraCodigo(NULL, "SOMA"); // Adiciona operação de soma } | expressao_simples MENOS termo { - geraCodigo(NULL, "SUBT"); // Adiciona operação de subt + if (val_ou_ref == REF) + yyerror("Erro: tentativa de EXPRESSAO em passagem por REFERENCIA\n"); + else + geraCodigo(NULL, "SUBT"); // Adiciona operação de subt } | termo ; @@ -435,7 +443,6 @@ fator: IDENT { sprintf(buffer, "CRVL %d,%d", l_elem->nivel, l_elem->info.vs.desloc); } geraCodigo(NULL, buffer); - val_ou_ref = VLR; } } | NUMERO { diff --git a/teste9.pas b/teste9.pas index 5e3e87b6a6929dbeb627cc92778f31887286931b..96ad0495cf12b4366870d6c70acab9dd991f071d 100644 --- a/teste9.pas +++ b/teste9.pas @@ -8,5 +8,5 @@ program proc1 (input, output); end; begin x := 8; - p(x, 2+3); + p(x+9, 2+3); end. \ No newline at end of file