From 403a0487171d79f0dc42835384e1f2d1e9bc5587 Mon Sep 17 00:00:00 2001
From: viniciusmioto <vsmioto@gmail.com>
Date: Tue, 3 Dec 2024 16:57:06 -0300
Subject: [PATCH] organiza apresentacao

---
 .DS_Store                                     |  Bin 6148 -> 8196 bytes
 MEPA => ALTERADO/MEPA                         |    0
 Makefile => ALTERADO/Makefile                 |    0
 USAGE => ALTERADO/USAGE                       |    0
 compilador.h => ALTERADO/compilador.h         |    0
 compilador.l => ALTERADO/compilador.l         |    0
 .../compilador.output                         |    0
 compilador.y => ALTERADO/compilador.y         |    0
 compiladorF.c => ALTERADO/compiladorF.c       |    0
 {stack => ALTERADO/stack}/stack.c             |    0
 {stack => ALTERADO/stack}/stack.h             |    0
 teste1.pas => ALTERADO/teste1.pas             |    0
 teste10.pas => ALTERADO/teste10.pas           |    0
 teste11.pas => ALTERADO/teste11.pas           |    0
 teste2.pas => ALTERADO/teste2.pas             |    0
 teste3.pas => ALTERADO/teste3.pas             |    0
 teste4.pas => ALTERADO/teste4.pas             |    0
 teste5.pas => ALTERADO/teste5.pas             |    0
 teste6.pas => ALTERADO/teste6.pas             |    0
 teste7.pas => ALTERADO/teste7.pas             |    0
 teste8.pas => ALTERADO/teste8.pas             |    0
 teste9.pas => ALTERADO/teste9.pas             |    0
 {ts => ALTERADO/ts}/ts.c                      |    0
 {ts => ALTERADO/ts}/ts.h                      |    0
 ORIGNAL/MEPA                                  |   54 +
 ORIGNAL/Makefile                              |   31 +
 ORIGNAL/USAGE                                 |   19 +
 ORIGNAL/compilador.h                          |   41 +
 ORIGNAL/compilador.l                          |  284 +++
 ORIGNAL/compilador.output                     | 2090 +++++++++++++++++
 ORIGNAL/compilador.y                          |  672 ++++++
 ORIGNAL/compiladorF.c                         |   45 +
 ORIGNAL/stack/stack.c                         |   56 +
 ORIGNAL/stack/stack.h                         |   22 +
 ORIGNAL/teste1.pas                            |    5 +
 ORIGNAL/teste10.pas                           |   12 +
 ORIGNAL/teste11.pas                           |   22 +
 ORIGNAL/teste2.pas                            |    7 +
 ORIGNAL/teste3.pas                            |   11 +
 ORIGNAL/teste4.pas                            |   13 +
 ORIGNAL/teste5.pas                            |   20 +
 ORIGNAL/teste6.pas                            |   11 +
 ORIGNAL/teste7.pas                            |   11 +
 ORIGNAL/teste8.pas                            |   11 +
 ORIGNAL/teste9.pas                            |   12 +
 ORIGNAL/ts/ts.c                               |  360 +++
 ORIGNAL/ts/ts.h                               |   84 +
 47 files changed, 3893 insertions(+)
 rename MEPA => ALTERADO/MEPA (100%)
 rename Makefile => ALTERADO/Makefile (100%)
 rename USAGE => ALTERADO/USAGE (100%)
 rename compilador.h => ALTERADO/compilador.h (100%)
 rename compilador.l => ALTERADO/compilador.l (100%)
 rename compilador.output => ALTERADO/compilador.output (100%)
 rename compilador.y => ALTERADO/compilador.y (100%)
 rename compiladorF.c => ALTERADO/compiladorF.c (100%)
 rename {stack => ALTERADO/stack}/stack.c (100%)
 rename {stack => ALTERADO/stack}/stack.h (100%)
 rename teste1.pas => ALTERADO/teste1.pas (100%)
 rename teste10.pas => ALTERADO/teste10.pas (100%)
 rename teste11.pas => ALTERADO/teste11.pas (100%)
 rename teste2.pas => ALTERADO/teste2.pas (100%)
 rename teste3.pas => ALTERADO/teste3.pas (100%)
 rename teste4.pas => ALTERADO/teste4.pas (100%)
 rename teste5.pas => ALTERADO/teste5.pas (100%)
 rename teste6.pas => ALTERADO/teste6.pas (100%)
 rename teste7.pas => ALTERADO/teste7.pas (100%)
 rename teste8.pas => ALTERADO/teste8.pas (100%)
 rename teste9.pas => ALTERADO/teste9.pas (100%)
 rename {ts => ALTERADO/ts}/ts.c (100%)
 rename {ts => ALTERADO/ts}/ts.h (100%)
 create mode 100644 ORIGNAL/MEPA
 create mode 100644 ORIGNAL/Makefile
 create mode 100644 ORIGNAL/USAGE
 create mode 100644 ORIGNAL/compilador.h
 create mode 100644 ORIGNAL/compilador.l
 create mode 100644 ORIGNAL/compilador.output
 create mode 100644 ORIGNAL/compilador.y
 create mode 100644 ORIGNAL/compiladorF.c
 create mode 100644 ORIGNAL/stack/stack.c
 create mode 100644 ORIGNAL/stack/stack.h
 create mode 100644 ORIGNAL/teste1.pas
 create mode 100644 ORIGNAL/teste10.pas
 create mode 100644 ORIGNAL/teste11.pas
 create mode 100644 ORIGNAL/teste2.pas
 create mode 100644 ORIGNAL/teste3.pas
 create mode 100644 ORIGNAL/teste4.pas
 create mode 100644 ORIGNAL/teste5.pas
 create mode 100644 ORIGNAL/teste6.pas
 create mode 100644 ORIGNAL/teste7.pas
 create mode 100644 ORIGNAL/teste8.pas
 create mode 100644 ORIGNAL/teste9.pas
 create mode 100644 ORIGNAL/ts/ts.c
 create mode 100644 ORIGNAL/ts/ts.h

diff --git a/.DS_Store b/.DS_Store
index f7887da69e8c535abb484648286ed48b845f2b43..a59d25439c2f0f85399d2d611a0b0e5612b01312 100644
GIT binary patch
delta 435
zcmZoMXmOBWU|?W$DortDU;r^W7$CF&_ryZ6iF%5R+#3USGjCSl_`|%Ior7ay0}CVf
z<hyKAo7GqzFx9g&_%j4Ccrv&%_%S##_~fJ;1}Ep|7BC<Hnu^?f7nh`*{3Hej1`h4c
z%$H~Ck2x|hFkq-kAwpF_Mm>ggJg5$0P+&-A$Y&^EsKnwloN9465>vf9)bQMVtnS6s
z099X*f$H$h-aLnyxg@w57#Lg`7zDUC3vzsCp3E=eIoY3wgM*QQ0Te3?o8x)rFarQ~
C)mbS3

delta 108
zcmZp1XfcprU|?W$DortDU=UznVBlbY&@5aN3&ketDKau|4A{-g$UOP3kkn>1fd@<*
xOBfj!vvY6=GBbdI05<~zgDV3A3)jZN@640=WjsN~Ffc)k0-4URIi6<@GXVCv5w8FM

diff --git a/MEPA b/ALTERADO/MEPA
similarity index 100%
rename from MEPA
rename to ALTERADO/MEPA
diff --git a/Makefile b/ALTERADO/Makefile
similarity index 100%
rename from Makefile
rename to ALTERADO/Makefile
diff --git a/USAGE b/ALTERADO/USAGE
similarity index 100%
rename from USAGE
rename to ALTERADO/USAGE
diff --git a/compilador.h b/ALTERADO/compilador.h
similarity index 100%
rename from compilador.h
rename to ALTERADO/compilador.h
diff --git a/compilador.l b/ALTERADO/compilador.l
similarity index 100%
rename from compilador.l
rename to ALTERADO/compilador.l
diff --git a/compilador.output b/ALTERADO/compilador.output
similarity index 100%
rename from compilador.output
rename to ALTERADO/compilador.output
diff --git a/compilador.y b/ALTERADO/compilador.y
similarity index 100%
rename from compilador.y
rename to ALTERADO/compilador.y
diff --git a/compiladorF.c b/ALTERADO/compiladorF.c
similarity index 100%
rename from compiladorF.c
rename to ALTERADO/compiladorF.c
diff --git a/stack/stack.c b/ALTERADO/stack/stack.c
similarity index 100%
rename from stack/stack.c
rename to ALTERADO/stack/stack.c
diff --git a/stack/stack.h b/ALTERADO/stack/stack.h
similarity index 100%
rename from stack/stack.h
rename to ALTERADO/stack/stack.h
diff --git a/teste1.pas b/ALTERADO/teste1.pas
similarity index 100%
rename from teste1.pas
rename to ALTERADO/teste1.pas
diff --git a/teste10.pas b/ALTERADO/teste10.pas
similarity index 100%
rename from teste10.pas
rename to ALTERADO/teste10.pas
diff --git a/teste11.pas b/ALTERADO/teste11.pas
similarity index 100%
rename from teste11.pas
rename to ALTERADO/teste11.pas
diff --git a/teste2.pas b/ALTERADO/teste2.pas
similarity index 100%
rename from teste2.pas
rename to ALTERADO/teste2.pas
diff --git a/teste3.pas b/ALTERADO/teste3.pas
similarity index 100%
rename from teste3.pas
rename to ALTERADO/teste3.pas
diff --git a/teste4.pas b/ALTERADO/teste4.pas
similarity index 100%
rename from teste4.pas
rename to ALTERADO/teste4.pas
diff --git a/teste5.pas b/ALTERADO/teste5.pas
similarity index 100%
rename from teste5.pas
rename to ALTERADO/teste5.pas
diff --git a/teste6.pas b/ALTERADO/teste6.pas
similarity index 100%
rename from teste6.pas
rename to ALTERADO/teste6.pas
diff --git a/teste7.pas b/ALTERADO/teste7.pas
similarity index 100%
rename from teste7.pas
rename to ALTERADO/teste7.pas
diff --git a/teste8.pas b/ALTERADO/teste8.pas
similarity index 100%
rename from teste8.pas
rename to ALTERADO/teste8.pas
diff --git a/teste9.pas b/ALTERADO/teste9.pas
similarity index 100%
rename from teste9.pas
rename to ALTERADO/teste9.pas
diff --git a/ts/ts.c b/ALTERADO/ts/ts.c
similarity index 100%
rename from ts/ts.c
rename to ALTERADO/ts/ts.c
diff --git a/ts/ts.h b/ALTERADO/ts/ts.h
similarity index 100%
rename from ts/ts.h
rename to ALTERADO/ts/ts.h
diff --git a/ORIGNAL/MEPA b/ORIGNAL/MEPA
new file mode 100644
index 0000000..fff6568
--- /dev/null
+++ b/ORIGNAL/MEPA
@@ -0,0 +1,54 @@
+     INPP
+     AMEM 1
+     DSVS R00
+R01: ENPR 1 
+     AMEM 2
+     DSVS R02
+R02: NADA 
+     CRVL 1, -5
+     CRCT 2
+     CMME
+     DSVF R03
+     CRVL 1, -5
+     ARMZ 1, -6
+     CRCT 0
+     ARMI 1, -4
+     DSVS R04
+R03: NADA 
+     AMEM 1
+     CRVL 1, -5
+     CRCT 1
+     SUBT
+     CREN 1, 0
+     CHPR R01, 1
+     AMEM 1
+     CRVL 1, -5
+     CRCT 2
+     SUBT
+     CREN 1, 1
+     CHPR R01, 1
+     SOMA
+     ARMZ 1, -6
+     CRVL 1, 0
+     CRVL 1, 1
+     SOMA
+     CRCT 1
+     SOMA
+     ARMI 1, -4
+R04: NADA 
+     CRVL 1, -5
+     IMPR
+     CRVI 1, -4
+     IMPR
+     DMEM 2
+     RTPR 1, 2
+R00: NADA 
+     AMEM 1
+     CRCT 3
+     CREN 0, 0
+     CHPR R01, 0
+     IMPR
+     CRVL 0, 0
+     IMPR
+     DMEM 1
+     PARA
diff --git a/ORIGNAL/Makefile b/ORIGNAL/Makefile
new file mode 100644
index 0000000..0e97d56
--- /dev/null
+++ b/ORIGNAL/Makefile
@@ -0,0 +1,31 @@
+ # -------------------------------------------------------------------
+ #            Arquivo: Makefile
+ # -------------------------------------------------------------------
+ #              Autor: Bruno Müller Junior
+ #               Data: 08/2007
+ #      Atualizado em: [09/08/2020, 19h:01m]
+ #
+ # -------------------------------------------------------------------
+
+$DEPURA=1
+
+compilador: lex.yy.c compilador.tab.c compilador.o ts/ts.o stack/stack.o compilador.h
+	gcc lex.yy.c compilador.tab.c compilador.o ts/ts.o stack/stack.o -o compilador -ll -ly -lc
+
+lex.yy.c: compilador.l compilador.h
+	flex compilador.l
+
+compilador.tab.c: compilador.y compilador.h
+	bison compilador.y -d -v
+
+compilador.o: compilador.h compiladorF.c
+	gcc -c compiladorF.c -o compilador.o
+
+ts/ts.o: ts/ts.h ts/ts.c
+	gcc -c ts/ts.c -o ts/ts.o
+
+stack/stack.o: stack/stack.h stack/stack.c
+	gcc -c stack/stack.c -o stack/stack.o
+
+clean:
+	rm -f compilador.tab.* lex.yy.c compilador.o ts/ts.o compilador stack/stack.o
diff --git a/ORIGNAL/USAGE b/ORIGNAL/USAGE
new file mode 100644
index 0000000..c06ff7d
--- /dev/null
+++ b/ORIGNAL/USAGE
@@ -0,0 +1,19 @@
+1. Só para gerar código MEPA:
+> make
+
+2. Executar o programa
+> ./compilador teste1.pas
+
+3. Ver código MEPA
+> cat MEPA
+
+
+Para aqueles mais curiosos, verifiquem o arquivo lex.yy.c . Este
+arquivo é a implementação em "C" da autômato gerado pelo analisador
+léxico ao ler o arquivo "compilador.l". De forma análoga,
+"compilador.tab.c" é o autômato a pilha gerado pelo bison ao ler o
+arquivo "compilador.y".
+
+Na segunda parte da disciplina, será mostrado como gerar um autômato a
+pilha (tabela de ações e de desvios) para uma classe de gramáticas
+mais restritas do que esta, porém que segue o mesmo "esquema".
diff --git a/ORIGNAL/compilador.h b/ORIGNAL/compilador.h
new file mode 100644
index 0000000..5e8d4e8
--- /dev/null
+++ b/ORIGNAL/compilador.h
@@ -0,0 +1,41 @@
+/* -------------------------------------------------------------------
+ *            Arquivo: compilador.h
+ * -------------------------------------------------------------------
+ *              Autor: Bruno Muller Junior
+ *               Data: 08/2007
+ *      Atualizado em: [09/08/2020, 19h:01m]
+ *
+ * -------------------------------------------------------------------
+ *
+ * Tipos, protótipos e variáveis globais do compilador (via extern)
+ *
+ * ------------------------------------------------------------------- */
+
+#define TAM_TOKEN 16
+
+typedef enum simbolos {
+  simb_program, simb_var, simb_begin, simb_end,
+  simb_identificador, simb_numero,
+  simb_ponto, simb_virgula, simb_ponto_e_virgula, simb_dois_pontos, simb_read, simb_write,
+  simb_atribuicao, simb_abre_parenteses, simb_fecha_parenteses, simb_label, simb_type, simb_array, simb_procedure, simb_function, simb_goto, simb_if, simb_then, simb_else, simb_while, simb_do, simb_or, simb_div, simb_and, simb_not, simb_igual, simb_diferente, simb_menor_igual, simb_maior_igual, simb_menor, simb_maior, simb_mais, simb_menos, simb_asterisco
+} simbolos;
+
+
+/* -------------------------------------------------------------------
+ * variáveis globais
+ * ------------------------------------------------------------------- */
+
+extern simbolos simbolo, relacao;
+extern char token[TAM_TOKEN];
+extern int nivel_lexico;
+extern int desloc;
+extern int nl;
+
+
+/* -------------------------------------------------------------------
+ * prototipos globais
+ * ------------------------------------------------------------------- */
+
+void geraCodigo (char*, char*);
+int yylex();
+void yyerror(const char *s);
diff --git a/ORIGNAL/compilador.l b/ORIGNAL/compilador.l
new file mode 100644
index 0000000..0629b8c
--- /dev/null
+++ b/ORIGNAL/compilador.l
@@ -0,0 +1,284 @@
+
+/* -------------------------------------------------------------------
+ *            Arquivo: compilador.l
+ * -------------------------------------------------------------------
+ *              Autor: Bruno Muller Junior
+ *               Data: 08/2007
+ *      Atualizado em: [09/08/2020, 19h:01m]
+ *
+ * -------------------------------------------------------------------
+ *
+ * Tipos, protótipos e variáveis globais do compilador (via extern)
+ *
+ * ------------------------------------------------------------------- */
+
+%{
+
+
+#include<stdio.h>
+#include<string.h>
+
+#include "compilador.h"
+#include "compilador.tab.h"
+
+//#define IMPRIME(STR) {};
+#define IMPRIME(STR) printf("%s    # %s \n", STR, token);
+
+int nl = 1;
+
+%}
+
+pulo_linha [\n]
+
+descarte [\t ]+
+
+ident [a-zA-Z][a-zA-Z0-9]*
+
+numero [0-9]+
+
+comentario "(*".*"*)"
+
+%%
+
+{pulo_linha} {nl++;}
+
+{descarte}
+
+{comentario}
+
+program { simbolo  = simb_program;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("program ");
+          return PROGRAM;
+ }
+
+var      { simbolo = simb_var;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("var  ");
+          return VAR;
+ }
+
+begin { simbolo = simb_begin;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("begin ");
+          return T_BEGIN;
+ }
+
+end { simbolo = simb_end;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("end  ");
+          return T_END;
+ }
+
+read { simbolo = simb_read;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("read  ");
+          return READ;
+}
+
+write { simbolo = simb_write;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("write  ");
+          return WRITE;
+}
+
+:= { simbolo = simb_atribuicao;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" atribuicao  ");
+          return ATRIBUICAO;
+ }
+
+\; { simbolo = simb_ponto_e_virgula;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" pt_virgula  ");
+          return PONTO_E_VIRGULA;
+ }
+
+\: { simbolo = simb_dois_pontos;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" dois pontos ");
+          return DOIS_PONTOS;
+ }
+
+\, { simbolo = simb_virgula;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" virgula  ");
+          return VIRGULA;
+ }
+
+
+\. { simbolo = simb_ponto;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" ponto  ");
+          return PONTO;
+    }
+
+\(  { simbolo = simb_abre_parenteses;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" abre_parenteses  ");
+          return ABRE_PARENTESES;
+    }
+
+\)  { simbolo = simb_fecha_parenteses;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" fecha_parenteses ");
+          return FECHA_PARENTESES;
+ }
+
+label { simbolo  = simb_label;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("label ");
+          return LABEL;
+ }
+
+type { simbolo  = simb_type;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("type ");
+          return TYPE;
+ }
+
+array { simbolo  = simb_array;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("array ");
+          return ARRAY;
+ }
+
+procedure { simbolo  = simb_procedure;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("procedure ");
+          return PROCEDURE;
+ }
+
+function { simbolo  = simb_function;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("function ");
+          return FUNCTION;
+ }
+
+goto { simbolo  = simb_goto;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("goto ");
+          return GOTO;
+ }
+
+if { simbolo  = simb_if;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("if ");
+          return IF;
+ }
+
+then { simbolo  = simb_then;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" then ");
+          return THEN;
+ }
+
+else { simbolo  = simb_else;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" else ");
+          return ELSE;
+ }
+
+while { simbolo  = simb_while;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("while ");
+          return WHILE;
+ }
+
+do { simbolo  = simb_do;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" do ");
+          return DO;
+ }
+
+or { simbolo  = simb_or;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" or ");
+          return OR;
+ }
+
+div { simbolo  = simb_div;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" div ");
+          return DIV;
+ }
+
+and { simbolo  = simb_and;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" and ");
+          return AND;
+ }
+
+not { simbolo  = simb_not;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" not ");
+          return NOT;
+ }
+
+\= { simbolo = simb_igual;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" igual  ");
+          return IGUAL;
+    }
+
+\<> { simbolo = simb_diferente;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" diferente  ");
+          return DIFERENTE;
+    }
+
+\<= { simbolo = simb_menor_igual;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" menor_igual  ");
+          return MENOR_IGUAL;
+    }
+
+\>= { simbolo = simb_maior_igual;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" maior_igual  ");
+          return MAIOR_IGUAL;
+    }
+
+\< { simbolo = simb_menor;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" menor  ");
+          return MENOR;
+    }
+
+\> { simbolo = simb_maior;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" maior  ");
+          return MAIOR;
+    }
+
+\+ { simbolo = simb_mais;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" mais  ");
+          return MAIS;
+    }
+
+\- { simbolo = simb_menos;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" menos  ");
+          return MENOS;
+    }
+
+\* { simbolo = simb_asterisco;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" asterisco  ");
+          return ASTERISCO;
+    }
+
+{numero} {  simbolo = simb_numero;
+            strncpy (token, yytext,TAM_TOKEN);
+            IMPRIME(" numero ");
+            return NUMERO;
+    }
+
+{ident} { simbolo = simb_identificador;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME(" ident  ");
+          return IDENT;
+        }
+
+%%
diff --git a/ORIGNAL/compilador.output b/ORIGNAL/compilador.output
new file mode 100644
index 0000000..a8dc1fb
--- /dev/null
+++ b/ORIGNAL/compilador.output
@@ -0,0 +1,2090 @@
+Terminals which are not used
+
+   TYPE
+   ARRAY
+   GOTO
+   OR
+   AND
+   NOT
+
+
+State 79 conflicts: 1 reduce/reduce
+
+
+Grammar
+
+    0 $accept: programa $end
+
+    1 @1: /* empty */
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+
+    3 @2: /* empty */
+
+    4 @3: /* empty */
+
+    5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto
+
+    6 parte_declara_rotulos: LABEL VIRGULA
+    7                      | /* empty */
+
+    8 parte_declara_vars: var
+
+    9 @4: /* empty */
+
+   10 var: @4 VAR declara_vars
+   11    | /* empty */
+
+   12 declara_vars: declara_vars declara_var
+   13             | declara_var
+
+   14 @5: /* empty */
+
+   15 @6: /* empty */
+
+   16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA
+
+   17 tipo: IDENT
+
+   18 lista_id_var: lista_id_var VIRGULA IDENT
+   19             | IDENT
+
+   20 lista_idents: lista_idents VIRGULA IDENT
+   21             | IDENT
+
+   22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento
+   23                         | declaracao_funcao
+   24                         | /* empty */
+
+   25 @7: /* empty */
+
+   26 @8: /* empty */
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA
+
+   28 @9: /* empty */
+
+   29 @10: /* empty */
+
+   30 @11: /* empty */
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+   32 @12: /* empty */
+
+   33 @13: /* empty */
+
+   34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 FECHA_PARENTESES
+   35                   | /* empty */
+
+   36 paramentros_formais: secao_pfs
+   37                    | paramentros_formais PONTO_E_VIRGULA secao_pfs
+
+   38 @14: /* empty */
+
+   39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS tipo
+
+   40 @15: /* empty */
+
+   41 secao_pfs: @15 lista_id_pf DOIS_PONTOS tipo
+
+   42 lista_id_pf: parametro VIRGULA lista_id_pf
+   43            | parametro
+
+   44 parametro: IDENT
+
+   45 comando_composto: T_BEGIN comandos T_END
+
+   46 comandos: comando PONTO_E_VIRGULA comandos
+   47         | comando PONTO_E_VIRGULA
+   48         | /* empty */
+
+   49 comando: numero DOIS_PONTOS comando_sem_rotulo
+   50        | comando_sem_rotulo
+
+   51 comando_sem_rotulo: atribuicao_ou_procedimento
+   52                   | comando_composto
+   53                   | comando_condicional
+   54                   | comando_repetitivo
+   55                   | leitura
+   56                   | escrita
+
+   57 @16: /* empty */
+
+   58 atribuicao_ou_procedimento: IDENT @16 atribuicao_ou_procedimento_token
+
+   59 atribuicao_ou_procedimento_token: atribuicao
+   60                                 | chamada_procedimento
+
+   61 @17: /* empty */
+
+   62 atribuicao: @17 ATRIBUICAO expressao_simples
+
+   63 @18: /* empty */
+
+   64 chamada_procedimento: @18 lista_parametros
+
+   65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES
+   66                 | /* empty */
+
+   67 @19: /* empty */
+
+   68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 expressao_simples
+
+   69 @20: /* empty */
+
+   70 lista_parametros_parenteses: @20 expressao_simples
+
+   71 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES
+
+   72 lista_leituras: lista_leituras VIRGULA simb_leitura
+   73               | simb_leitura
+
+   74 simb_leitura: IDENT
+
+   75 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES
+
+   76 lista_escritas: lista_escritas VIRGULA expressao_simples
+   77               | expressao_simples
+
+   78 expressao: expressao IGUAL expressao_simples
+   79          | expressao DIFERENTE expressao_simples
+   80          | expressao MENOR expressao_simples
+   81          | expressao MENOR_IGUAL expressao_simples
+   82          | expressao MAIOR expressao_simples
+   83          | expressao MAIOR_IGUAL expressao_simples
+   84          | expressao_simples
+
+   85 expressao_simples: expressao_simples MAIS termo
+   86                  | expressao_simples MENOS termo
+   87                  | termo
+
+   88 termo: termo ASTERISCO fator
+   89      | termo DIV fator
+   90      | fator
+
+   91 @21: /* empty */
+
+   92 fator: IDENT @21 chamada_procedimento
+   93      | NUMERO
+   94      | ABRE_PARENTESES expressao FECHA_PARENTESES
+
+   95 numero: NUMERO
+
+   96 @22: /* empty */
+
+   97 @23: /* empty */
+
+   98 comando_repetitivo: @22 WHILE expressao DO @23 comando_sem_rotulo
+
+   99 comando_condicional: if_then cond_else
+
+  100 cond_else: ELSE comando_sem_rotulo
+  101          | /* empty */
+
+  102 @24: /* empty */
+
+  103 if_then: IF expressao @24 THEN comando_sem_rotulo
+
+
+Terminals, with rules where they appear
+
+$end (0) 0
+error (256)
+PROGRAM (258) 2
+ABRE_PARENTESES (259) 2 34 65 71 75 94
+FECHA_PARENTESES (260) 2 34 65 71 75 94
+VIRGULA (261) 6 18 20 42 68 72 76
+PONTO_E_VIRGULA (262) 2 16 27 31 37 46 47
+DOIS_PONTOS (263) 16 31 39 41 49
+PONTO (264) 2
+T_BEGIN (265) 45
+T_END (266) 45
+VAR (267) 10 39
+IDENT (268) 2 17 18 19 20 21 27 31 44 58 74 92
+ATRIBUICAO (269) 62
+LABEL (270) 6
+TYPE (271)
+ARRAY (272)
+PROCEDURE (273) 27
+FUNCTION (274) 31
+GOTO (275)
+IF (276) 103
+THEN (277) 103
+ELSE (278) 100
+WHILE (279) 98
+DO (280) 98
+OR (281)
+DIV (282) 89
+AND (283)
+NOT (284)
+IGUAL (285) 78
+DIFERENTE (286) 79
+MENOR_IGUAL (287) 81
+MAIOR_IGUAL (288) 83
+MENOR (289) 80
+MAIOR (290) 82
+MAIS (291) 85
+MENOS (292) 86
+ASTERISCO (293) 88
+NUMERO (294) 93 95
+READ (295) 71
+WRITE (296) 75
+LOWER_THAN_ELSE (297)
+
+
+Nonterminals, with rules where they appear
+
+$accept (43)
+    on left: 0
+programa (44)
+    on left: 2, on right: 0
+@1 (45)
+    on left: 1, on right: 2
+bloco (46)
+    on left: 5, on right: 2 27 31
+@2 (47)
+    on left: 3, on right: 5
+@3 (48)
+    on left: 4, on right: 5
+parte_declara_rotulos (49)
+    on left: 6 7, on right: 5
+parte_declara_vars (50)
+    on left: 8, on right: 5
+var (51)
+    on left: 10 11, on right: 8
+@4 (52)
+    on left: 9, on right: 10
+declara_vars (53)
+    on left: 12 13, on right: 10 12
+declara_var (54)
+    on left: 16, on right: 12 13
+@5 (55)
+    on left: 14, on right: 16
+@6 (56)
+    on left: 15, on right: 16
+tipo (57)
+    on left: 17, on right: 16 31 39 41
+lista_id_var (58)
+    on left: 18 19, on right: 16 18
+lista_idents (59)
+    on left: 20 21, on right: 2 20
+parte_declara_subrotinas (60)
+    on left: 22 23 24, on right: 5 22
+declaracao_procedimento (61)
+    on left: 27, on right: 22
+@7 (62)
+    on left: 25, on right: 27
+@8 (63)
+    on left: 26, on right: 27
+declaracao_funcao (64)
+    on left: 31, on right: 23
+@9 (65)
+    on left: 28, on right: 31
+@10 (66)
+    on left: 29, on right: 31
+@11 (67)
+    on left: 30, on right: 31
+parametros_ou_nada (68)
+    on left: 34 35, on right: 27 31
+@12 (69)
+    on left: 32, on right: 34
+@13 (70)
+    on left: 33, on right: 34
+paramentros_formais (71)
+    on left: 36 37, on right: 34 37
+secao_pfs (72)
+    on left: 39 41, on right: 36 37
+@14 (73)
+    on left: 38, on right: 39
+@15 (74)
+    on left: 40, on right: 41
+lista_id_pf (75)
+    on left: 42 43, on right: 39 41 42
+parametro (76)
+    on left: 44, on right: 42 43
+comando_composto (77)
+    on left: 45, on right: 5 52
+comandos (78)
+    on left: 46 47 48, on right: 45 46
+comando (79)
+    on left: 49 50, on right: 46 47
+comando_sem_rotulo (80)
+    on left: 51 52 53 54 55 56, on right: 49 50 98 100 103
+atribuicao_ou_procedimento (81)
+    on left: 58, on right: 51
+@16 (82)
+    on left: 57, on right: 58
+atribuicao_ou_procedimento_token (83)
+    on left: 59 60, on right: 58
+atribuicao (84)
+    on left: 62, on right: 59
+@17 (85)
+    on left: 61, on right: 62
+chamada_procedimento (86)
+    on left: 64, on right: 60 92
+@18 (87)
+    on left: 63, on right: 64
+lista_parametros (88)
+    on left: 65 66, on right: 64
+lista_parametros_parenteses (89)
+    on left: 68 70, on right: 65 68
+@19 (90)
+    on left: 67, on right: 68
+@20 (91)
+    on left: 69, on right: 70
+leitura (92)
+    on left: 71, on right: 55
+lista_leituras (93)
+    on left: 72 73, on right: 71 72
+simb_leitura (94)
+    on left: 74, on right: 72 73
+escrita (95)
+    on left: 75, on right: 56
+lista_escritas (96)
+    on left: 76 77, on right: 75 76
+expressao (97)
+    on left: 78 79 80 81 82 83 84, on right: 78 79 80 81 82 83 94 98
+    103
+expressao_simples (98)
+    on left: 85 86 87, on right: 62 68 70 76 77 78 79 80 81 82 83 84
+    85 86
+termo (99)
+    on left: 88 89 90, on right: 85 86 87 88 89
+fator (100)
+    on left: 92 93 94, on right: 88 89 90
+@21 (101)
+    on left: 91, on right: 92
+numero (102)
+    on left: 95, on right: 49
+comando_repetitivo (103)
+    on left: 98, on right: 54
+@22 (104)
+    on left: 96, on right: 98
+@23 (105)
+    on left: 97, on right: 98
+comando_condicional (106)
+    on left: 99, on right: 53
+cond_else (107)
+    on left: 100 101, on right: 99
+if_then (108)
+    on left: 103, on right: 99
+@24 (109)
+    on left: 102, on right: 103
+
+
+state 0
+
+    0 $accept: . programa $end
+
+    $default  reduce using rule 1 (@1)
+
+    programa  go to state 1
+    @1        go to state 2
+
+
+state 1
+
+    0 $accept: programa . $end
+
+    $end  shift, and go to state 3
+
+
+state 2
+
+    2 programa: @1 . PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+
+    PROGRAM  shift, and go to state 4
+
+
+state 3
+
+    0 $accept: programa $end .
+
+    $default  accept
+
+
+state 4
+
+    2 programa: @1 PROGRAM . IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+
+    IDENT  shift, and go to state 5
+
+
+state 5
+
+    2 programa: @1 PROGRAM IDENT . ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+
+    ABRE_PARENTESES  shift, and go to state 6
+
+
+state 6
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES . lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+
+    IDENT  shift, and go to state 7
+
+    lista_idents  go to state 8
+
+
+state 7
+
+   21 lista_idents: IDENT .
+
+    $default  reduce using rule 21 (lista_idents)
+
+
+state 8
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents . FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO
+   20 lista_idents: lista_idents . VIRGULA IDENT
+
+    FECHA_PARENTESES  shift, and go to state 9
+    VIRGULA           shift, and go to state 10
+
+
+state 9
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES . PONTO_E_VIRGULA bloco PONTO
+
+    PONTO_E_VIRGULA  shift, and go to state 11
+
+
+state 10
+
+   20 lista_idents: lista_idents VIRGULA . IDENT
+
+    IDENT  shift, and go to state 12
+
+
+state 11
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA . bloco PONTO
+
+    LABEL  shift, and go to state 13
+
+    $default  reduce using rule 7 (parte_declara_rotulos)
+
+    bloco                  go to state 14
+    parte_declara_rotulos  go to state 15
+
+
+state 12
+
+   20 lista_idents: lista_idents VIRGULA IDENT .
+
+    $default  reduce using rule 20 (lista_idents)
+
+
+state 13
+
+    6 parte_declara_rotulos: LABEL . VIRGULA
+
+    VIRGULA  shift, and go to state 16
+
+
+state 14
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco . PONTO
+
+    PONTO  shift, and go to state 17
+
+
+state 15
+
+    5 bloco: parte_declara_rotulos . parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto
+
+    VAR       reduce using rule 9 (@4)
+    $default  reduce using rule 11 (var)
+
+    parte_declara_vars  go to state 18
+    var                 go to state 19
+    @4                  go to state 20
+
+
+state 16
+
+    6 parte_declara_rotulos: LABEL VIRGULA .
+
+    $default  reduce using rule 6 (parte_declara_rotulos)
+
+
+state 17
+
+    2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO .
+
+    $default  reduce using rule 2 (programa)
+
+
+state 18
+
+    5 bloco: parte_declara_rotulos parte_declara_vars . @2 parte_declara_subrotinas @3 comando_composto
+
+    $default  reduce using rule 3 (@2)
+
+    @2  go to state 21
+
+
+state 19
+
+    8 parte_declara_vars: var .
+
+    $default  reduce using rule 8 (parte_declara_vars)
+
+
+state 20
+
+   10 var: @4 . VAR declara_vars
+
+    VAR  shift, and go to state 22
+
+
+state 21
+
+    5 bloco: parte_declara_rotulos parte_declara_vars @2 . parte_declara_subrotinas @3 comando_composto
+
+    FUNCTION  shift, and go to state 23
+
+    $default  reduce using rule 24 (parte_declara_subrotinas)
+
+    parte_declara_subrotinas  go to state 24
+    declaracao_funcao         go to state 25
+
+
+state 22
+
+   10 var: @4 VAR . declara_vars
+
+    $default  reduce using rule 14 (@5)
+
+    declara_vars  go to state 26
+    declara_var   go to state 27
+    @5            go to state 28
+
+
+state 23
+
+   31 declaracao_funcao: FUNCTION . IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    IDENT  shift, and go to state 29
+
+
+state 24
+
+    5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas . @3 comando_composto
+   22 parte_declara_subrotinas: parte_declara_subrotinas . declaracao_procedimento
+
+    PROCEDURE  shift, and go to state 30
+
+    $default  reduce using rule 4 (@3)
+
+    @3                       go to state 31
+    declaracao_procedimento  go to state 32
+
+
+state 25
+
+   23 parte_declara_subrotinas: declaracao_funcao .
+
+    $default  reduce using rule 23 (parte_declara_subrotinas)
+
+
+state 26
+
+   10 var: @4 VAR declara_vars .
+   12 declara_vars: declara_vars . declara_var
+
+    IDENT     reduce using rule 14 (@5)
+    $default  reduce using rule 10 (var)
+
+    declara_var  go to state 33
+    @5           go to state 28
+
+
+state 27
+
+   13 declara_vars: declara_var .
+
+    $default  reduce using rule 13 (declara_vars)
+
+
+state 28
+
+   16 declara_var: @5 . lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA
+
+    IDENT  shift, and go to state 34
+
+    lista_id_var  go to state 35
+
+
+state 29
+
+   31 declaracao_funcao: FUNCTION IDENT . @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    $default  reduce using rule 28 (@9)
+
+    @9  go to state 36
+
+
+state 30
+
+   27 declaracao_procedimento: PROCEDURE . IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA
+
+    IDENT  shift, and go to state 37
+
+
+state 31
+
+    5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 . comando_composto
+
+    T_BEGIN  shift, and go to state 38
+
+    comando_composto  go to state 39
+
+
+state 32
+
+   22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento .
+
+    $default  reduce using rule 22 (parte_declara_subrotinas)
+
+
+state 33
+
+   12 declara_vars: declara_vars declara_var .
+
+    $default  reduce using rule 12 (declara_vars)
+
+
+state 34
+
+   19 lista_id_var: IDENT .
+
+    $default  reduce using rule 19 (lista_id_var)
+
+
+state 35
+
+   16 declara_var: @5 lista_id_var . DOIS_PONTOS tipo @6 PONTO_E_VIRGULA
+   18 lista_id_var: lista_id_var . VIRGULA IDENT
+
+    VIRGULA      shift, and go to state 40
+    DOIS_PONTOS  shift, and go to state 41
+
+
+state 36
+
+   31 declaracao_funcao: FUNCTION IDENT @9 . parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    ABRE_PARENTESES  shift, and go to state 42
+
+    $default  reduce using rule 35 (parametros_ou_nada)
+
+    parametros_ou_nada  go to state 43
+
+
+state 37
+
+   27 declaracao_procedimento: PROCEDURE IDENT . @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA
+
+    $default  reduce using rule 25 (@7)
+
+    @7  go to state 44
+
+
+state 38
+
+   45 comando_composto: T_BEGIN . comandos T_END
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    NUMERO   shift, and go to state 47
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    WHILE     reduce using rule 96 (@22)
+    $default  reduce using rule 48 (comandos)
+
+    comando_composto            go to state 50
+    comandos                    go to state 51
+    comando                     go to state 52
+    comando_sem_rotulo          go to state 53
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    numero                      go to state 57
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 39
+
+    5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto .
+
+    $default  reduce using rule 5 (bloco)
+
+
+state 40
+
+   18 lista_id_var: lista_id_var VIRGULA . IDENT
+
+    IDENT  shift, and go to state 62
+
+
+state 41
+
+   16 declara_var: @5 lista_id_var DOIS_PONTOS . tipo @6 PONTO_E_VIRGULA
+
+    IDENT  shift, and go to state 63
+
+    tipo  go to state 64
+
+
+state 42
+
+   34 parametros_ou_nada: ABRE_PARENTESES . @12 paramentros_formais @13 FECHA_PARENTESES
+
+    $default  reduce using rule 32 (@12)
+
+    @12  go to state 65
+
+
+state 43
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada . DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    DOIS_PONTOS  shift, and go to state 66
+
+
+state 44
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 . parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA
+
+    ABRE_PARENTESES  shift, and go to state 42
+
+    $default  reduce using rule 35 (parametros_ou_nada)
+
+    parametros_ou_nada  go to state 67
+
+
+state 45
+
+   58 atribuicao_ou_procedimento: IDENT . @16 atribuicao_ou_procedimento_token
+
+    $default  reduce using rule 57 (@16)
+
+    @16  go to state 68
+
+
+state 46
+
+  103 if_then: IF . expressao @24 THEN comando_sem_rotulo
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao          go to state 72
+    expressao_simples  go to state 73
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 47
+
+   95 numero: NUMERO .
+
+    $default  reduce using rule 95 (numero)
+
+
+state 48
+
+   71 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES
+
+    ABRE_PARENTESES  shift, and go to state 76
+
+
+state 49
+
+   75 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES
+
+    ABRE_PARENTESES  shift, and go to state 77
+
+
+state 50
+
+   52 comando_sem_rotulo: comando_composto .
+
+    $default  reduce using rule 52 (comando_sem_rotulo)
+
+
+state 51
+
+   45 comando_composto: T_BEGIN comandos . T_END
+
+    T_END  shift, and go to state 78
+
+
+state 52
+
+   46 comandos: comando . PONTO_E_VIRGULA comandos
+   47         | comando . PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 79
+
+
+state 53
+
+   50 comando: comando_sem_rotulo .
+
+    $default  reduce using rule 50 (comando)
+
+
+state 54
+
+   51 comando_sem_rotulo: atribuicao_ou_procedimento .
+
+    $default  reduce using rule 51 (comando_sem_rotulo)
+
+
+state 55
+
+   55 comando_sem_rotulo: leitura .
+
+    $default  reduce using rule 55 (comando_sem_rotulo)
+
+
+state 56
+
+   56 comando_sem_rotulo: escrita .
+
+    $default  reduce using rule 56 (comando_sem_rotulo)
+
+
+state 57
+
+   49 comando: numero . DOIS_PONTOS comando_sem_rotulo
+
+    DOIS_PONTOS  shift, and go to state 80
+
+
+state 58
+
+   54 comando_sem_rotulo: comando_repetitivo .
+
+    $default  reduce using rule 54 (comando_sem_rotulo)
+
+
+state 59
+
+   98 comando_repetitivo: @22 . WHILE expressao DO @23 comando_sem_rotulo
+
+    WHILE  shift, and go to state 81
+
+
+state 60
+
+   53 comando_sem_rotulo: comando_condicional .
+
+    $default  reduce using rule 53 (comando_sem_rotulo)
+
+
+state 61
+
+   99 comando_condicional: if_then . cond_else
+
+    ELSE  shift, and go to state 82
+
+    $default  reduce using rule 101 (cond_else)
+
+    cond_else  go to state 83
+
+
+state 62
+
+   18 lista_id_var: lista_id_var VIRGULA IDENT .
+
+    $default  reduce using rule 18 (lista_id_var)
+
+
+state 63
+
+   17 tipo: IDENT .
+
+    $default  reduce using rule 17 (tipo)
+
+
+state 64
+
+   16 declara_var: @5 lista_id_var DOIS_PONTOS tipo . @6 PONTO_E_VIRGULA
+
+    $default  reduce using rule 15 (@6)
+
+    @6  go to state 84
+
+
+state 65
+
+   34 parametros_ou_nada: ABRE_PARENTESES @12 . paramentros_formais @13 FECHA_PARENTESES
+
+    VAR  shift, and go to state 85
+
+    $default  reduce using rule 40 (@15)
+
+    paramentros_formais  go to state 86
+    secao_pfs            go to state 87
+    @15                  go to state 88
+
+
+state 66
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS . @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    $default  reduce using rule 29 (@10)
+
+    @10  go to state 89
+
+
+state 67
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada . PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 90
+
+
+state 68
+
+   58 atribuicao_ou_procedimento: IDENT @16 . atribuicao_ou_procedimento_token
+
+    ATRIBUICAO  reduce using rule 61 (@17)
+    $default    reduce using rule 63 (@18)
+
+    atribuicao_ou_procedimento_token  go to state 91
+    atribuicao                        go to state 92
+    @17                               go to state 93
+    chamada_procedimento              go to state 94
+    @18                               go to state 95
+
+
+state 69
+
+   94 fator: ABRE_PARENTESES . expressao FECHA_PARENTESES
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao          go to state 96
+    expressao_simples  go to state 73
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 70
+
+   92 fator: IDENT . @21 chamada_procedimento
+
+    $default  reduce using rule 91 (@21)
+
+    @21  go to state 97
+
+
+state 71
+
+   93 fator: NUMERO .
+
+    $default  reduce using rule 93 (fator)
+
+
+state 72
+
+   78 expressao: expressao . IGUAL expressao_simples
+   79          | expressao . DIFERENTE expressao_simples
+   80          | expressao . MENOR expressao_simples
+   81          | expressao . MENOR_IGUAL expressao_simples
+   82          | expressao . MAIOR expressao_simples
+   83          | expressao . MAIOR_IGUAL expressao_simples
+  103 if_then: IF expressao . @24 THEN comando_sem_rotulo
+
+    IGUAL        shift, and go to state 98
+    DIFERENTE    shift, and go to state 99
+    MENOR_IGUAL  shift, and go to state 100
+    MAIOR_IGUAL  shift, and go to state 101
+    MENOR        shift, and go to state 102
+    MAIOR        shift, and go to state 103
+
+    $default  reduce using rule 102 (@24)
+
+    @24  go to state 104
+
+
+state 73
+
+   84 expressao: expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 84 (expressao)
+
+
+state 74
+
+   87 expressao_simples: termo .
+   88 termo: termo . ASTERISCO fator
+   89      | termo . DIV fator
+
+    DIV        shift, and go to state 107
+    ASTERISCO  shift, and go to state 108
+
+    $default  reduce using rule 87 (expressao_simples)
+
+
+state 75
+
+   90 termo: fator .
+
+    $default  reduce using rule 90 (termo)
+
+
+state 76
+
+   71 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES
+
+    IDENT  shift, and go to state 109
+
+    lista_leituras  go to state 110
+    simb_leitura    go to state 111
+
+
+state 77
+
+   75 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    lista_escritas     go to state 112
+    expressao_simples  go to state 113
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 78
+
+   45 comando_composto: T_BEGIN comandos T_END .
+
+    $default  reduce using rule 45 (comando_composto)
+
+
+state 79
+
+   46 comandos: comando PONTO_E_VIRGULA . comandos
+   47         | comando PONTO_E_VIRGULA .
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    NUMERO   shift, and go to state 47
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    T_END     reduce using rule 47 (comandos)
+    T_END     [reduce using rule 48 (comandos)]
+    WHILE     reduce using rule 96 (@22)
+    $default  reduce using rule 47 (comandos)
+
+    comando_composto            go to state 50
+    comandos                    go to state 114
+    comando                     go to state 52
+    comando_sem_rotulo          go to state 53
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    numero                      go to state 57
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 80
+
+   49 comando: numero DOIS_PONTOS . comando_sem_rotulo
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    $default  reduce using rule 96 (@22)
+
+    comando_composto            go to state 50
+    comando_sem_rotulo          go to state 115
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 81
+
+   98 comando_repetitivo: @22 WHILE . expressao DO @23 comando_sem_rotulo
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao          go to state 116
+    expressao_simples  go to state 73
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 82
+
+  100 cond_else: ELSE . comando_sem_rotulo
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    $default  reduce using rule 96 (@22)
+
+    comando_composto            go to state 50
+    comando_sem_rotulo          go to state 117
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 83
+
+   99 comando_condicional: if_then cond_else .
+
+    $default  reduce using rule 99 (comando_condicional)
+
+
+state 84
+
+   16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 . PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 118
+
+
+state 85
+
+   39 secao_pfs: VAR . @14 lista_id_pf DOIS_PONTOS tipo
+
+    $default  reduce using rule 38 (@14)
+
+    @14  go to state 119
+
+
+state 86
+
+   34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais . @13 FECHA_PARENTESES
+   37 paramentros_formais: paramentros_formais . PONTO_E_VIRGULA secao_pfs
+
+    PONTO_E_VIRGULA  shift, and go to state 120
+
+    $default  reduce using rule 33 (@13)
+
+    @13  go to state 121
+
+
+state 87
+
+   36 paramentros_formais: secao_pfs .
+
+    $default  reduce using rule 36 (paramentros_formais)
+
+
+state 88
+
+   41 secao_pfs: @15 . lista_id_pf DOIS_PONTOS tipo
+
+    IDENT  shift, and go to state 122
+
+    lista_id_pf  go to state 123
+    parametro    go to state 124
+
+
+state 89
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 . tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    IDENT  shift, and go to state 63
+
+    tipo  go to state 125
+
+
+state 90
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA . bloco @8 PONTO_E_VIRGULA
+
+    LABEL  shift, and go to state 13
+
+    $default  reduce using rule 7 (parte_declara_rotulos)
+
+    bloco                  go to state 126
+    parte_declara_rotulos  go to state 15
+
+
+state 91
+
+   58 atribuicao_ou_procedimento: IDENT @16 atribuicao_ou_procedimento_token .
+
+    $default  reduce using rule 58 (atribuicao_ou_procedimento)
+
+
+state 92
+
+   59 atribuicao_ou_procedimento_token: atribuicao .
+
+    $default  reduce using rule 59 (atribuicao_ou_procedimento_token)
+
+
+state 93
+
+   62 atribuicao: @17 . ATRIBUICAO expressao_simples
+
+    ATRIBUICAO  shift, and go to state 127
+
+
+state 94
+
+   60 atribuicao_ou_procedimento_token: chamada_procedimento .
+
+    $default  reduce using rule 60 (atribuicao_ou_procedimento_token)
+
+
+state 95
+
+   64 chamada_procedimento: @18 . lista_parametros
+
+    ABRE_PARENTESES  shift, and go to state 128
+
+    $default  reduce using rule 66 (lista_parametros)
+
+    lista_parametros  go to state 129
+
+
+state 96
+
+   78 expressao: expressao . IGUAL expressao_simples
+   79          | expressao . DIFERENTE expressao_simples
+   80          | expressao . MENOR expressao_simples
+   81          | expressao . MENOR_IGUAL expressao_simples
+   82          | expressao . MAIOR expressao_simples
+   83          | expressao . MAIOR_IGUAL expressao_simples
+   94 fator: ABRE_PARENTESES expressao . FECHA_PARENTESES
+
+    FECHA_PARENTESES  shift, and go to state 130
+    IGUAL             shift, and go to state 98
+    DIFERENTE         shift, and go to state 99
+    MENOR_IGUAL       shift, and go to state 100
+    MAIOR_IGUAL       shift, and go to state 101
+    MENOR             shift, and go to state 102
+    MAIOR             shift, and go to state 103
+
+
+state 97
+
+   92 fator: IDENT @21 . chamada_procedimento
+
+    $default  reduce using rule 63 (@18)
+
+    chamada_procedimento  go to state 131
+    @18                   go to state 95
+
+
+state 98
+
+   78 expressao: expressao IGUAL . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 132
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 99
+
+   79 expressao: expressao DIFERENTE . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 133
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 100
+
+   81 expressao: expressao MENOR_IGUAL . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 134
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 101
+
+   83 expressao: expressao MAIOR_IGUAL . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 135
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 102
+
+   80 expressao: expressao MENOR . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 136
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 103
+
+   82 expressao: expressao MAIOR . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 137
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 104
+
+  103 if_then: IF expressao @24 . THEN comando_sem_rotulo
+
+    THEN  shift, and go to state 138
+
+
+state 105
+
+   85 expressao_simples: expressao_simples MAIS . termo
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    termo  go to state 139
+    fator  go to state 75
+
+
+state 106
+
+   86 expressao_simples: expressao_simples MENOS . termo
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    termo  go to state 140
+    fator  go to state 75
+
+
+state 107
+
+   89 termo: termo DIV . fator
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    fator  go to state 141
+
+
+state 108
+
+   88 termo: termo ASTERISCO . fator
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    fator  go to state 142
+
+
+state 109
+
+   74 simb_leitura: IDENT .
+
+    $default  reduce using rule 74 (simb_leitura)
+
+
+state 110
+
+   71 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES
+   72 lista_leituras: lista_leituras . VIRGULA simb_leitura
+
+    FECHA_PARENTESES  shift, and go to state 143
+    VIRGULA           shift, and go to state 144
+
+
+state 111
+
+   73 lista_leituras: simb_leitura .
+
+    $default  reduce using rule 73 (lista_leituras)
+
+
+state 112
+
+   75 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES
+   76 lista_escritas: lista_escritas . VIRGULA expressao_simples
+
+    FECHA_PARENTESES  shift, and go to state 145
+    VIRGULA           shift, and go to state 146
+
+
+state 113
+
+   77 lista_escritas: expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 77 (lista_escritas)
+
+
+state 114
+
+   46 comandos: comando PONTO_E_VIRGULA comandos .
+
+    $default  reduce using rule 46 (comandos)
+
+
+state 115
+
+   49 comando: numero DOIS_PONTOS comando_sem_rotulo .
+
+    $default  reduce using rule 49 (comando)
+
+
+state 116
+
+   78 expressao: expressao . IGUAL expressao_simples
+   79          | expressao . DIFERENTE expressao_simples
+   80          | expressao . MENOR expressao_simples
+   81          | expressao . MENOR_IGUAL expressao_simples
+   82          | expressao . MAIOR expressao_simples
+   83          | expressao . MAIOR_IGUAL expressao_simples
+   98 comando_repetitivo: @22 WHILE expressao . DO @23 comando_sem_rotulo
+
+    DO           shift, and go to state 147
+    IGUAL        shift, and go to state 98
+    DIFERENTE    shift, and go to state 99
+    MENOR_IGUAL  shift, and go to state 100
+    MAIOR_IGUAL  shift, and go to state 101
+    MENOR        shift, and go to state 102
+    MAIOR        shift, and go to state 103
+
+
+state 117
+
+  100 cond_else: ELSE comando_sem_rotulo .
+
+    $default  reduce using rule 100 (cond_else)
+
+
+state 118
+
+   16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA .
+
+    $default  reduce using rule 16 (declara_var)
+
+
+state 119
+
+   39 secao_pfs: VAR @14 . lista_id_pf DOIS_PONTOS tipo
+
+    IDENT  shift, and go to state 122
+
+    lista_id_pf  go to state 148
+    parametro    go to state 124
+
+
+state 120
+
+   37 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs
+
+    VAR  shift, and go to state 85
+
+    $default  reduce using rule 40 (@15)
+
+    secao_pfs  go to state 149
+    @15        go to state 88
+
+
+state 121
+
+   34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 . FECHA_PARENTESES
+
+    FECHA_PARENTESES  shift, and go to state 150
+
+
+state 122
+
+   44 parametro: IDENT .
+
+    $default  reduce using rule 44 (parametro)
+
+
+state 123
+
+   41 secao_pfs: @15 lista_id_pf . DOIS_PONTOS tipo
+
+    DOIS_PONTOS  shift, and go to state 151
+
+
+state 124
+
+   42 lista_id_pf: parametro . VIRGULA lista_id_pf
+   43            | parametro .
+
+    VIRGULA  shift, and go to state 152
+
+    $default  reduce using rule 43 (lista_id_pf)
+
+
+state 125
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo . PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 153
+
+
+state 126
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco . @8 PONTO_E_VIRGULA
+
+    $default  reduce using rule 26 (@8)
+
+    @8  go to state 154
+
+
+state 127
+
+   62 atribuicao: @17 ATRIBUICAO . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 155
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 128
+
+   65 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES
+
+    $default  reduce using rule 69 (@20)
+
+    lista_parametros_parenteses  go to state 156
+    @20                          go to state 157
+
+
+state 129
+
+   64 chamada_procedimento: @18 lista_parametros .
+
+    $default  reduce using rule 64 (chamada_procedimento)
+
+
+state 130
+
+   94 fator: ABRE_PARENTESES expressao FECHA_PARENTESES .
+
+    $default  reduce using rule 94 (fator)
+
+
+state 131
+
+   92 fator: IDENT @21 chamada_procedimento .
+
+    $default  reduce using rule 92 (fator)
+
+
+state 132
+
+   78 expressao: expressao IGUAL expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 78 (expressao)
+
+
+state 133
+
+   79 expressao: expressao DIFERENTE expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 79 (expressao)
+
+
+state 134
+
+   81 expressao: expressao MENOR_IGUAL expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 81 (expressao)
+
+
+state 135
+
+   83 expressao: expressao MAIOR_IGUAL expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 83 (expressao)
+
+
+state 136
+
+   80 expressao: expressao MENOR expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 80 (expressao)
+
+
+state 137
+
+   82 expressao: expressao MAIOR expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 82 (expressao)
+
+
+state 138
+
+  103 if_then: IF expressao @24 THEN . comando_sem_rotulo
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    $default  reduce using rule 96 (@22)
+
+    comando_composto            go to state 50
+    comando_sem_rotulo          go to state 158
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 139
+
+   85 expressao_simples: expressao_simples MAIS termo .
+   88 termo: termo . ASTERISCO fator
+   89      | termo . DIV fator
+
+    DIV        shift, and go to state 107
+    ASTERISCO  shift, and go to state 108
+
+    $default  reduce using rule 85 (expressao_simples)
+
+
+state 140
+
+   86 expressao_simples: expressao_simples MENOS termo .
+   88 termo: termo . ASTERISCO fator
+   89      | termo . DIV fator
+
+    DIV        shift, and go to state 107
+    ASTERISCO  shift, and go to state 108
+
+    $default  reduce using rule 86 (expressao_simples)
+
+
+state 141
+
+   89 termo: termo DIV fator .
+
+    $default  reduce using rule 89 (termo)
+
+
+state 142
+
+   88 termo: termo ASTERISCO fator .
+
+    $default  reduce using rule 88 (termo)
+
+
+state 143
+
+   71 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES .
+
+    $default  reduce using rule 71 (leitura)
+
+
+state 144
+
+   72 lista_leituras: lista_leituras VIRGULA . simb_leitura
+
+    IDENT  shift, and go to state 109
+
+    simb_leitura  go to state 159
+
+
+state 145
+
+   75 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES .
+
+    $default  reduce using rule 75 (escrita)
+
+
+state 146
+
+   76 lista_escritas: lista_escritas VIRGULA . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 160
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 147
+
+   98 comando_repetitivo: @22 WHILE expressao DO . @23 comando_sem_rotulo
+
+    $default  reduce using rule 97 (@23)
+
+    @23  go to state 161
+
+
+state 148
+
+   39 secao_pfs: VAR @14 lista_id_pf . DOIS_PONTOS tipo
+
+    DOIS_PONTOS  shift, and go to state 162
+
+
+state 149
+
+   37 paramentros_formais: paramentros_formais PONTO_E_VIRGULA secao_pfs .
+
+    $default  reduce using rule 37 (paramentros_formais)
+
+
+state 150
+
+   34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 FECHA_PARENTESES .
+
+    $default  reduce using rule 34 (parametros_ou_nada)
+
+
+state 151
+
+   41 secao_pfs: @15 lista_id_pf DOIS_PONTOS . tipo
+
+    IDENT  shift, and go to state 63
+
+    tipo  go to state 163
+
+
+state 152
+
+   42 lista_id_pf: parametro VIRGULA . lista_id_pf
+
+    IDENT  shift, and go to state 122
+
+    lista_id_pf  go to state 164
+    parametro    go to state 124
+
+
+state 153
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA . bloco @11 PONTO_E_VIRGULA
+
+    LABEL  shift, and go to state 13
+
+    $default  reduce using rule 7 (parte_declara_rotulos)
+
+    bloco                  go to state 165
+    parte_declara_rotulos  go to state 15
+
+
+state 154
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 . PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 166
+
+
+state 155
+
+   62 atribuicao: @17 ATRIBUICAO expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 62 (atribuicao)
+
+
+state 156
+
+   65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES
+   68 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA @19 expressao_simples
+
+    FECHA_PARENTESES  shift, and go to state 167
+    VIRGULA           shift, and go to state 168
+
+
+state 157
+
+   70 lista_parametros_parenteses: @20 . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 169
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 158
+
+  103 if_then: IF expressao @24 THEN comando_sem_rotulo .
+
+    $default  reduce using rule 103 (if_then)
+
+
+state 159
+
+   72 lista_leituras: lista_leituras VIRGULA simb_leitura .
+
+    $default  reduce using rule 72 (lista_leituras)
+
+
+state 160
+
+   76 lista_escritas: lista_escritas VIRGULA expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 76 (lista_escritas)
+
+
+state 161
+
+   98 comando_repetitivo: @22 WHILE expressao DO @23 . comando_sem_rotulo
+
+    T_BEGIN  shift, and go to state 38
+    IDENT    shift, and go to state 45
+    IF       shift, and go to state 46
+    READ     shift, and go to state 48
+    WRITE    shift, and go to state 49
+
+    $default  reduce using rule 96 (@22)
+
+    comando_composto            go to state 50
+    comando_sem_rotulo          go to state 170
+    atribuicao_ou_procedimento  go to state 54
+    leitura                     go to state 55
+    escrita                     go to state 56
+    comando_repetitivo          go to state 58
+    @22                         go to state 59
+    comando_condicional         go to state 60
+    if_then                     go to state 61
+
+
+state 162
+
+   39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS . tipo
+
+    IDENT  shift, and go to state 63
+
+    tipo  go to state 171
+
+
+state 163
+
+   41 secao_pfs: @15 lista_id_pf DOIS_PONTOS tipo .
+
+    $default  reduce using rule 41 (secao_pfs)
+
+
+state 164
+
+   42 lista_id_pf: parametro VIRGULA lista_id_pf .
+
+    $default  reduce using rule 42 (lista_id_pf)
+
+
+state 165
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco . @11 PONTO_E_VIRGULA
+
+    $default  reduce using rule 30 (@11)
+
+    @11  go to state 172
+
+
+state 166
+
+   27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA .
+
+    $default  reduce using rule 27 (declaracao_procedimento)
+
+
+state 167
+
+   65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES .
+
+    $default  reduce using rule 65 (lista_parametros)
+
+
+state 168
+
+   68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . @19 expressao_simples
+
+    $default  reduce using rule 67 (@19)
+
+    @19  go to state 173
+
+
+state 169
+
+   70 lista_parametros_parenteses: @20 expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 70 (lista_parametros_parenteses)
+
+
+state 170
+
+   98 comando_repetitivo: @22 WHILE expressao DO @23 comando_sem_rotulo .
+
+    $default  reduce using rule 98 (comando_repetitivo)
+
+
+state 171
+
+   39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS tipo .
+
+    $default  reduce using rule 39 (secao_pfs)
+
+
+state 172
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 . PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  shift, and go to state 174
+
+
+state 173
+
+   68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 . expressao_simples
+
+    ABRE_PARENTESES  shift, and go to state 69
+    IDENT            shift, and go to state 70
+    NUMERO           shift, and go to state 71
+
+    expressao_simples  go to state 175
+    termo              go to state 74
+    fator              go to state 75
+
+
+state 174
+
+   31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA .
+
+    $default  reduce using rule 31 (declaracao_funcao)
+
+
+state 175
+
+   68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 expressao_simples .
+   85 expressao_simples: expressao_simples . MAIS termo
+   86                  | expressao_simples . MENOS termo
+
+    MAIS   shift, and go to state 105
+    MENOS  shift, and go to state 106
+
+    $default  reduce using rule 68 (lista_parametros_parenteses)
diff --git a/ORIGNAL/compilador.y b/ORIGNAL/compilador.y
new file mode 100644
index 0000000..4e02b27
--- /dev/null
+++ b/ORIGNAL/compilador.y
@@ -0,0 +1,672 @@
+
+// Testar se funciona corretamente o empilhamento de par�metros
+// passados por valor ou por refer�ncia.
+
+
+%{
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include "compilador.h"
+#include "ts/ts.h"
+#include "stack/stack.h"
+
+int num_vars;
+int num_param;
+ts_t *ts;
+int nivel_lexico;
+int desloc;
+int destino_nivel;
+int destino_desloc;
+simb_t *l_elem;
+int rot_id;
+custom_stack_t *rot;
+custom_stack_t *proc;
+
+int val_ou_ref;
+int atr_indireto;
+
+%}
+
+%token PROGRAM ABRE_PARENTESES FECHA_PARENTESES
+%token VIRGULA PONTO_E_VIRGULA DOIS_PONTOS PONTO
+%token T_BEGIN T_END VAR IDENT ATRIBUICAO
+%token LABEL TYPE ARRAY PROCEDURE FUNCTION
+%token GOTO IF THEN ELSE WHILE DO OR DIV
+%token AND NOT IGUAL DIFERENTE MENOR_IGUAL
+%token MAIOR_IGUAL MENOR MAIOR MAIS MENOS
+%token ASTERISCO NUMERO READ WRITE
+
+%nonassoc LOWER_THAN_ELSE
+%nonassoc ELSE
+
+%%
+
+// REGRA 1
+programa    :{
+             geraCodigo (NULL, "INPP");
+             }
+             PROGRAM IDENT
+             ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA
+             bloco PONTO 
+             {
+               geraCodigo (NULL, "PARA");
+             }
+;
+
+// REGRA 2
+bloco       :
+	      parte_declara_rotulos
+         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
+         {
+            char r_main[4];
+            desempilha(r_main,rot);
+            geraCodigo(r_main,"NADA");
+         }
+
+         comando_composto {
+            char buffer[50];
+            sprintf(buffer,"DMEM %d",desloc);
+            desloc = retira_pr_fun(ts);
+            desloc = retira_vs_pf(ts);
+            geraCodigo(NULL,buffer);
+            if (nivel_lexico > 0)
+               nivel_lexico -= 1;
+            mostra_ts(ts);
+         }
+;
+
+
+parte_declara_rotulos: LABEL /*numero*/ VIRGULA /*numero*/
+	    | /*numero*/
+;
+
+parte_declara_vars:  var
+;
+
+
+var         : { } VAR declara_vars
+            |
+;
+
+declara_vars: declara_vars declara_var
+            | declara_var
+;
+
+// Regra ajustada para declarar variáveis
+declara_var : { num_vars = 0; }
+              lista_id_var DOIS_PONTOS
+              tipo
+              { 
+               char buffer[50];
+               sprintf(buffer, "AMEM %d", num_vars);
+               geraCodigo(NULL, buffer);
+              }
+              PONTO_E_VIRGULA
+;
+
+tipo        : IDENT
+               {
+                if (strcmp(token, "integer") == 0) {
+                    atualiza_tipo(num_vars, INTEIRO, ts);
+                } else if (strcmp(token, "boolean") == 0) {
+                    atualiza_tipo(num_vars, BOOLEAN, ts);
+                } else {
+                    yyerror("ERRO: Tipo não reconhecido. Somente 'integer' ou 'boolean' são permitidos.");
+                }
+                mostra_ts(ts); // Mostra a tabela após a inserção
+               }
+;
+
+lista_id_var: lista_id_var VIRGULA IDENT
+              { /* insere �ltima vars na tabela de s�mbolos */ 
+               num_vars += 1;
+               info_t info;
+               info.vs.tipo = NSEI;
+               info.vs.desloc = desloc;
+               insere_ts(token,VS,nivel_lexico,info,ts);
+               desloc += 1;
+              }
+            | IDENT { 
+               num_vars += 1;
+               info_t info;
+               info.vs.tipo = NSEI;
+               info.vs.desloc = desloc;
+               insere_ts(token,VS,nivel_lexico,info,ts);
+               desloc += 1;
+               /* insere vars na tabela de s�mbolos */
+            }
+;
+
+lista_idents: lista_idents VIRGULA IDENT
+            | IDENT
+;
+
+// REGRA 11
+parte_declara_subrotinas: parte_declara_subrotinas
+            declaracao_procedimento 
+            | declaracao_funcao
+            |
+;
+
+// REGRA 12
+// Regra ajustada para declaração de procedimento
+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;
+               strcpy(info.pr.rot,r_proc);
+               info.pr.quant = 0;
+               info.pr.param = NULL;
+
+               // Incrementa o nível léxico
+               nivel_lexico += 1;
+               desloc = 0; // Reinicia deslocamento para variáveis locais do novo nível
+
+               insere_ts(token, PR, nivel_lexico, info, ts);
+               empilha(token,proc);
+
+               char buffer[50];
+               sprintf(buffer,"ENPR %d",nivel_lexico);
+               geraCodigo(r_proc,buffer);
+               mostra_ts(ts);
+            }
+            parametros_ou_nada
+            PONTO_E_VIRGULA bloco
+            {
+               char buffer[50];
+               desempilha(buffer,proc);
+               l_elem = busca(buffer,ts);
+               sprintf(buffer,"RTPR %d, %d",l_elem->nivel,l_elem->info.pr.quant);
+               geraCodigo(NULL,buffer);
+               desloc = retira_vs_pf(ts);
+               mostra_ts(ts);
+            }
+            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
+            DOIS_PONTOS {
+               num_vars = 1;
+            } tipo
+            PONTO_E_VIRGULA bloco
+            { 
+               char buffer[50];
+               desempilha(buffer,proc);
+               l_elem = busca(buffer,ts);
+               sprintf(buffer,"RTPR %d, %d",l_elem->nivel,l_elem->info.fun.quant);
+               geraCodigo(NULL,buffer);
+               desloc = retira_vs_pf(ts);
+               mostra_ts(ts); 
+            }
+            PONTO_E_VIRGULA
+;
+
+parametros_ou_nada: ABRE_PARENTESES
+            {num_param = 0;}
+            paramentros_formais {
+               char proc_ident[50];
+               desempilha(proc_ident,proc);
+               adiciona_param(proc_ident,num_param,ts);
+               empilha(proc_ident,proc);
+               mostra_ts(ts);
+            }
+             FECHA_PARENTESES
+            |
+;
+
+paramentros_formais: secao_pfs
+            | paramentros_formais PONTO_E_VIRGULA secao_pfs
+;
+
+secao_pfs: VAR 
+            {
+               num_vars = 0; 
+               val_ou_ref = REF;
+            }
+            lista_id_pf DOIS_PONTOS tipo
+            { 
+               num_param += num_vars;
+               val_ou_ref = VLR;
+            }
+            |  {
+               num_vars = 0;
+               val_ou_ref = VLR;
+            }
+            lista_id_pf DOIS_PONTOS tipo
+            {num_param += num_vars;}
+;
+
+lista_id_pf: parametro VIRGULA lista_id_pf
+            | parametro;
+;
+
+parametro: IDENT {
+               num_vars += 1;
+               info_t info;
+               info.pf.tipo = NSEI;
+               info.pf.desloc = NSEI;
+               info.pf.passagem = val_ou_ref;
+               insere_ts(token,PF,nivel_lexico,info,ts);
+            }
+;
+
+comando_composto: T_BEGIN comandos T_END
+;
+
+comandos: comando PONTO_E_VIRGULA comandos
+            | comando PONTO_E_VIRGULA
+            |
+;
+
+comando: numero DOIS_PONTOS comando_sem_rotulo
+            | comando_sem_rotulo
+;
+
+comando_sem_rotulo: atribuicao_ou_procedimento
+            | comando_composto
+            | comando_condicional
+            | comando_repetitivo
+            | leitura
+            | escrita
+;
+
+atribuicao_ou_procedimento: IDENT {l_elem = busca(token, ts);}
+            atribuicao_ou_procedimento_token
+;
+
+atribuicao_ou_procedimento_token: atribuicao
+            | chamada_procedimento
+;
+
+atribuicao: {
+    if (l_elem == NULL) {
+        yyerror("ERRO: Variável de destino não declarada");
+    } else {
+         if (l_elem->categ == PF && l_elem->info.pf.passagem == REF)
+            atr_indireto = REF;
+         else atr_indireto = VLR; 
+         destino_nivel = l_elem->nivel;
+         if(l_elem->categ == VS)
+            destino_desloc = l_elem->info.vs.desloc;
+         else if(l_elem->categ == PF)
+            destino_desloc = l_elem->info.pf.desloc;
+         else if(l_elem->categ == FUN)
+            destino_desloc = l_elem->info.fun.desloc;
+         else
+            yyerror("ERRO: Tentativa de atribuir em procedimento");
+
+    }
+} ATRIBUICAO expressao_simples {
+    // Gera código ARMZ para armazenar valor
+    char buffer[50];
+    if (atr_indireto == REF) {
+      sprintf(buffer, "ARMI %d, %d", destino_nivel, destino_desloc);
+    } else {
+      sprintf(buffer, "ARMZ %d, %d", destino_nivel, destino_desloc);
+    }
+    geraCodigo(NULL, buffer);
+};
+
+
+chamada_procedimento: 
+            {
+               if (l_elem == NULL){
+                  yyerror("ERRO: Procedimento não declarado");
+               } else{
+                  // Gera código para chamar o procedimento
+                  empilha(l_elem->ident, proc);
+               }
+               if (l_elem->categ == FUN)
+                  geraCodigo(NULL, "AMEM 1");
+               if (l_elem->categ == PR || l_elem->categ == FUN)
+                  num_param = 0; // Reinicia a contagem de parâmetros reais   
+            }
+
+            lista_parametros
+            
+            { 
+               char buffer[50];
+               mostra_ts(ts);
+               desempilha(buffer, proc);
+               l_elem = busca(buffer, ts);
+
+               if (l_elem->categ == PR || l_elem->categ ==FUN) {
+                  // Verifica se o número de parâmetros reais bate com os formais
+                  char error_msg[100];
+                  if (l_elem->categ == PR && num_param != l_elem->info.pr.quant) {
+                     sprintf(error_msg, "ERRO: número de parâmetros incorreto. Esperado: %d, recebido: %d.",
+                              l_elem->info.pr.quant, num_param);
+                     yyerror(error_msg);
+                  } else if(l_elem->categ == FUN && num_param != l_elem->info.fun.quant){
+                     sprintf(error_msg, "ERRO: número de parâmetros incorreto. Esperado: %d, recebido: %d.",
+                              l_elem->info.fun.quant, num_param);
+                     yyerror(error_msg);
+                  }
+
+                  // Gera o código de chamada do procedimento
+                  
+                  sprintf(buffer, "CHPR %s, %d", l_elem->info.pr.rot, nivel_lexico);
+                  geraCodigo(NULL, buffer);
+               }
+            }
+;
+
+lista_parametros: ABRE_PARENTESES
+               lista_parametros_parenteses
+               FECHA_PARENTESES
+               |
+;
+
+lista_parametros_parenteses: lista_parametros_parenteses VIRGULA 
+               {
+                  char buffer[50];
+                  desempilha(buffer,proc);
+                  l_elem = busca(buffer,ts);
+                  val_ou_ref = l_elem->info.pr.param[num_param][1];
+                  empilha(buffer,proc);
+               }
+               expressao_simples
+               {
+                  num_param++; // Incrementa para cada parâmetro real
+                  val_ou_ref = VLR;
+               }
+               | {
+                  char buffer[50];
+                  desempilha(buffer,proc);
+                  l_elem = busca(buffer,ts);
+                  val_ou_ref = l_elem->info.pr.param[num_param][1];
+                  empilha(buffer,proc);
+               } 
+               expressao_simples
+               {
+                  num_param++; // Conta o primeiro parâmetro real
+                  val_ou_ref = VLR;
+               }
+;
+
+leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES
+;
+
+lista_leituras: lista_leituras VIRGULA simb_leitura
+            | simb_leitura
+;
+
+simb_leitura: IDENT {
+               geraCodigo(NULL, "LEIT");
+               l_elem = busca(token,ts);
+               char buffer[50];
+               sprintf(buffer,"ARMZ %d, %d",l_elem->nivel,l_elem->info.vs.desloc);
+               geraCodigo(NULL,buffer);
+            }
+;
+
+escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES
+;
+
+lista_escritas: lista_escritas VIRGULA expressao_simples {
+               geraCodigo(NULL,"IMPR");
+            }
+            | expressao_simples {
+               geraCodigo(NULL,"IMPR");
+            }
+;
+
+expressao: expressao IGUAL expressao_simples {
+            geraCodigo(NULL, "CMIG"); // Adiciona operação de cmig
+         }
+         | expressao DIFERENTE expressao_simples{
+            geraCodigo(NULL, "CMDG"); // Adiciona operação de cmdg
+         }
+         | expressao MENOR expressao_simples {
+            geraCodigo(NULL, "CMME"); // Adiciona operação de cmme
+         }
+         | expressao MENOR_IGUAL expressao_simples {
+            geraCodigo(NULL, "CMEG"); // Adiciona operação de cmeg
+         }
+         | expressao MAIOR expressao_simples {
+            geraCodigo(NULL, "CMMA"); // Adiciona operação de cmma
+         }
+         | expressao MAIOR_IGUAL expressao_simples {
+            geraCodigo(NULL, "CMAG"); // Adiciona operação de cmag
+         }
+         | expressao_simples
+;
+
+expressao_simples: expressao_simples MAIS termo {
+               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 {
+               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
+;
+
+termo: termo ASTERISCO fator {
+               geraCodigo(NULL, "MULT"); // Adiciona operação de mult
+            }
+            | termo DIV fator {
+               geraCodigo(NULL, "DIVI"); // Adiciona operação de divi
+            }
+            | fator
+;
+
+fator: IDENT {
+    // Carrega variável
+    l_elem = busca(token, ts);
+    empilha(token, proc);
+   }
+   chamada_procedimento 
+   {
+      char buffer[50];
+      desempilha(buffer, proc);
+      l_elem = busca(buffer, ts);
+      if (l_elem == NULL) {
+         yyerror("ERRO: Variável não declarada");
+      } else {
+         if (val_ou_ref == REF) {
+               if (l_elem->categ == VS){
+                  sprintf(buffer, "CREN %d, %d", l_elem->nivel, l_elem->info.vs.desloc);
+                  geraCodigo(NULL, buffer);
+               }
+               else if (l_elem->categ == PF){
+                  sprintf(buffer, "CREN %d, %d", l_elem->nivel, l_elem->info.pf.desloc);
+                  geraCodigo(NULL, buffer);
+               }
+               else
+                  yyerror("ERRO: Tentativa de passagem de referencia de procedimento ou funcao");
+               
+         } 
+         else if (l_elem->categ == PF && l_elem->info.pf.passagem == REF) {
+               sprintf(buffer, "CRVI %d, %d", l_elem->nivel, l_elem->info.pf.desloc);
+               geraCodigo(NULL, buffer);
+         }        
+         else {
+               if (l_elem->categ == VS) {
+                  sprintf(buffer, "CRVL %d, %d", l_elem->nivel, l_elem->info.vs.desloc);
+                  geraCodigo(NULL, buffer);
+               }
+               else if (l_elem->categ == PF){
+                  sprintf(buffer, "CRVL %d, %d", l_elem->nivel, l_elem->info.pf.desloc);
+                  geraCodigo(NULL, buffer);
+               }
+         }
+      }
+   }
+| NUMERO {
+    // Empilha constante
+    char buffer[50];
+    if (val_ou_ref == VLR)
+      sprintf(buffer, "CRCT %s", token);
+    else {
+      yyerror("ERRO: passagem de constante por REFERENCIA.\n");
+    }
+    geraCodigo(NULL, buffer);
+}
+| ABRE_PARENTESES expressao FECHA_PARENTESES
+;
+
+numero: NUMERO;
+
+comando_repetitivo: {
+               char r_ini[4];
+               sprintf(r_ini, "R%02d", rot_id);
+               empilha(r_ini, rot);
+               rot_id += 1;
+               geraCodigo(r_ini,"NADA");
+            }
+            WHILE expressao DO {
+               char r_fim[4];
+               sprintf(r_fim, "R%02d", rot_id);
+               empilha(r_fim, rot);
+               rot_id += 1;
+               char buffer[50];
+               strcpy(buffer, "DSVF ");
+               strcat(buffer,r_fim);
+               geraCodigo(NULL,buffer);
+            }
+            comando_sem_rotulo {
+               char r_ini[4];
+               char r_fim[4];
+
+               desempilha(r_fim,rot);
+               desempilha(r_ini,rot);
+
+               char buffer[50];
+               strcpy(buffer,"DSVS ");
+               strcat(buffer,r_ini);
+               geraCodigo(NULL,buffer);
+
+               geraCodigo(r_fim,"NADA");
+            }
+;
+
+comando_condicional: if_then cond_else {
+               char r_fim[4];
+               desempilha(r_fim,rot);
+               geraCodigo(r_fim,"NADA");
+            }
+;
+
+cond_else: ELSE
+            comando_sem_rotulo
+            | %prec LOWER_THAN_ELSE
+;
+
+if_then: IF expressao {
+               char r_else[4];
+               sprintf(r_else,"R%02d",rot_id);
+               empilha(r_else,rot);
+               rot_id += 1;
+               char buffer[50];
+               strcpy(buffer, "DSVF ");
+               strcat(buffer,r_else);
+               geraCodigo(NULL,buffer);
+               
+               char r_fim[4];
+               sprintf(r_fim, "R%02d", rot_id);
+               empilha(r_fim, rot);
+               rot_id += 1;
+            }
+            THEN comando_sem_rotulo {
+               char r_fim[4];
+               desempilha(r_fim,rot);
+               char r_else[4];
+               desempilha(r_else,rot);
+               
+               empilha(r_fim,rot);
+               char buffer[50];
+               strcpy(buffer, "DSVS ");
+               strcat(buffer,r_fim);
+               geraCodigo(NULL,buffer);
+
+               geraCodigo(r_else,"NADA");
+            }
+;
+
+
+%%
+
+int main (int argc, char** argv) {
+   FILE* fp;
+   extern FILE* yyin;
+
+   if (argc<2 || argc>2) {
+         printf("usage compilador <arq>a %d\n", argc);
+         return(-1);
+      }
+
+   fp=fopen (argv[1], "r");
+   if (fp == NULL) {
+      printf("usage compilador <arq>b\n");
+      return(-1);
+   }
+
+
+/* -------------------------------------------------------------------
+ *  Inicia a Tabela de S�mbolos
+ * ------------------------------------------------------------------- */
+   ts = (ts_t *)malloc(sizeof(ts_t));
+   inicializa_ts(ts);
+   nivel_lexico = 0;
+   desloc = 0;
+
+   // Inicializa Rotulos
+   rot = (custom_stack_t *)malloc(sizeof(custom_stack_t));
+   inicializa_stack(rot);
+   rot_id = 0;
+
+   proc = (custom_stack_t *)malloc(sizeof(custom_stack_t));
+   inicializa_stack(proc);
+
+   yyin=fp;
+   yyparse();
+
+   return 0;
+}
diff --git a/ORIGNAL/compiladorF.c b/ORIGNAL/compiladorF.c
new file mode 100644
index 0000000..28df1b9
--- /dev/null
+++ b/ORIGNAL/compiladorF.c
@@ -0,0 +1,45 @@
+
+/* -------------------------------------------------------------------
+ *            Aquivo: compilador.c
+ * -------------------------------------------------------------------
+ *              Autor: Bruno Muller Junior
+ *               Data: 08/2007
+ *      Atualizado em: [09/08/2020, 19h:01m]
+ *
+ * -------------------------------------------------------------------
+ *
+ * Funções auxiliares ao compilador
+ *
+ * ------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "compilador.h"
+
+
+/* -------------------------------------------------------------------
+ *  variáveis globais
+ * ------------------------------------------------------------------- */
+
+simbolos simbolo, relacao;
+char token[TAM_TOKEN];
+
+FILE* fp=NULL;
+void geraCodigo (char* rot, char* comando) {
+
+  if (fp == NULL) {
+    fp = fopen ("MEPA", "w");
+  }
+
+  if ( rot == NULL ) {
+    fprintf(fp, "     %s\n", comando); fflush(fp);
+  } else {
+    fprintf(fp, "%s: %s \n", rot, comando); fflush(fp);
+  }
+}
+
+int imprimeErro ( char* erro ) {
+  fprintf (stderr, "Erro na linha %d - %s\n", nl, erro);
+  exit(-1);
+}
diff --git a/ORIGNAL/stack/stack.c b/ORIGNAL/stack/stack.c
new file mode 100644
index 0000000..7a4ca08
--- /dev/null
+++ b/ORIGNAL/stack/stack.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "stack.h" 
+
+void inicializa_stack(custom_stack_t *stack) {
+    stack->topo = NULL;
+    stack->tam = 0;
+}
+
+void empilha(char *item, custom_stack_t *stack) {
+    if (stack == NULL) {
+        return;
+    }
+
+    item_t *new = (item_t *)malloc(sizeof(item_t));
+    new->item = (char *)malloc((strlen(item) + 1) * sizeof(char));
+    strcpy(new->item, item);
+
+    new->prox = stack->topo;
+    stack->topo = new;
+    stack->tam += 1;
+}
+
+void desempilha(char *item, custom_stack_t *stack) {
+    if (stack == NULL || stack->topo == NULL) {
+        return;
+    }
+
+    item_t *p = stack->topo;
+    stack->topo = p->prox;
+    stack->tam -= 1;
+
+    strcpy(item, p->item);
+    free(p->item);
+    free(p);
+}
+
+void mostra_stack(custom_stack_t *stack) {
+    if (stack == NULL || stack->topo == NULL) {
+        printf("Pilha está vazia ou não inicializada.\n");
+        return;
+    }
+
+    printf("\nPilha:\n");
+    printf("----------------------------------------------------------------------------------\n");
+    printf("| %-10s |\n", "Item");
+    printf("----------------------------------------------------------------------------------\n");
+
+    item_t *p = stack->topo;
+    while (p != NULL) {
+        printf("| %-10s |\n", p->item);
+        p = p->prox;
+    }
+    printf("----------------------------------------------------------------------------------\n");
+}
\ No newline at end of file
diff --git a/ORIGNAL/stack/stack.h b/ORIGNAL/stack/stack.h
new file mode 100644
index 0000000..56ec259
--- /dev/null
+++ b/ORIGNAL/stack/stack.h
@@ -0,0 +1,22 @@
+#ifndef __STACK__
+#define __STACK__
+
+typedef struct item_t {
+    char *item;
+    struct item_t *prox;
+} item_t;
+
+typedef struct stack_t {
+    item_t *topo;
+    int tam;
+} custom_stack_t;
+
+void inicializa_stack(custom_stack_t *stack);
+
+void empilha(char *item, custom_stack_t *stack);
+
+void desempilha(char *item, custom_stack_t *stack);
+
+void mostra_stack(custom_stack_t *stack);
+
+#endif
diff --git a/ORIGNAL/teste1.pas b/ORIGNAL/teste1.pas
new file mode 100644
index 0000000..2d79c2b
--- /dev/null
+++ b/ORIGNAL/teste1.pas
@@ -0,0 +1,5 @@
+program exemplo75 (input, output);
+var m,n :  integer;
+begin    
+end.
+
diff --git a/ORIGNAL/teste10.pas b/ORIGNAL/teste10.pas
new file mode 100644
index 0000000..3c1b11b
--- /dev/null
+++ b/ORIGNAL/teste10.pas
@@ -0,0 +1,12 @@
+program proc1 (input, output);
+    var x: integer;
+    function f(var a: integer; b: integer): integer;
+    var z: integer;
+    begin
+        z := a;
+        a := 1;
+        f := a;
+    end;
+begin
+    x := f(x, 2+3);
+end.
\ No newline at end of file
diff --git a/ORIGNAL/teste11.pas b/ORIGNAL/teste11.pas
new file mode 100644
index 0000000..56e1c31
--- /dev/null
+++ b/ORIGNAL/teste11.pas
@@ -0,0 +1,22 @@
+program funcao (input, output); 
+var  m: integer;      
+function f(n: integer; var k: integer): integer; 
+var p, q: integer;           
+begin                    
+   if n<2 then
+      begin          
+         f:=n; k:=0;     
+      end              
+   else                
+      begin            
+         f:=f(n-1,p) + f(n-2,q);   
+         k:=p+q+1;      
+      end;             
+   write(n,k);        
+end;                      
+begin                          
+   write(f(3,m),m);
+end. 
+
+
+
diff --git a/ORIGNAL/teste2.pas b/ORIGNAL/teste2.pas
new file mode 100644
index 0000000..93c6a6a
--- /dev/null
+++ b/ORIGNAL/teste2.pas
@@ -0,0 +1,7 @@
+program varsGlobais (input, output);
+var a: integer;
+    b: integer;
+begin
+    a := 5;
+    b := b + 5 * 2;
+end.
diff --git a/ORIGNAL/teste3.pas b/ORIGNAL/teste3.pas
new file mode 100644
index 0000000..fd9e82e
--- /dev/null
+++ b/ORIGNAL/teste3.pas
@@ -0,0 +1,11 @@
+program varsGlobais (input, output);
+var a: integer;
+    b: integer;
+begin
+    a := 5;
+    b := a + 5 * 2;
+    while b > 5 do
+    begin
+	    b := 0;
+    end;
+end.
diff --git a/ORIGNAL/teste4.pas b/ORIGNAL/teste4.pas
new file mode 100644
index 0000000..486791c
--- /dev/null
+++ b/ORIGNAL/teste4.pas
@@ -0,0 +1,13 @@
+program comandoWhile (input, output);
+var n, k: integer; 
+    f1, f2, f3:integer;
+begin             
+   f1:=0; f2:=1; k:=1;
+   while k <= n do  
+   begin              
+      f3:=f2+f1;      
+      f1:=f2;         
+      f2:=f3;         
+      k:=k+1;          
+   end;                 
+end. 
diff --git a/ORIGNAL/teste5.pas b/ORIGNAL/teste5.pas
new file mode 100644
index 0000000..a5cf75f
--- /dev/null
+++ b/ORIGNAL/teste5.pas
@@ -0,0 +1,20 @@
+program cmdIf (input, output);
+var i, j: integer;       
+begin        
+   read(j);          
+   i:=0;                   
+   while i < j do        
+   begin                   
+      if (i + 2) * 2 = i  
+        then
+        begin
+          write(i,0);
+          if i = 0
+            then write(2)
+            else write(3);
+         end
+        else  write(i,1);
+      i := i+1;             
+   end;                    
+end. 
+
diff --git a/ORIGNAL/teste6.pas b/ORIGNAL/teste6.pas
new file mode 100644
index 0000000..05af5da
--- /dev/null
+++ b/ORIGNAL/teste6.pas
@@ -0,0 +1,11 @@
+program proc1 (input, output);
+    var x: integer;
+    procedure p;
+    var z: integer;
+    begin
+        z := 3;
+    end
+begin
+    x := 8;
+    p;
+end.
\ No newline at end of file
diff --git a/ORIGNAL/teste7.pas b/ORIGNAL/teste7.pas
new file mode 100644
index 0000000..c3801a1
--- /dev/null
+++ b/ORIGNAL/teste7.pas
@@ -0,0 +1,11 @@
+program proc1 (input, output);
+    var x: integer;
+    procedure p;
+    var z: integer;
+    begin
+        z := a;
+    end;
+begin
+    x := 8;
+    p;
+end.
\ No newline at end of file
diff --git a/ORIGNAL/teste8.pas b/ORIGNAL/teste8.pas
new file mode 100644
index 0000000..e0df5ef
--- /dev/null
+++ b/ORIGNAL/teste8.pas
@@ -0,0 +1,11 @@
+program proc1 (input, output);
+    var x: integer;
+    procedure p(a, b: integer);
+    var z: integer;
+    begin
+        z := a;
+    end;
+begin
+    x := 8;
+    p(x, 2);
+end.
\ No newline at end of file
diff --git a/ORIGNAL/teste9.pas b/ORIGNAL/teste9.pas
new file mode 100644
index 0000000..5e3e87b
--- /dev/null
+++ b/ORIGNAL/teste9.pas
@@ -0,0 +1,12 @@
+program proc1 (input, output);
+    var x: integer;
+    procedure p(var a: integer; b: integer);
+    var z: integer;
+    begin
+        z := a;
+        a := 1;
+    end;
+begin
+    x := 8;
+    p(x, 2+3);
+end.
\ No newline at end of file
diff --git a/ORIGNAL/ts/ts.c b/ORIGNAL/ts/ts.c
new file mode 100644
index 0000000..97491ea
--- /dev/null
+++ b/ORIGNAL/ts/ts.c
@@ -0,0 +1,360 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ts.h" 
+
+void inicializa_ts(ts_t *ts){
+	ts->topo = NULL;
+	ts->tam = 0;
+}
+
+void insere_ts(char *ident, int categ, int nivel, info_t info, ts_t *ts){
+	if(ts == NULL) return;
+
+	simb_t *new = (simb_t *)malloc(sizeof(simb_t));
+	new->ident = (char *)malloc((strlen(ident) + 1) * sizeof(char));
+	strcpy(new->ident, ident);
+	new->categ = categ;
+	new->nivel = nivel;
+    if (categ == VS) {
+        new->info.vs.tipo = info.vs.tipo;
+        new->info.vs.desloc = info.vs.desloc;
+    } else if (categ == PR) {
+        strcpy(new->info.pr.rot, info.pr.rot);
+        new->info.pr.quant = info.pr.quant;
+        new->info.pr.param = (int **)malloc(info.pr.quant * sizeof(int *));
+        for (int i = 0; i < info.pr.quant; i++) {
+            new->info.pr.param[i] = (int *)malloc(2 * sizeof(int));
+            new->info.pr.param[i][0] = info.pr.param[i][0];
+            new->info.pr.param[i][1] = info.pr.param[i][1];
+        }
+    } else if (categ == PF) {
+        new->info.pf.tipo = info.pf.tipo;
+        new->info.pf.desloc = info.pf.desloc;
+        new->info.pf.passagem = info.pf.passagem;
+    } else if (categ == FUN) {
+        strcpy(new->info.fun.rot, info.fun.rot);
+        new->info.fun.quant = info.fun.quant;
+        new->info.fun.param = (int **)malloc(info.fun.quant * sizeof(int *));
+        for (int i = 0; i < info.fun.quant; i++) {
+            new->info.fun.param[i] = (int *)malloc(2 * sizeof(int));
+            new->info.fun.param[i][0] = info.fun.param[i][0];
+            new->info.fun.param[i][1] = info.fun.param[i][1];
+        }
+        new->info.fun.tipo = info.fun.tipo;
+        new->info.fun.desloc = info.fun.desloc;
+    }
+
+	new->prox = ts->topo;
+	ts->topo = new;
+	ts->tam += 1;
+}
+
+simb_t *busca(char *ident, ts_t *ts){
+	if(ts == NULL) return NULL;
+
+	simb_t *p = ts->topo; //ponteiro?
+	if (strcmp(p->ident, ident) == 0) return p; //str compare
+	for (int i = 1; i < ts->tam; ++i){
+		p = p->prox;
+		if (strcmp(p->ident, ident) == 0) return p; //str compare
+	}
+	return NULL;//nao tem
+}
+
+simb_t *topo(ts_t *ts){
+    if(ts == NULL) return NULL;
+    return ts->topo;
+}
+
+int retira_vs_pf(ts_t *ts) {
+    if (ts == NULL || ts->topo == NULL) {
+        return 0; // Nenhum elemento a ser removido
+    }
+
+    int i; // Contador de elementos removidos
+    simb_t *temp = ts->topo;
+    while (ts->topo != NULL && (ts->topo->categ == VS || ts->topo->categ == PF)) {
+        temp = ts->topo;  
+        ts->topo = ts->topo->prox; 
+        //free the intern stuff
+        if (temp->categ == VS) {
+            free(temp->ident);
+        } else if (temp->categ == PF) {
+            free(temp->ident);
+        }
+        free(temp); 
+        ts->tam--;  
+    }
+
+    //retorna novo deslocamento
+    while (temp != NULL) {
+        if (temp->categ == VS || temp->categ == PF) {
+            return temp->info.vs.desloc + 1;
+        }
+        temp = temp->prox;
+    }
+    return 0;
+}
+
+int retira_pr_fun(ts_t *ts) {
+    if (ts == NULL || ts->topo == NULL) {
+        return 0; // Nenhum elemento a ser removido
+    }
+
+    int i; // Contador de elementos removidos
+    simb_t *temp = ts->topo;
+    while (ts->topo != NULL && (ts->topo->categ == PR || ts->topo->categ == FUN)) {
+        temp = ts->topo;  
+        ts->topo = ts->topo->prox; 
+        //free the intern stuff
+        if (temp->categ == PR) {
+            free(temp->ident);
+            for (int i = 0; i < temp->info.pr.quant; i++) {
+                free(temp->info.pr.param[i]);
+            }
+            free(temp->info.pr.param);
+        } else if (temp->categ == FUN) {
+            free(temp->ident);
+            for (int i = 0; i < temp->info.fun.quant; i++) {
+                free(temp->info.fun.param[i]);
+            }
+            free(temp->info.fun.param);
+        }
+        free(temp); 
+        ts->tam--;  
+    }
+
+    //retorna novo deslocamento
+    while (temp != NULL) {
+        if (temp->categ == VS || temp->categ == PF) {
+            return temp->info.vs.desloc + 1;
+        }
+        temp = temp->prox;
+    }
+    return 0;
+}
+
+int retira(int n, ts_t *ts) {
+    if (ts == NULL || ts->topo == NULL) {
+        return 0; // Nenhum elemento a ser removido
+    }
+
+    int i; // Contador de elementos removidos
+    simb_t *temp = ts->topo;
+    for (i = 0; i < n && ts->topo != NULL; i++) {
+        temp = ts->topo;  
+        ts->topo = ts->topo->prox; 
+        free(temp); 
+        ts->tam--;  
+    }
+
+    if (i < n) {
+        printf("Aviso: Tentativa de remover mais itens (%d) do que a pilha possui (%d). Removidos apenas %d itens.\n", n, i, i);
+    }
+
+    //retorna novo deslocamento
+    while (temp != NULL) {
+        if (temp->categ == VS) {
+            return temp->info.vs.desloc + 1;
+        }
+        temp = temp->prox;
+    }
+    return 0;
+}
+
+void atualiza_tipo(int n, int tipo, ts_t *ts){
+	if(ts == NULL || ts->topo == NULL || n <= 0) return;
+
+	simb_t *p = ts->topo;
+    int count = 0;
+    while (p != NULL && count < n) {
+        if (p->categ == VS && p->info.vs.tipo == NSEI) {
+            p->info.vs.tipo = tipo;
+            count++;
+        } else if (p->categ == PF && p->info.pf.tipo == NSEI) {
+            p->info.pf.tipo = tipo;
+            count++;
+        } else if (p->categ == FUN && p->info.fun.tipo == NSEI) {
+            p->info.fun.tipo = tipo;
+            count++;
+        }
+        p = p->prox;
+    }
+}
+
+void adiciona_param(char *ident, int n, 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 && p->categ != FUN)) return;
+
+    if (p->categ == PR) {
+        if(p->info.pr.quant != 0) return;
+
+        p->info.pr.param = (int **)malloc(n * sizeof(int *));
+        p->info.pr.quant = n;
+
+        simb_t *pf = ts->topo;
+        for (int i = n-1, j = 0; i >= 0 && pf != NULL; i--, j++) {
+            if (pf->categ == PF) {
+                p->info.pr.param[i] = (int *)malloc(2 * sizeof(int));
+                p->info.pr.param[i][0] = pf->info.pf.tipo;
+                p->info.pr.param[i][1] = pf->info.pf.passagem;
+                pf->info.pf.desloc = -4 - j;
+            }
+            pf = pf->prox;
+        }
+    } else if (p->categ == FUN) {
+        if(p->info.fun.quant != 0) return;
+
+        p->info.fun.param = (int **)malloc(n * sizeof(int *));
+        p->info.fun.quant = n;
+
+        simb_t *pf = ts->topo;
+        int i,j;
+        for (i = n-1, j = 0; i >= 0 && pf != NULL; i--, j++) {
+            if (pf->categ == PF) {
+                p->info.fun.param[i] = (int *)malloc(2 * sizeof(int));
+                p->info.fun.param[i][0] = pf->info.pf.tipo;
+                p->info.fun.param[i][1] = pf->info.pf.passagem;
+                pf->info.pf.desloc = -4 - j;
+            }
+            pf = pf->prox;
+        }
+        p->info.fun.desloc = -4 - j;
+    }
+}
+
+void mostra_ts(ts_t *ts) {
+    if (ts == NULL || ts->topo == NULL) {
+        printf("Tabela de Símbolos está vazia ou não inicializada.\n");
+        return;
+    }
+
+    printf("\nTabela de Símbolos:\n");
+    printf("----------------------------------------------------------------------------------\n");
+    printf("| %-10s | %-8s | %-8s | %-10s | %-10s | %-20s |\n", 
+           "Ident", "Categ", "Nivel", "Tipo", "Desloc", "Detalhes");
+    printf("----------------------------------------------------------------------------------\n");
+
+    simb_t *p = ts->topo;
+    while (p != NULL) {
+        const char *categStr = "Outro";
+        const char *tipoStr = "-";
+        char deslocStr[10] = "-";
+        char detalhes[200] = "-";
+
+        switch (p->categ) {
+            case VS: {
+                categStr = "VS";
+                switch (p->info.vs.tipo) {
+                    case INTEIRO:
+                        tipoStr = "Inteiro";
+                        break;
+                    case BOOLEAN:
+                        tipoStr = "Boolean";
+                        break;
+                    default:
+                        tipoStr = "NSEI";
+                        break;
+                }
+                snprintf(deslocStr, sizeof(deslocStr), "%d", p->info.vs.desloc);
+                break;
+            }
+            case PR: {
+                categStr = "PR";
+                tipoStr = "-";
+                if (p->info.pr.quant > 1) {
+                    char paramStr[150] = "";
+                    snprintf(paramStr, sizeof(paramStr), "%d{", p->info.pr.quant);
+                    for (int i = 0; i < p->info.pr.quant; i++) {
+                        const char *paramTipo = 
+                            (p->info.pr.param[i][0] == INTEIRO) ? "Int" :
+                            (p->info.pr.param[i][0] == BOOLEAN) ? "Bool" : "NSEI";
+                        const char *paramPassagem = 
+                            (p->info.pr.param[i][1] == VLR) ? "VLR" : "REF";
+
+                        char singleParam[30];
+                        snprintf(singleParam, sizeof(singleParam), "[%s,%s]", paramTipo, paramPassagem);
+                        strncat(paramStr, singleParam, sizeof(paramStr) - strlen(paramStr) - 1);
+                        if (i < p->info.pr.quant - 1) {
+                            strncat(paramStr, ",", sizeof(paramStr) - strlen(paramStr) - 1);
+                        }
+                    }
+                    strncat(paramStr, "}", sizeof(paramStr) - strlen(paramStr) - 1);
+                    snprintf(detalhes, sizeof(detalhes), "%s, Params: %s", p->info.pr.rot, paramStr);
+                } else {
+                    snprintf(detalhes, sizeof(detalhes), "%s, Params: %d", p->info.pr.rot, p->info.pr.quant);
+                }
+                break;
+            }
+            case PF: {
+                categStr = "PF";
+                switch (p->info.pf.tipo) {
+                    case INTEIRO:
+                        tipoStr = "Inteiro";
+                        break;
+                    case BOOLEAN:
+                        tipoStr = "Boolean";
+                        break;
+                    default:
+                        tipoStr = "NSEI";
+                        break;
+                }
+                snprintf(deslocStr, sizeof(deslocStr), "%d", p->info.pf.desloc);
+                snprintf(detalhes, sizeof(detalhes), "Passagem: %s", p->info.pf.passagem == VLR ? "Valor" : "Referência");
+                break;
+            }
+            case FUN: {
+                categStr = "FUN";
+                switch (p->info.fun.tipo) {
+                    case INTEIRO:
+                        tipoStr = "Inteiro";
+                        break;
+                    case BOOLEAN:
+                        tipoStr = "Boolean";
+                        break;
+                    default:
+                        tipoStr = "NSEI";
+                        break;
+                }
+                snprintf(deslocStr, sizeof(deslocStr), "%d", p->info.fun.desloc);
+                if (p->info.fun.quant > 1) {
+                    char paramStr[150] = "";
+                    snprintf(paramStr, sizeof(paramStr), "%d{", p->info.fun.quant);
+                    for (int i = 0; i < p->info.fun.quant; i++) {
+                        const char *paramTipo = 
+                            (p->info.fun.param[i][0] == INTEIRO) ? "Int" :
+                            (p->info.fun.param[i][0] == BOOLEAN) ? "Bool" : "NSEI";
+                        const char *paramPassagem = 
+                            (p->info.fun.param[i][1] == VLR) ? "VLR" : "REF";
+
+                        char singleParam[30];
+                        snprintf(singleParam, sizeof(singleParam), "[%s,%s]", paramTipo, paramPassagem);
+                        strncat(paramStr, singleParam, sizeof(paramStr) - strlen(paramStr) - 1);
+                        if (i < p->info.fun.quant - 1) {
+                            strncat(paramStr, ",", sizeof(paramStr) - strlen(paramStr) - 1);
+                        }
+                    }
+                    strncat(paramStr, "}", sizeof(paramStr) - strlen(paramStr) - 1);
+                    snprintf(detalhes, sizeof(detalhes), "%s, Params: %s", p->info.fun.rot, paramStr);
+                } else {
+                    snprintf(detalhes, sizeof(detalhes), "%s, Params: %d", p->info.fun.rot, p->info.fun.quant);
+                }
+                break;
+            }
+            default:
+                categStr = "Outro";
+        }
+
+        printf("| %-10s | %-8s | %-8d | %-10s | %-10s | %-20s |\n", 
+               p->ident, categStr, p->nivel, tipoStr, deslocStr, detalhes);
+
+        p = p->prox;
+    }
+    printf("----------------------------------------------------------------------------------\n");
+}
+
+
diff --git a/ORIGNAL/ts/ts.h b/ORIGNAL/ts/ts.h
new file mode 100644
index 0000000..30aa963
--- /dev/null
+++ b/ORIGNAL/ts/ts.h
@@ -0,0 +1,84 @@
+#ifndef __TS__
+#define __TS__
+
+typedef struct vs_t {
+    int tipo;
+    int desloc;
+} vs_t;
+
+typedef struct pr_t {
+    char rot[4];
+    int quant;
+    int **param;
+} pr_t;
+
+typedef struct pf_t {
+    int tipo;
+    int desloc;
+    int passagem;
+} pf_t;
+
+typedef struct fun_t {
+    char rot[4];
+    int quant;
+    int **param;
+    int tipo;
+    int desloc;
+} fun_t;
+
+typedef union info_t {
+    vs_t vs;
+    pr_t pr;
+    pf_t pf;
+    fun_t fun;
+} info_t;
+
+typedef struct simb_t {
+    char *ident;
+    int categ;
+    int nivel;
+    info_t info;
+    struct simb_t *prox; // Corrigido: use explicitamente struct simb_t
+} simb_t;
+
+typedef struct ts_t {
+    simb_t *topo;
+    int tam;
+} ts_t;
+
+// enum de tipos
+#define NSEI 0
+#define INTEIRO 1
+#define BOOLEAN 2
+
+// enum categorias
+#define VS 0
+#define PR 1
+#define PF 2
+#define FUN 3
+
+// enum passagem
+#define VLR 0
+#define REF 1
+
+void inicializa_ts(ts_t *ts);
+
+void insere_ts(char *ident, int categ, int nivel, info_t info, ts_t *ts);
+
+simb_t *busca(char *ident, ts_t *ts); // Corrigido: retorna ponteiro para simb_t
+
+simb_t *topo(ts_t *ts);
+
+int retira(int n, ts_t *ts);
+
+int retira_vs_pf(ts_t *ts);
+
+int retira_pr_fun(ts_t *ts);
+
+void atualiza_tipo(int n, int tipo, ts_t *ts);
+
+void adiciona_param(char *ident, int n, ts_t *ts);
+
+void mostra_ts(ts_t *ts);
+
+#endif
-- 
GitLab