diff --git a/MEPA b/MEPA
index f41e65000718ea0557b41978185c7ee38a51f37a..dd41d3f02a140ad26d914284dcd89eb1f12a7a5d 100644
--- a/MEPA
+++ b/MEPA
@@ -1,29 +1,49 @@
      INPP
      AMEM 2
-     AMEM 3
-     CRCT 0
-     ARMZ 0,2
-     CRCT 1
-     ARMZ 0,3
-     CRCT 1
+     LEIT
      ARMZ 0,1
+     CRCT 0
+     ARMZ 0,0
 R00: NADA 
-     CRVL 0,1
      CRVL 0,0
-     CMEG
-     DSVF R01
-     CRVL 0,3
-     CRVL 0,2
-     SOMA
-     ARMZ 0,4
-     CRVL 0,3
-     ARMZ 0,2
-     CRVL 0,4
-     ARMZ 0,3
      CRVL 0,1
+     CMME
+     DSVF R01
+     CRVL 0,0
+     CRCT 2
+     DIVI
+     CRCT 2
+     MULT
+     CRVL 0,0
+     CMIG
+     DSVF R02
+     CRVL 0,0
+     IMPR
+     CRCT 0
+     IMPR
+     CRVL 0,0
+     CRCT 0
+     CMIG
+     DSVF R04
+     CRCT 2
+     IMPR
+     DSVS R05
+R04: NADA 
+     CRCT 3
+     IMPR
+R05: NADA 
+     DSVS R03
+R02: NADA 
+     CRVL 0,0
+     IMPR
+     CRCT 1
+     IMPR
+R03: NADA 
+     CRVL 0,0
      CRCT 1
      SOMA
-     ARMZ 0,1
+     ARMZ 0,0
      DSVS R00
 R01: NADA 
+     DMEM 2
      PARA
diff --git a/compilador b/compilador
index 7f8599f3f7ee14c55ee262e5aaab503a1ab05654..3ee94dfccf57ca4549a0ec2e49fb5de71888f511 100755
Binary files a/compilador and b/compilador differ
diff --git a/compilador.h b/compilador.h
index 3f1dc0c1e1a829e8141af6c024eb1382e99c834e..5e8d4e8d20ad075968eb1f207f2f0936eac3152c 100644
--- a/compilador.h
+++ b/compilador.h
@@ -16,7 +16,7 @@
 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_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;
 
diff --git a/compilador.l b/compilador.l
index 1f1f4a37819dfd1f68a05d769fb30fba08161944..0629b8cd12eb42824d40c23d5b6c5071fa758662 100644
--- a/compilador.l
+++ b/compilador.l
@@ -70,6 +70,18 @@ end { simbolo = simb_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  ");
@@ -163,7 +175,7 @@ then { simbolo  = simb_then;
 
 else { simbolo  = simb_else;
           strncpy (token, yytext, TAM_TOKEN);
-          IMPRIME("else ");
+          IMPRIME(" else ");
           return ELSE;
  }
 
diff --git a/compilador.output b/compilador.output
index de7b057a8f852f34fc7095a8abd594264e6476b5..1ca2ea0851cab6d32ac702d341e83813f02d3aab 100644
--- a/compilador.output
+++ b/compilador.output
@@ -5,15 +5,12 @@ Terminais sem uso na gramática
     PROCEDURE
     FUNCTION
     GOTO
-    IF
-    THEN
-    ELSE
     OR
     AND
     NOT
 
 
-Estado 47 conflitos: 1 de redução/redução
+Estado 61 conflitos: 1 de redução/redução
 
 
 Gramática
@@ -70,39 +67,60 @@ Gramática
    29                   | comando_composto
    30                   | comando_condicional
    31                   | comando_repetitivo
+   32                   | leitura
+   33                   | escrita
 
-   32 expressao: expressao IGUAL expressao_simples
-   33          | expressao DIFERENTE expressao_simples
-   34          | expressao MENOR expressao_simples
-   35          | expressao MENOR_IGUAL expressao_simples
-   36          | expressao MAIOR expressao_simples
-   37          | expressao MAIOR_IGUAL expressao_simples
-   38          | expressao_simples
+   34 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES
 
-   39 expressao_simples: expressao_simples MAIS termo
-   40                  | expressao_simples MENOS termo
-   41                  | termo
+   35 lista_leituras: lista_leituras VIRGULA simb_leitura
+   36               | simb_leitura
 
-   42 termo: termo ASTERISCO fator
-   43      | termo DIV fator
-   44      | fator
+   37 simb_leitura: IDENT
 
-   45 $@6: ε
+   38 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES
 
-   46 atribuicao: IDENT $@6 ATRIBUICAO expressao_simples
+   39 lista_escritas: lista_escritas VIRGULA expressao_simples
+   40               | expressao_simples
 
-   47 fator: IDENT
-   48      | NUMERO
+   41 expressao: expressao IGUAL expressao_simples
+   42          | expressao DIFERENTE expressao_simples
+   43          | expressao MENOR expressao_simples
+   44          | expressao MENOR_IGUAL expressao_simples
+   45          | expressao MAIOR expressao_simples
+   46          | expressao MAIOR_IGUAL expressao_simples
+   47          | expressao_simples
 
-   49 numero: NUMERO
+   48 expressao_simples: expressao_simples MAIS termo
+   49                  | expressao_simples MENOS termo
+   50                  | termo
 
-   50 $@7: ε
+   51 termo: termo ASTERISCO fator
+   52      | termo DIV fator
+   53      | fator
 
-   51 $@8: ε
+   54 $@6: ε
 
-   52 comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo
+   55 atribuicao: IDENT $@6 ATRIBUICAO expressao_simples
 
-   53 comando_condicional: ε
+   56 fator: IDENT
+   57      | NUMERO
+
+   58 numero: NUMERO
+
+   59 $@7: ε
+
+   60 $@8: ε
+
+   61 comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo
+
+   62 comando_condicional: if_then cond_else
+
+   63 cond_else: ELSE comando_sem_rotulo
+   64          | ε
+
+   65 $@9: ε
+
+   66 if_then: IF expressao $@9 THEN comando_sem_rotulo
 
 
 Terminais, com as regras onde eles aparecem
@@ -110,141 +128,168 @@ Terminais, com as regras onde eles aparecem
     $end (0) 0
     error (256)
     PROGRAM (258) 2
-    ABRE_PARENTESES (259) 2
-    FECHA_PARENTESES (260) 2
-    VIRGULA (261) 5 17 19
+    ABRE_PARENTESES (259) 2 34 38
+    FECHA_PARENTESES (260) 2 34 38
+    VIRGULA (261) 5 17 19 35 39
     PONTO_E_VIRGULA (262) 2 15 23 24
     DOIS_PONTOS (263) 15 26
     PONTO (264) 2
     T_BEGIN (265) 22
     T_END (266) 22
     VAR (267) 9
-    IDENT (268) 2 16 17 18 19 20 46 47
-    ATRIBUICAO (269) 46
+    IDENT (268) 2 16 17 18 19 20 37 55 56
+    ATRIBUICAO (269) 55
     LABEL (270) 5
     TYPE (271)
     ARRAY (272)
     PROCEDURE (273)
     FUNCTION (274)
     GOTO (275)
-    IF (276)
-    THEN (277)
-    ELSE (278)
-    WHILE (279) 52
-    DO (280) 52
+    IF (276) 66
+    THEN (277) 66
+    ELSE (278) 63
+    WHILE (279) 61
+    DO (280) 61
     OR (281)
-    DIV (282) 43
+    DIV (282) 52
     AND (283)
     NOT (284)
-    IGUAL (285) 32
-    DIFERENTE (286) 33
-    MENOR_IGUAL (287) 35
-    MAIOR_IGUAL (288) 37
-    MENOR (289) 34
-    MAIOR (290) 36
-    MAIS (291) 39
-    MENOS (292) 40
-    ASTERISCO (293) 42
-    NUMERO (294) 48 49
+    IGUAL (285) 41
+    DIFERENTE (286) 42
+    MENOR_IGUAL (287) 44
+    MAIOR_IGUAL (288) 46
+    MENOR (289) 43
+    MAIOR (290) 45
+    MAIS (291) 48
+    MENOS (292) 49
+    ASTERISCO (293) 51
+    NUMERO (294) 57 58
+    READ (295) 34
+    WRITE (296) 38
+    LOWER_THAN_ELSE (297)
 
 
 Não terminais com as regras onde eles aparecem
 
-    $accept (40)
+    $accept (43)
         à esquerda: 0
-    programa (41)
+    programa (44)
         à esquerda: 2
         à direita: 0
-    $@1 (42)
+    $@1 (45)
         à esquerda: 1
         à direita: 2
-    bloco (43)
+    bloco (46)
         à esquerda: 4
         à direita: 2
-    $@2 (44)
+    $@2 (47)
         à esquerda: 3
         à direita: 4
-    parte_declara_rotulos (45)
+    parte_declara_rotulos (48)
         à esquerda: 5 6
         à direita: 4
-    parte_declara_vars (46)
+    parte_declara_vars (49)
         à esquerda: 7
         à direita: 4
-    var (47)
+    var (50)
         à esquerda: 9 10
         à direita: 7
-    $@3 (48)
+    $@3 (51)
         à esquerda: 8
         à direita: 9
-    declara_vars (49)
+    declara_vars (52)
         à esquerda: 11 12
         à direita: 9 11
-    declara_var (50)
+    declara_var (53)
         à esquerda: 15
         à direita: 11 12
-    $@4 (51)
+    $@4 (54)
         à esquerda: 13
         à direita: 15
-    $@5 (52)
+    $@5 (55)
         à esquerda: 14
         à direita: 15
-    tipo (53)
+    tipo (56)
         à esquerda: 16
         à direita: 15
-    lista_id_var (54)
+    lista_id_var (57)
         à esquerda: 17 18
         à direita: 15 17
-    lista_idents (55)
+    lista_idents (58)
         à esquerda: 19 20
         à direita: 2 19
-    parte_declara_subrotinas (56)
+    parte_declara_subrotinas (59)
         à esquerda: 21
         à direita: 4
-    comando_composto (57)
+    comando_composto (60)
         à esquerda: 22
         à direita: 4 29
-    comandos (58)
+    comandos (61)
         à esquerda: 23 24 25
         à direita: 22 23
-    comando (59)
+    comando (62)
         à esquerda: 26 27
         à direita: 23 24
-    comando_sem_rotulo (60)
-        à esquerda: 28 29 30 31
-        à direita: 26 27 52
-    expressao (61)
-        à esquerda: 32 33 34 35 36 37 38
-        à direita: 32 33 34 35 36 37 52
-    expressao_simples (62)
-        à esquerda: 39 40 41
-        à direita: 32 33 34 35 36 37 38 39 40 46
-    termo (63)
-        à esquerda: 42 43 44
-        à direita: 39 40 41 42 43
-    atribuicao (64)
-        à esquerda: 46
+    comando_sem_rotulo (63)
+        à esquerda: 28 29 30 31 32 33
+        à direita: 26 27 61 63 66
+    leitura (64)
+        à esquerda: 34
+        à direita: 32
+    lista_leituras (65)
+        à esquerda: 35 36
+        à direita: 34 35
+    simb_leitura (66)
+        à esquerda: 37
+        à direita: 35 36
+    escrita (67)
+        à esquerda: 38
+        à direita: 33
+    lista_escritas (68)
+        à esquerda: 39 40
+        à direita: 38 39
+    expressao (69)
+        à esquerda: 41 42 43 44 45 46 47
+        à direita: 41 42 43 44 45 46 61 66
+    expressao_simples (70)
+        à esquerda: 48 49 50
+        à direita: 39 40 41 42 43 44 45 46 47 48 49 55
+    termo (71)
+        à esquerda: 51 52 53
+        à direita: 48 49 50 51 52
+    atribuicao (72)
+        à esquerda: 55
         à direita: 28
-    $@6 (65)
-        à esquerda: 45
-        à direita: 46
-    fator (66)
-        à esquerda: 47 48
-        à direita: 42 43 44
-    numero (67)
-        à esquerda: 49
+    $@6 (73)
+        à esquerda: 54
+        à direita: 55
+    fator (74)
+        à esquerda: 56 57
+        à direita: 51 52 53
+    numero (75)
+        à esquerda: 58
         à direita: 26
-    comando_repetitivo (68)
-        à esquerda: 52
+    comando_repetitivo (76)
+        à esquerda: 61
         à direita: 31
-    $@7 (69)
-        à esquerda: 50
-        à direita: 52
-    $@8 (70)
-        à esquerda: 51
-        à direita: 52
-    comando_condicional (71)
-        à esquerda: 53
+    $@7 (77)
+        à esquerda: 59
+        à direita: 61
+    $@8 (78)
+        à esquerda: 60
+        à direita: 61
+    comando_condicional (79)
+        à esquerda: 62
         à direita: 30
+    cond_else (80)
+        à esquerda: 63 64
+        à direita: 62
+    if_then (81)
+        à esquerda: 66
+        à direita: 62
+    $@9 (82)
+        à esquerda: 65
+        à direita: 66
 
 
 Estado 0
@@ -476,21 +521,26 @@ Estado 27
 
     T_BEGIN  deslocar, e ir ao estado 27
     IDENT    deslocar, e ir ao estado 32
-    NUMERO   deslocar, e ir ao estado 33
-
-    PONTO_E_VIRGULA  reduzir usando a regra 53 (comando_condicional)
-    WHILE            reduzir usando a regra 50 ($@7)
-    $padrão          reduzir usando a regra 25 (comandos)
-
-    comando_composto     ir ao estado 34
-    comandos             ir ao estado 35
-    comando              ir ao estado 36
-    comando_sem_rotulo   ir ao estado 37
-    atribuicao           ir ao estado 38
-    numero               ir ao estado 39
-    comando_repetitivo   ir ao estado 40
-    $@7                  ir ao estado 41
-    comando_condicional  ir ao estado 42
+    IF       deslocar, e ir ao estado 33
+    NUMERO   deslocar, e ir ao estado 34
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
+
+    WHILE    reduzir usando a regra 59 ($@7)
+    $padrão  reduzir usando a regra 25 (comandos)
+
+    comando_composto     ir ao estado 37
+    comandos             ir ao estado 38
+    comando              ir ao estado 39
+    comando_sem_rotulo   ir ao estado 40
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    numero               ir ao estado 44
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
 
 
 Estado 28
@@ -519,569 +569,853 @@ Estado 31
    15 declara_var: $@4 lista_id_var • DOIS_PONTOS tipo $@5 PONTO_E_VIRGULA
    17 lista_id_var: lista_id_var • VIRGULA IDENT
 
-    VIRGULA      deslocar, e ir ao estado 43
-    DOIS_PONTOS  deslocar, e ir ao estado 44
+    VIRGULA      deslocar, e ir ao estado 49
+    DOIS_PONTOS  deslocar, e ir ao estado 50
 
 
 Estado 32
 
-   46 atribuicao: IDENT • $@6 ATRIBUICAO expressao_simples
+   55 atribuicao: IDENT • $@6 ATRIBUICAO expressao_simples
 
-    $padrão  reduzir usando a regra 45 ($@6)
+    $padrão  reduzir usando a regra 54 ($@6)
 
-    $@6  ir ao estado 45
+    $@6  ir ao estado 51
 
 
 Estado 33
 
-   49 numero: NUMERO •
+   66 if_then: IF • expressao $@9 THEN comando_sem_rotulo
 
-    $padrão  reduzir usando a regra 49 (numero)
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
+
+    expressao          ir ao estado 54
+    expressao_simples  ir ao estado 55
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 34
 
-   29 comando_sem_rotulo: comando_composto •
+   58 numero: NUMERO •
 
-    $padrão  reduzir usando a regra 29 (comando_sem_rotulo)
+    $padrão  reduzir usando a regra 58 (numero)
 
 
 Estado 35
 
-   22 comando_composto: T_BEGIN comandos • T_END
+   34 leitura: READ • ABRE_PARENTESES lista_leituras FECHA_PARENTESES
 
-    T_END  deslocar, e ir ao estado 46
+    ABRE_PARENTESES  deslocar, e ir ao estado 58
 
 
 Estado 36
 
-   23 comandos: comando • PONTO_E_VIRGULA comandos
-   24         | comando • PONTO_E_VIRGULA
+   38 escrita: WRITE • ABRE_PARENTESES lista_escritas FECHA_PARENTESES
 
-    PONTO_E_VIRGULA  deslocar, e ir ao estado 47
+    ABRE_PARENTESES  deslocar, e ir ao estado 59
 
 
 Estado 37
 
-   27 comando: comando_sem_rotulo •
+   29 comando_sem_rotulo: comando_composto •
 
-    $padrão  reduzir usando a regra 27 (comando)
+    $padrão  reduzir usando a regra 29 (comando_sem_rotulo)
 
 
 Estado 38
 
-   28 comando_sem_rotulo: atribuicao •
+   22 comando_composto: T_BEGIN comandos • T_END
 
-    $padrão  reduzir usando a regra 28 (comando_sem_rotulo)
+    T_END  deslocar, e ir ao estado 60
 
 
 Estado 39
 
-   26 comando: numero • DOIS_PONTOS comando_sem_rotulo
+   23 comandos: comando • PONTO_E_VIRGULA comandos
+   24         | comando • PONTO_E_VIRGULA
 
-    DOIS_PONTOS  deslocar, e ir ao estado 48
+    PONTO_E_VIRGULA  deslocar, e ir ao estado 61
 
 
 Estado 40
 
-   31 comando_sem_rotulo: comando_repetitivo •
+   27 comando: comando_sem_rotulo •
 
-    $padrão  reduzir usando a regra 31 (comando_sem_rotulo)
+    $padrão  reduzir usando a regra 27 (comando)
 
 
 Estado 41
 
-   52 comando_repetitivo: $@7 • WHILE expressao DO $@8 comando_sem_rotulo
+   32 comando_sem_rotulo: leitura •
 
-    WHILE  deslocar, e ir ao estado 49
+    $padrão  reduzir usando a regra 32 (comando_sem_rotulo)
 
 
 Estado 42
 
-   30 comando_sem_rotulo: comando_condicional •
+   33 comando_sem_rotulo: escrita •
 
-    $padrão  reduzir usando a regra 30 (comando_sem_rotulo)
+    $padrão  reduzir usando a regra 33 (comando_sem_rotulo)
 
 
 Estado 43
 
-   17 lista_id_var: lista_id_var VIRGULA • IDENT
+   28 comando_sem_rotulo: atribuicao •
 
-    IDENT  deslocar, e ir ao estado 50
+    $padrão  reduzir usando a regra 28 (comando_sem_rotulo)
 
 
 Estado 44
 
-   15 declara_var: $@4 lista_id_var DOIS_PONTOS • tipo $@5 PONTO_E_VIRGULA
-
-    IDENT  deslocar, e ir ao estado 51
+   26 comando: numero • DOIS_PONTOS comando_sem_rotulo
 
-    tipo  ir ao estado 52
+    DOIS_PONTOS  deslocar, e ir ao estado 62
 
 
 Estado 45
 
-   46 atribuicao: IDENT $@6 • ATRIBUICAO expressao_simples
+   31 comando_sem_rotulo: comando_repetitivo •
 
-    ATRIBUICAO  deslocar, e ir ao estado 53
+    $padrão  reduzir usando a regra 31 (comando_sem_rotulo)
 
 
 Estado 46
 
-   22 comando_composto: T_BEGIN comandos T_END •
+   61 comando_repetitivo: $@7 • WHILE expressao DO $@8 comando_sem_rotulo
 
-    $padrão  reduzir usando a regra 22 (comando_composto)
+    WHILE  deslocar, e ir ao estado 63
 
 
 Estado 47
 
-   23 comandos: comando PONTO_E_VIRGULA • comandos
-   24         | comando PONTO_E_VIRGULA •
-
-    T_BEGIN  deslocar, e ir ao estado 27
-    IDENT    deslocar, e ir ao estado 32
-    NUMERO   deslocar, e ir ao estado 33
-
-    PONTO_E_VIRGULA  reduzir usando a regra 53 (comando_condicional)
-    T_END            reduzir usando a regra 24 (comandos)
-    T_END            [reduzir usando a regra 25 (comandos)]
-    WHILE            reduzir usando a regra 50 ($@7)
-    $padrão          reduzir usando a regra 24 (comandos)
+   30 comando_sem_rotulo: comando_condicional •
 
-    comando_composto     ir ao estado 34
-    comandos             ir ao estado 54
-    comando              ir ao estado 36
-    comando_sem_rotulo   ir ao estado 37
-    atribuicao           ir ao estado 38
-    numero               ir ao estado 39
-    comando_repetitivo   ir ao estado 40
-    $@7                  ir ao estado 41
-    comando_condicional  ir ao estado 42
+    $padrão  reduzir usando a regra 30 (comando_sem_rotulo)
 
 
 Estado 48
 
-   26 comando: numero DOIS_PONTOS • comando_sem_rotulo
+   62 comando_condicional: if_then • cond_else
 
-    T_BEGIN  deslocar, e ir ao estado 27
-    IDENT    deslocar, e ir ao estado 32
+    ELSE  deslocar, e ir ao estado 64
 
-    PONTO_E_VIRGULA  reduzir usando a regra 53 (comando_condicional)
-    $padrão          reduzir usando a regra 50 ($@7)
+    $padrão  reduzir usando a regra 64 (cond_else)
 
-    comando_composto     ir ao estado 34
-    comando_sem_rotulo   ir ao estado 55
-    atribuicao           ir ao estado 38
-    comando_repetitivo   ir ao estado 40
-    $@7                  ir ao estado 41
-    comando_condicional  ir ao estado 42
+    cond_else  ir ao estado 65
 
 
 Estado 49
 
-   52 comando_repetitivo: $@7 WHILE • expressao DO $@8 comando_sem_rotulo
-
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+   17 lista_id_var: lista_id_var VIRGULA • IDENT
 
-    expressao          ir ao estado 58
-    expressao_simples  ir ao estado 59
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    IDENT  deslocar, e ir ao estado 66
 
 
 Estado 50
 
-   17 lista_id_var: lista_id_var VIRGULA IDENT •
+   15 declara_var: $@4 lista_id_var DOIS_PONTOS • tipo $@5 PONTO_E_VIRGULA
 
-    $padrão  reduzir usando a regra 17 (lista_id_var)
+    IDENT  deslocar, e ir ao estado 67
+
+    tipo  ir ao estado 68
 
 
 Estado 51
 
-   16 tipo: IDENT •
+   55 atribuicao: IDENT $@6 • ATRIBUICAO expressao_simples
 
-    $padrão  reduzir usando a regra 16 (tipo)
+    ATRIBUICAO  deslocar, e ir ao estado 69
 
 
 Estado 52
 
-   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo • $@5 PONTO_E_VIRGULA
+   56 fator: IDENT •
 
-    $padrão  reduzir usando a regra 14 ($@5)
-
-    $@5  ir ao estado 62
+    $padrão  reduzir usando a regra 56 (fator)
 
 
 Estado 53
 
-   46 atribuicao: IDENT $@6 ATRIBUICAO • expressao_simples
+   57 fator: NUMERO •
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
-
-    expressao_simples  ir ao estado 63
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    $padrão  reduzir usando a regra 57 (fator)
 
 
 Estado 54
 
-   23 comandos: comando PONTO_E_VIRGULA comandos •
+   41 expressao: expressao • IGUAL expressao_simples
+   42          | expressao • DIFERENTE expressao_simples
+   43          | expressao • MENOR expressao_simples
+   44          | expressao • MENOR_IGUAL expressao_simples
+   45          | expressao • MAIOR expressao_simples
+   46          | expressao • MAIOR_IGUAL expressao_simples
+   66 if_then: IF expressao • $@9 THEN comando_sem_rotulo
 
-    $padrão  reduzir usando a regra 23 (comandos)
+    IGUAL        deslocar, e ir ao estado 70
+    DIFERENTE    deslocar, e ir ao estado 71
+    MENOR_IGUAL  deslocar, e ir ao estado 72
+    MAIOR_IGUAL  deslocar, e ir ao estado 73
+    MENOR        deslocar, e ir ao estado 74
+    MAIOR        deslocar, e ir ao estado 75
+
+    $padrão  reduzir usando a regra 65 ($@9)
+
+    $@9  ir ao estado 76
 
 
 Estado 55
 
-   26 comando: numero DOIS_PONTOS comando_sem_rotulo •
+   47 expressao: expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
 
-    $padrão  reduzir usando a regra 26 (comando)
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 47 (expressao)
 
 
 Estado 56
 
-   47 fator: IDENT •
+   50 expressao_simples: termo •
+   51 termo: termo • ASTERISCO fator
+   52      | termo • DIV fator
 
-    $padrão  reduzir usando a regra 47 (fator)
+    DIV        deslocar, e ir ao estado 79
+    ASTERISCO  deslocar, e ir ao estado 80
+
+    $padrão  reduzir usando a regra 50 (expressao_simples)
 
 
 Estado 57
 
-   48 fator: NUMERO •
+   53 termo: fator •
 
-    $padrão  reduzir usando a regra 48 (fator)
+    $padrão  reduzir usando a regra 53 (termo)
 
 
 Estado 58
 
-   32 expressao: expressao • IGUAL expressao_simples
-   33          | expressao • DIFERENTE expressao_simples
-   34          | expressao • MENOR expressao_simples
-   35          | expressao • MENOR_IGUAL expressao_simples
-   36          | expressao • MAIOR expressao_simples
-   37          | expressao • MAIOR_IGUAL expressao_simples
-   52 comando_repetitivo: $@7 WHILE expressao • DO $@8 comando_sem_rotulo
+   34 leitura: READ ABRE_PARENTESES • lista_leituras FECHA_PARENTESES
+
+    IDENT  deslocar, e ir ao estado 81
 
-    DO           deslocar, e ir ao estado 64
-    IGUAL        deslocar, e ir ao estado 65
-    DIFERENTE    deslocar, e ir ao estado 66
-    MENOR_IGUAL  deslocar, e ir ao estado 67
-    MAIOR_IGUAL  deslocar, e ir ao estado 68
-    MENOR        deslocar, e ir ao estado 69
-    MAIOR        deslocar, e ir ao estado 70
+    lista_leituras  ir ao estado 82
+    simb_leitura    ir ao estado 83
 
 
 Estado 59
 
-   38 expressao: expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   38 escrita: WRITE ABRE_PARENTESES • lista_escritas FECHA_PARENTESES
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 38 (expressao)
+    lista_escritas     ir ao estado 84
+    expressao_simples  ir ao estado 85
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 60
 
-   41 expressao_simples: termo •
-   42 termo: termo • ASTERISCO fator
-   43      | termo • DIV fator
-
-    DIV        deslocar, e ir ao estado 73
-    ASTERISCO  deslocar, e ir ao estado 74
+   22 comando_composto: T_BEGIN comandos T_END •
 
-    $padrão  reduzir usando a regra 41 (expressao_simples)
+    $padrão  reduzir usando a regra 22 (comando_composto)
 
 
 Estado 61
 
-   44 termo: fator •
+   23 comandos: comando PONTO_E_VIRGULA • comandos
+   24         | comando PONTO_E_VIRGULA •
 
-    $padrão  reduzir usando a regra 44 (termo)
+    T_BEGIN  deslocar, e ir ao estado 27
+    IDENT    deslocar, e ir ao estado 32
+    IF       deslocar, e ir ao estado 33
+    NUMERO   deslocar, e ir ao estado 34
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
+
+    T_END    reduzir usando a regra 24 (comandos)
+    T_END    [reduzir usando a regra 25 (comandos)]
+    WHILE    reduzir usando a regra 59 ($@7)
+    $padrão  reduzir usando a regra 24 (comandos)
+
+    comando_composto     ir ao estado 37
+    comandos             ir ao estado 86
+    comando              ir ao estado 39
+    comando_sem_rotulo   ir ao estado 40
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    numero               ir ao estado 44
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
 
 
 Estado 62
 
-   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo $@5 • PONTO_E_VIRGULA
+   26 comando: numero DOIS_PONTOS • comando_sem_rotulo
 
-    PONTO_E_VIRGULA  deslocar, e ir ao estado 75
+    T_BEGIN  deslocar, e ir ao estado 27
+    IDENT    deslocar, e ir ao estado 32
+    IF       deslocar, e ir ao estado 33
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
+
+    $padrão  reduzir usando a regra 59 ($@7)
+
+    comando_composto     ir ao estado 37
+    comando_sem_rotulo   ir ao estado 87
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
 
 
 Estado 63
 
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
-   46 atribuicao: IDENT $@6 ATRIBUICAO expressao_simples •
+   61 comando_repetitivo: $@7 WHILE • expressao DO $@8 comando_sem_rotulo
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 46 (atribuicao)
+    expressao          ir ao estado 88
+    expressao_simples  ir ao estado 55
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 64
 
-   52 comando_repetitivo: $@7 WHILE expressao DO • $@8 comando_sem_rotulo
+   63 cond_else: ELSE • comando_sem_rotulo
 
-    $padrão  reduzir usando a regra 51 ($@8)
+    T_BEGIN  deslocar, e ir ao estado 27
+    IDENT    deslocar, e ir ao estado 32
+    IF       deslocar, e ir ao estado 33
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
 
-    $@8  ir ao estado 76
+    $padrão  reduzir usando a regra 59 ($@7)
 
+    comando_composto     ir ao estado 37
+    comando_sem_rotulo   ir ao estado 89
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
 
-Estado 65
 
-   32 expressao: expressao IGUAL • expressao_simples
+Estado 65
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+   62 comando_condicional: if_then cond_else •
 
-    expressao_simples  ir ao estado 77
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    $padrão  reduzir usando a regra 62 (comando_condicional)
 
 
 Estado 66
 
-   33 expressao: expressao DIFERENTE • expressao_simples
-
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+   17 lista_id_var: lista_id_var VIRGULA IDENT •
 
-    expressao_simples  ir ao estado 78
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    $padrão  reduzir usando a regra 17 (lista_id_var)
 
 
 Estado 67
 
-   35 expressao: expressao MENOR_IGUAL • expressao_simples
-
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+   16 tipo: IDENT •
 
-    expressao_simples  ir ao estado 79
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    $padrão  reduzir usando a regra 16 (tipo)
 
 
 Estado 68
 
-   37 expressao: expressao MAIOR_IGUAL • expressao_simples
+   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo • $@5 PONTO_E_VIRGULA
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    $padrão  reduzir usando a regra 14 ($@5)
 
-    expressao_simples  ir ao estado 80
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    $@5  ir ao estado 90
 
 
 Estado 69
 
-   34 expressao: expressao MENOR • expressao_simples
+   55 atribuicao: IDENT $@6 ATRIBUICAO • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    expressao_simples  ir ao estado 81
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    expressao_simples  ir ao estado 91
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 70
 
-   36 expressao: expressao MAIOR • expressao_simples
+   41 expressao: expressao IGUAL • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    expressao_simples  ir ao estado 82
-    termo              ir ao estado 60
-    fator              ir ao estado 61
+    expressao_simples  ir ao estado 92
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 71
 
-   39 expressao_simples: expressao_simples MAIS • termo
+   42 expressao: expressao DIFERENTE • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    termo  ir ao estado 83
-    fator  ir ao estado 61
+    expressao_simples  ir ao estado 93
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 72
 
-   40 expressao_simples: expressao_simples MENOS • termo
+   44 expressao: expressao MENOR_IGUAL • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    termo  ir ao estado 84
-    fator  ir ao estado 61
+    expressao_simples  ir ao estado 94
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 73
 
-   43 termo: termo DIV • fator
+   46 expressao: expressao MAIOR_IGUAL • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    fator  ir ao estado 85
+    expressao_simples  ir ao estado 95
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 74
 
-   42 termo: termo ASTERISCO • fator
+   43 expressao: expressao MENOR • expressao_simples
 
-    IDENT   deslocar, e ir ao estado 56
-    NUMERO  deslocar, e ir ao estado 57
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    fator  ir ao estado 86
+    expressao_simples  ir ao estado 96
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
 
 Estado 75
 
-   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo $@5 PONTO_E_VIRGULA •
-
-    $padrão  reduzir usando a regra 15 (declara_var)
+   45 expressao: expressao MAIOR • expressao_simples
 
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-Estado 76
+    expressao_simples  ir ao estado 97
+    termo              ir ao estado 56
+    fator              ir ao estado 57
 
-   52 comando_repetitivo: $@7 WHILE expressao DO $@8 • comando_sem_rotulo
 
-    T_BEGIN  deslocar, e ir ao estado 27
-    IDENT    deslocar, e ir ao estado 32
+Estado 76
 
-    PONTO_E_VIRGULA  reduzir usando a regra 53 (comando_condicional)
-    $padrão          reduzir usando a regra 50 ($@7)
+   66 if_then: IF expressao $@9 • THEN comando_sem_rotulo
 
-    comando_composto     ir ao estado 34
-    comando_sem_rotulo   ir ao estado 87
-    atribuicao           ir ao estado 38
-    comando_repetitivo   ir ao estado 40
-    $@7                  ir ao estado 41
-    comando_condicional  ir ao estado 42
+    THEN  deslocar, e ir ao estado 98
 
 
 Estado 77
 
-   32 expressao: expressao IGUAL expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   48 expressao_simples: expressao_simples MAIS • termo
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 32 (expressao)
+    termo  ir ao estado 99
+    fator  ir ao estado 57
 
 
 Estado 78
 
-   33 expressao: expressao DIFERENTE expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   49 expressao_simples: expressao_simples MENOS • termo
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 33 (expressao)
+    termo  ir ao estado 100
+    fator  ir ao estado 57
 
 
 Estado 79
 
-   35 expressao: expressao MENOR_IGUAL expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   52 termo: termo DIV • fator
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 35 (expressao)
+    fator  ir ao estado 101
 
 
 Estado 80
 
-   37 expressao: expressao MAIOR_IGUAL expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   51 termo: termo ASTERISCO • fator
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
 
-    $padrão  reduzir usando a regra 37 (expressao)
+    fator  ir ao estado 102
 
 
 Estado 81
 
-   34 expressao: expressao MENOR expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
+   37 simb_leitura: IDENT •
 
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
-
-    $padrão  reduzir usando a regra 34 (expressao)
+    $padrão  reduzir usando a regra 37 (simb_leitura)
 
 
 Estado 82
 
-   36 expressao: expressao MAIOR expressao_simples •
-   39 expressao_simples: expressao_simples • MAIS termo
-   40                  | expressao_simples • MENOS termo
-
-    MAIS   deslocar, e ir ao estado 71
-    MENOS  deslocar, e ir ao estado 72
+   34 leitura: READ ABRE_PARENTESES lista_leituras • FECHA_PARENTESES
+   35 lista_leituras: lista_leituras • VIRGULA simb_leitura
 
-    $padrão  reduzir usando a regra 36 (expressao)
+    FECHA_PARENTESES  deslocar, e ir ao estado 103
+    VIRGULA           deslocar, e ir ao estado 104
 
 
 Estado 83
 
-   39 expressao_simples: expressao_simples MAIS termo •
-   42 termo: termo • ASTERISCO fator
-   43      | termo • DIV fator
+   36 lista_leituras: simb_leitura •
 
-    DIV        deslocar, e ir ao estado 73
-    ASTERISCO  deslocar, e ir ao estado 74
-
-    $padrão  reduzir usando a regra 39 (expressao_simples)
+    $padrão  reduzir usando a regra 36 (lista_leituras)
 
 
 Estado 84
 
-   40 expressao_simples: expressao_simples MENOS termo •
-   42 termo: termo • ASTERISCO fator
-   43      | termo • DIV fator
-
-    DIV        deslocar, e ir ao estado 73
-    ASTERISCO  deslocar, e ir ao estado 74
+   38 escrita: WRITE ABRE_PARENTESES lista_escritas • FECHA_PARENTESES
+   39 lista_escritas: lista_escritas • VIRGULA expressao_simples
 
-    $padrão  reduzir usando a regra 40 (expressao_simples)
+    FECHA_PARENTESES  deslocar, e ir ao estado 105
+    VIRGULA           deslocar, e ir ao estado 106
 
 
 Estado 85
 
-   43 termo: termo DIV fator •
+   40 lista_escritas: expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
 
-    $padrão  reduzir usando a regra 43 (termo)
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 40 (lista_escritas)
 
 
 Estado 86
 
-   42 termo: termo ASTERISCO fator •
+   23 comandos: comando PONTO_E_VIRGULA comandos •
 
-    $padrão  reduzir usando a regra 42 (termo)
+    $padrão  reduzir usando a regra 23 (comandos)
 
 
 Estado 87
 
-   52 comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo •
+   26 comando: numero DOIS_PONTOS comando_sem_rotulo •
+
+    $padrão  reduzir usando a regra 26 (comando)
+
+
+Estado 88
+
+   41 expressao: expressao • IGUAL expressao_simples
+   42          | expressao • DIFERENTE expressao_simples
+   43          | expressao • MENOR expressao_simples
+   44          | expressao • MENOR_IGUAL expressao_simples
+   45          | expressao • MAIOR expressao_simples
+   46          | expressao • MAIOR_IGUAL expressao_simples
+   61 comando_repetitivo: $@7 WHILE expressao • DO $@8 comando_sem_rotulo
+
+    DO           deslocar, e ir ao estado 107
+    IGUAL        deslocar, e ir ao estado 70
+    DIFERENTE    deslocar, e ir ao estado 71
+    MENOR_IGUAL  deslocar, e ir ao estado 72
+    MAIOR_IGUAL  deslocar, e ir ao estado 73
+    MENOR        deslocar, e ir ao estado 74
+    MAIOR        deslocar, e ir ao estado 75
+
+
+Estado 89
+
+   63 cond_else: ELSE comando_sem_rotulo •
+
+    $padrão  reduzir usando a regra 63 (cond_else)
+
+
+Estado 90
+
+   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo $@5 • PONTO_E_VIRGULA
+
+    PONTO_E_VIRGULA  deslocar, e ir ao estado 108
+
+
+Estado 91
+
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+   55 atribuicao: IDENT $@6 ATRIBUICAO expressao_simples •
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 55 (atribuicao)
+
+
+Estado 92
+
+   41 expressao: expressao IGUAL expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 41 (expressao)
+
+
+Estado 93
+
+   42 expressao: expressao DIFERENTE expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 42 (expressao)
+
+
+Estado 94
+
+   44 expressao: expressao MENOR_IGUAL expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 44 (expressao)
+
+
+Estado 95
+
+   46 expressao: expressao MAIOR_IGUAL expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 46 (expressao)
+
+
+Estado 96
+
+   43 expressao: expressao MENOR expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 43 (expressao)
+
+
+Estado 97
+
+   45 expressao: expressao MAIOR expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 45 (expressao)
+
+
+Estado 98
+
+   66 if_then: IF expressao $@9 THEN • comando_sem_rotulo
+
+    T_BEGIN  deslocar, e ir ao estado 27
+    IDENT    deslocar, e ir ao estado 32
+    IF       deslocar, e ir ao estado 33
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
+
+    $padrão  reduzir usando a regra 59 ($@7)
+
+    comando_composto     ir ao estado 37
+    comando_sem_rotulo   ir ao estado 109
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
+
+
+Estado 99
+
+   48 expressao_simples: expressao_simples MAIS termo •
+   51 termo: termo • ASTERISCO fator
+   52      | termo • DIV fator
+
+    DIV        deslocar, e ir ao estado 79
+    ASTERISCO  deslocar, e ir ao estado 80
+
+    $padrão  reduzir usando a regra 48 (expressao_simples)
+
+
+Estado 100
+
+   49 expressao_simples: expressao_simples MENOS termo •
+   51 termo: termo • ASTERISCO fator
+   52      | termo • DIV fator
+
+    DIV        deslocar, e ir ao estado 79
+    ASTERISCO  deslocar, e ir ao estado 80
+
+    $padrão  reduzir usando a regra 49 (expressao_simples)
+
+
+Estado 101
+
+   52 termo: termo DIV fator •
+
+    $padrão  reduzir usando a regra 52 (termo)
+
+
+Estado 102
+
+   51 termo: termo ASTERISCO fator •
+
+    $padrão  reduzir usando a regra 51 (termo)
+
+
+Estado 103
+
+   34 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES •
+
+    $padrão  reduzir usando a regra 34 (leitura)
+
+
+Estado 104
+
+   35 lista_leituras: lista_leituras VIRGULA • simb_leitura
+
+    IDENT  deslocar, e ir ao estado 81
+
+    simb_leitura  ir ao estado 110
+
+
+Estado 105
+
+   38 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES •
+
+    $padrão  reduzir usando a regra 38 (escrita)
+
+
+Estado 106
+
+   39 lista_escritas: lista_escritas VIRGULA • expressao_simples
+
+    IDENT   deslocar, e ir ao estado 52
+    NUMERO  deslocar, e ir ao estado 53
+
+    expressao_simples  ir ao estado 111
+    termo              ir ao estado 56
+    fator              ir ao estado 57
+
+
+Estado 107
+
+   61 comando_repetitivo: $@7 WHILE expressao DO • $@8 comando_sem_rotulo
+
+    $padrão  reduzir usando a regra 60 ($@8)
+
+    $@8  ir ao estado 112
+
+
+Estado 108
+
+   15 declara_var: $@4 lista_id_var DOIS_PONTOS tipo $@5 PONTO_E_VIRGULA •
+
+    $padrão  reduzir usando a regra 15 (declara_var)
+
+
+Estado 109
+
+   66 if_then: IF expressao $@9 THEN comando_sem_rotulo •
+
+    $padrão  reduzir usando a regra 66 (if_then)
+
+
+Estado 110
+
+   35 lista_leituras: lista_leituras VIRGULA simb_leitura •
+
+    $padrão  reduzir usando a regra 35 (lista_leituras)
+
+
+Estado 111
+
+   39 lista_escritas: lista_escritas VIRGULA expressao_simples •
+   48 expressao_simples: expressao_simples • MAIS termo
+   49                  | expressao_simples • MENOS termo
+
+    MAIS   deslocar, e ir ao estado 77
+    MENOS  deslocar, e ir ao estado 78
+
+    $padrão  reduzir usando a regra 39 (lista_escritas)
+
+
+Estado 112
+
+   61 comando_repetitivo: $@7 WHILE expressao DO $@8 • comando_sem_rotulo
+
+    T_BEGIN  deslocar, e ir ao estado 27
+    IDENT    deslocar, e ir ao estado 32
+    IF       deslocar, e ir ao estado 33
+    READ     deslocar, e ir ao estado 35
+    WRITE    deslocar, e ir ao estado 36
+
+    $padrão  reduzir usando a regra 59 ($@7)
+
+    comando_composto     ir ao estado 37
+    comando_sem_rotulo   ir ao estado 113
+    leitura              ir ao estado 41
+    escrita              ir ao estado 42
+    atribuicao           ir ao estado 43
+    comando_repetitivo   ir ao estado 45
+    $@7                  ir ao estado 46
+    comando_condicional  ir ao estado 47
+    if_then              ir ao estado 48
+
+
+Estado 113
+
+   61 comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo •
 
-    $padrão  reduzir usando a regra 52 (comando_repetitivo)
+    $padrão  reduzir usando a regra 61 (comando_repetitivo)
diff --git a/compilador.tab.c b/compilador.tab.c
index 7b59a3029417fc98d46221b812b26a122c80b52f..2a3cec53e37ff32fbb6e3275dad7521db752cf8b 100644
--- a/compilador.tab.c
+++ b/compilador.tab.c
@@ -156,38 +156,49 @@ enum yysymbol_kind_t
   YYSYMBOL_MENOS = 37,                     /* MENOS  */
   YYSYMBOL_ASTERISCO = 38,                 /* ASTERISCO  */
   YYSYMBOL_NUMERO = 39,                    /* NUMERO  */
-  YYSYMBOL_YYACCEPT = 40,                  /* $accept  */
-  YYSYMBOL_programa = 41,                  /* programa  */
-  YYSYMBOL_42_1 = 42,                      /* $@1  */
-  YYSYMBOL_bloco = 43,                     /* bloco  */
-  YYSYMBOL_44_2 = 44,                      /* $@2  */
-  YYSYMBOL_parte_declara_rotulos = 45,     /* parte_declara_rotulos  */
-  YYSYMBOL_parte_declara_vars = 46,        /* parte_declara_vars  */
-  YYSYMBOL_var = 47,                       /* var  */
-  YYSYMBOL_48_3 = 48,                      /* $@3  */
-  YYSYMBOL_declara_vars = 49,              /* declara_vars  */
-  YYSYMBOL_declara_var = 50,               /* declara_var  */
-  YYSYMBOL_51_4 = 51,                      /* $@4  */
-  YYSYMBOL_52_5 = 52,                      /* $@5  */
-  YYSYMBOL_tipo = 53,                      /* tipo  */
-  YYSYMBOL_lista_id_var = 54,              /* lista_id_var  */
-  YYSYMBOL_lista_idents = 55,              /* lista_idents  */
-  YYSYMBOL_parte_declara_subrotinas = 56,  /* parte_declara_subrotinas  */
-  YYSYMBOL_comando_composto = 57,          /* comando_composto  */
-  YYSYMBOL_comandos = 58,                  /* comandos  */
-  YYSYMBOL_comando = 59,                   /* comando  */
-  YYSYMBOL_comando_sem_rotulo = 60,        /* comando_sem_rotulo  */
-  YYSYMBOL_expressao = 61,                 /* expressao  */
-  YYSYMBOL_expressao_simples = 62,         /* expressao_simples  */
-  YYSYMBOL_termo = 63,                     /* termo  */
-  YYSYMBOL_atribuicao = 64,                /* atribuicao  */
-  YYSYMBOL_65_6 = 65,                      /* $@6  */
-  YYSYMBOL_fator = 66,                     /* fator  */
-  YYSYMBOL_numero = 67,                    /* numero  */
-  YYSYMBOL_comando_repetitivo = 68,        /* comando_repetitivo  */
-  YYSYMBOL_69_7 = 69,                      /* $@7  */
-  YYSYMBOL_70_8 = 70,                      /* $@8  */
-  YYSYMBOL_comando_condicional = 71        /* comando_condicional  */
+  YYSYMBOL_READ = 40,                      /* READ  */
+  YYSYMBOL_WRITE = 41,                     /* WRITE  */
+  YYSYMBOL_LOWER_THAN_ELSE = 42,           /* LOWER_THAN_ELSE  */
+  YYSYMBOL_YYACCEPT = 43,                  /* $accept  */
+  YYSYMBOL_programa = 44,                  /* programa  */
+  YYSYMBOL_45_1 = 45,                      /* $@1  */
+  YYSYMBOL_bloco = 46,                     /* bloco  */
+  YYSYMBOL_47_2 = 47,                      /* $@2  */
+  YYSYMBOL_parte_declara_rotulos = 48,     /* parte_declara_rotulos  */
+  YYSYMBOL_parte_declara_vars = 49,        /* parte_declara_vars  */
+  YYSYMBOL_var = 50,                       /* var  */
+  YYSYMBOL_51_3 = 51,                      /* $@3  */
+  YYSYMBOL_declara_vars = 52,              /* declara_vars  */
+  YYSYMBOL_declara_var = 53,               /* declara_var  */
+  YYSYMBOL_54_4 = 54,                      /* $@4  */
+  YYSYMBOL_55_5 = 55,                      /* $@5  */
+  YYSYMBOL_tipo = 56,                      /* tipo  */
+  YYSYMBOL_lista_id_var = 57,              /* lista_id_var  */
+  YYSYMBOL_lista_idents = 58,              /* lista_idents  */
+  YYSYMBOL_parte_declara_subrotinas = 59,  /* parte_declara_subrotinas  */
+  YYSYMBOL_comando_composto = 60,          /* comando_composto  */
+  YYSYMBOL_comandos = 61,                  /* comandos  */
+  YYSYMBOL_comando = 62,                   /* comando  */
+  YYSYMBOL_comando_sem_rotulo = 63,        /* comando_sem_rotulo  */
+  YYSYMBOL_leitura = 64,                   /* leitura  */
+  YYSYMBOL_lista_leituras = 65,            /* lista_leituras  */
+  YYSYMBOL_simb_leitura = 66,              /* simb_leitura  */
+  YYSYMBOL_escrita = 67,                   /* escrita  */
+  YYSYMBOL_lista_escritas = 68,            /* lista_escritas  */
+  YYSYMBOL_expressao = 69,                 /* expressao  */
+  YYSYMBOL_expressao_simples = 70,         /* expressao_simples  */
+  YYSYMBOL_termo = 71,                     /* termo  */
+  YYSYMBOL_atribuicao = 72,                /* atribuicao  */
+  YYSYMBOL_73_6 = 73,                      /* $@6  */
+  YYSYMBOL_fator = 74,                     /* fator  */
+  YYSYMBOL_numero = 75,                    /* numero  */
+  YYSYMBOL_comando_repetitivo = 76,        /* comando_repetitivo  */
+  YYSYMBOL_77_7 = 77,                      /* $@7  */
+  YYSYMBOL_78_8 = 78,                      /* $@8  */
+  YYSYMBOL_comando_condicional = 79,       /* comando_condicional  */
+  YYSYMBOL_cond_else = 80,                 /* cond_else  */
+  YYSYMBOL_if_then = 81,                   /* if_then  */
+  YYSYMBOL_82_9 = 82                       /* $@9  */
 };
 typedef enum yysymbol_kind_t yysymbol_kind_t;
 
@@ -515,19 +526,19 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  3
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   74
+#define YYLAST   94
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  40
+#define YYNTOKENS  43
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  32
+#define YYNNTS  40
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  54
+#define YYNRULES  67
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  88
+#define YYNSTATES  114
 
 /* YYMAXUTOK -- Last valid token kind.  */
-#define YYMAXUTOK   294
+#define YYMAXUTOK   297
 
 
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -570,19 +581,20 @@ static const yytype_int8 yytranslate[] =
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
-      35,    36,    37,    38,    39
+      35,    36,    37,    38,    39,    40,    41,    42
 };
 
 #if YYDEBUG
 /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
-static const yytype_uint8 yyrline[] =
+static const yytype_int16 yyrline[] =
 {
-       0,    38,    38,    38,    52,    49,    59,    60,    63,    67,
-      67,    68,    71,    72,    75,    78,    75,    86,    99,   105,
-     113,   114,   117,   121,   124,   125,   126,   129,   130,   133,
-     136,   137,   138,   141,   144,   147,   150,   153,   156,   159,
-     162,   165,   168,   171,   174,   177,   180,   180,   197,   208,
-     215,   217,   224,   217,   250
+       0,    41,    41,    41,    55,    52,    68,    69,    72,    76,
+      76,    77,    80,    81,    84,    87,    84,    95,   108,   114,
+     122,   123,   126,   130,   133,   134,   135,   138,   139,   142,
+     145,   146,   147,   148,   149,   152,   155,   156,   159,   168,
+     171,   174,   179,   182,   185,   188,   191,   194,   197,   200,
+     203,   206,   209,   212,   215,   218,   218,   235,   246,   253,
+     255,   262,   255,   288,   295,   297,   300,   300
 };
 #endif
 
@@ -604,13 +616,15 @@ static const char *const yytname[] =
   "LABEL", "TYPE", "ARRAY", "PROCEDURE", "FUNCTION", "GOTO", "IF", "THEN",
   "ELSE", "WHILE", "DO", "OR", "DIV", "AND", "NOT", "IGUAL", "DIFERENTE",
   "MENOR_IGUAL", "MAIOR_IGUAL", "MENOR", "MAIOR", "MAIS", "MENOS",
-  "ASTERISCO", "NUMERO", "$accept", "programa", "$@1", "bloco", "$@2",
-  "parte_declara_rotulos", "parte_declara_vars", "var", "$@3",
-  "declara_vars", "declara_var", "$@4", "$@5", "tipo", "lista_id_var",
-  "lista_idents", "parte_declara_subrotinas", "comando_composto",
-  "comandos", "comando", "comando_sem_rotulo", "expressao",
-  "expressao_simples", "termo", "atribuicao", "$@6", "fator", "numero",
-  "comando_repetitivo", "$@7", "$@8", "comando_condicional", YY_NULLPTR
+  "ASTERISCO", "NUMERO", "READ", "WRITE", "LOWER_THAN_ELSE", "$accept",
+  "programa", "$@1", "bloco", "$@2", "parte_declara_rotulos",
+  "parte_declara_vars", "var", "$@3", "declara_vars", "declara_var", "$@4",
+  "$@5", "tipo", "lista_id_var", "lista_idents",
+  "parte_declara_subrotinas", "comando_composto", "comandos", "comando",
+  "comando_sem_rotulo", "leitura", "lista_leituras", "simb_leitura",
+  "escrita", "lista_escritas", "expressao", "expressao_simples", "termo",
+  "atribuicao", "$@6", "fator", "numero", "comando_repetitivo", "$@7",
+  "$@8", "comando_condicional", "cond_else", "if_then", "$@9", YY_NULLPTR
 };
 
 static const char *
@@ -620,12 +634,12 @@ yysymbol_name (yysymbol_kind_t yysymbol)
 }
 #endif
 
-#define YYPACT_NINF (-48)
+#define YYPACT_NINF (-63)
 
 #define yypact_value_is_default(Yyn) \
   ((Yyn) == YYPACT_NINF)
 
-#define YYTABLE_NINF (-55)
+#define YYTABLE_NINF (-61)
 
 #define yytable_value_is_error(Yyn) \
   0
@@ -634,15 +648,18 @@ yysymbol_name (yysymbol_kind_t yysymbol)
    STATE-NUM.  */
 static const yytype_int8 yypact[] =
 {
-     -48,     9,    13,   -48,    12,    14,    18,   -48,     8,    36,
-      31,    30,   -48,    40,    38,    39,   -48,   -48,   -48,   -48,
-      41,   -48,   -48,    42,    35,   -48,    37,    -7,   -48,   -48,
-     -48,     4,   -48,   -48,   -48,    43,    44,   -48,   -48,    47,
-     -48,    32,   -48,    45,    46,    48,   -48,    -7,    -2,   -11,
-     -48,   -48,   -48,   -11,   -48,   -48,   -48,   -48,     5,   -10,
-     -23,   -48,    50,   -10,   -48,   -11,   -11,   -11,   -11,   -11,
-     -11,   -11,   -11,   -11,   -11,   -48,    -2,   -10,   -10,   -10,
-     -10,   -10,   -10,   -23,   -23,   -48,   -48,   -48
+     -63,     5,     7,   -63,    15,    35,    20,   -63,     3,    42,
+      38,    40,   -63,    50,    56,    57,   -63,   -63,   -63,   -63,
+      54,   -63,   -63,    58,    59,   -63,    60,    13,   -63,   -63,
+     -63,    -2,   -63,   -10,   -63,    65,    66,   -63,    63,    64,
+     -63,   -63,   -63,   -63,    67,   -63,    52,   -63,    55,    68,
+      69,    70,   -63,   -63,    29,   -17,   -20,   -63,    72,   -10,
+     -63,    13,    17,   -10,    17,   -63,   -63,   -63,   -63,   -10,
+     -10,   -10,   -10,   -10,   -10,   -10,    61,   -10,   -10,   -10,
+     -10,   -63,    16,   -63,    19,   -17,   -63,   -63,    10,   -63,
+      73,   -17,   -17,   -17,   -17,   -17,   -17,   -17,    17,   -20,
+     -20,   -63,   -63,   -63,    72,   -63,   -10,   -63,   -63,   -63,
+     -63,   -17,    17,   -63
 };
 
 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -653,30 +670,33 @@ static const yytype_int8 yydefact[] =
        2,     0,     0,     1,     0,     0,     0,    21,     0,     0,
        0,     7,    20,     0,     0,     9,     6,     3,    22,     8,
        0,     4,    14,     0,    10,    13,     0,    26,     5,    12,
-      19,     0,    46,    50,    30,     0,     0,    28,    29,     0,
-      32,     0,    31,     0,     0,     0,    23,    25,    51,     0,
-      18,    17,    15,     0,    24,    27,    48,    49,     0,    39,
-      42,    45,     0,    47,    52,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    16,    51,    33,    34,    36,
-      38,    35,    37,    40,    41,    44,    43,    53
+      19,     0,    55,     0,    59,     0,     0,    30,     0,     0,
+      28,    33,    34,    29,     0,    32,     0,    31,    65,     0,
+       0,     0,    57,    58,    66,    48,    51,    54,     0,     0,
+      23,    25,    60,     0,    60,    63,    18,    17,    15,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,    38,     0,    37,     0,    41,    24,    27,     0,    64,
+       0,    56,    42,    43,    45,    47,    44,    46,    60,    49,
+      50,    53,    52,    35,     0,    39,     0,    61,    16,    67,
+      36,    40,    60,    62
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-     -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
-      49,   -48,   -48,   -48,   -48,   -48,   -48,    51,    16,   -48,
-     -47,   -48,   -46,   -38,   -48,   -48,   -32,   -48,   -48,   -48,
-     -48,   -48
+     -63,   -63,   -63,   -63,   -63,   -63,   -63,   -63,   -63,   -63,
+      53,   -63,   -63,   -63,   -63,   -63,   -63,    71,    18,   -63,
+     -62,   -63,   -63,   -18,   -63,   -63,    24,   -58,   -46,   -63,
+     -63,   -33,   -63,   -63,   -63,   -63,   -63,   -63,   -63,   -63
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
        0,     1,     2,    14,    23,    15,    18,    19,    20,    24,
-      25,    26,    62,    52,    31,     8,    21,    34,    35,    36,
-      37,    58,    59,    60,    38,    45,    61,    39,    40,    41,
-      76,    42
+      25,    26,    90,    68,    31,     8,    21,    37,    38,    39,
+      40,    41,    82,    83,    42,    84,    54,    55,    56,    43,
+      51,    57,    44,    45,    46,   112,    47,    65,    48,    76
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -684,52 +704,60 @@ static const yytype_int8 yydefgoto[] =
    number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int8 yytable[] =
 {
-     -54,    55,    56,    27,    73,   -54,    32,    63,    27,     3,
-      43,    32,    44,     9,    10,    74,     4,   -51,     6,    77,
-      78,    79,    80,    81,    82,     5,    71,    72,    57,    87,
-      64,     7,    33,    83,    84,    65,    66,    67,    68,    69,
-      70,    85,    86,    11,    12,    13,    16,    17,   -14,   -11,
-      30,    47,    27,    22,    46,    48,    49,    75,    50,    51,
-       0,     0,    53,    54,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,    29,    28
+      87,    85,    89,    52,    49,     3,    50,    79,     9,    10,
+       4,    91,    92,    93,    94,    95,    96,    97,    80,    77,
+      78,   103,   104,    27,   105,   106,    32,    27,     5,    53,
+      32,    99,   100,     7,    33,   107,   109,   -60,    33,     6,
+      70,    71,    72,    73,    74,    75,   101,   102,   111,    11,
+     113,    12,    34,    35,    36,    13,    16,    35,    36,    70,
+      71,    72,    73,    74,    75,    17,    22,   -11,    27,    58,
+      59,    61,   -14,    30,    60,    62,    63,    29,    64,    86,
+     108,    66,    67,    98,    69,    81,   110,    88,     0,     0,
+       0,     0,     0,     0,    28
 };
 
 static const yytype_int8 yycheck[] =
 {
-       7,    48,    13,    10,    27,     7,    13,    53,    10,     0,
-       6,    13,     8,     5,     6,    38,     3,    24,     4,    65,
-      66,    67,    68,    69,    70,    13,    36,    37,    39,    76,
-      25,    13,    39,    71,    72,    30,    31,    32,    33,    34,
-      35,    73,    74,     7,    13,    15,     6,     9,    13,    10,
-      13,     7,    10,    12,    11,     8,    24,     7,    13,    13,
-      -1,    -1,    14,    47,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    24,    23
+      62,    59,    64,    13,     6,     0,     8,    27,     5,     6,
+       3,    69,    70,    71,    72,    73,    74,    75,    38,    36,
+      37,     5,     6,    10,     5,     6,    13,    10,    13,    39,
+      13,    77,    78,    13,    21,    25,    98,    24,    21,     4,
+      30,    31,    32,    33,    34,    35,    79,    80,   106,     7,
+     112,    13,    39,    40,    41,    15,     6,    40,    41,    30,
+      31,    32,    33,    34,    35,     9,    12,    10,    10,     4,
+       4,     7,    13,    13,    11,     8,    24,    24,    23,    61,
+       7,    13,    13,    22,    14,    13,   104,    63,    -1,    -1,
+      -1,    -1,    -1,    -1,    23
 };
 
 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
    state STATE-NUM.  */
 static const yytype_int8 yystos[] =
 {
-       0,    41,    42,     0,     3,    13,     4,    13,    55,     5,
-       6,     7,    13,    15,    43,    45,     6,     9,    46,    47,
-      48,    56,    12,    44,    49,    50,    51,    10,    57,    50,
-      13,    54,    13,    39,    57,    58,    59,    60,    64,    67,
-      68,    69,    71,     6,     8,    65,    11,     7,     8,    24,
-      13,    13,    53,    14,    58,    60,    13,    39,    61,    62,
-      63,    66,    52,    62,    25,    30,    31,    32,    33,    34,
-      35,    36,    37,    27,    38,     7,    70,    62,    62,    62,
-      62,    62,    62,    63,    63,    66,    66,    60
+       0,    44,    45,     0,     3,    13,     4,    13,    58,     5,
+       6,     7,    13,    15,    46,    48,     6,     9,    49,    50,
+      51,    59,    12,    47,    52,    53,    54,    10,    60,    53,
+      13,    57,    13,    21,    39,    40,    41,    60,    61,    62,
+      63,    64,    67,    72,    75,    76,    77,    79,    81,     6,
+       8,    73,    13,    39,    69,    70,    71,    74,     4,     4,
+      11,     7,     8,    24,    23,    80,    13,    13,    56,    14,
+      30,    31,    32,    33,    34,    35,    82,    36,    37,    27,
+      38,    13,    65,    66,    68,    70,    61,    63,    69,    63,
+      55,    70,    70,    70,    70,    70,    70,    70,    22,    71,
+      71,    74,    74,     5,     6,     5,     6,    25,     7,    63,
+      66,    70,    78,    63
 };
 
 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
 static const yytype_int8 yyr1[] =
 {
-       0,    40,    42,    41,    44,    43,    45,    45,    46,    48,
-      47,    47,    49,    49,    51,    52,    50,    53,    54,    54,
-      55,    55,    56,    57,    58,    58,    58,    59,    59,    60,
-      60,    60,    60,    61,    61,    61,    61,    61,    61,    61,
-      62,    62,    62,    63,    63,    63,    65,    64,    66,    66,
-      67,    69,    70,    68,    71
+       0,    43,    45,    44,    47,    46,    48,    48,    49,    51,
+      50,    50,    52,    52,    54,    55,    53,    56,    57,    57,
+      58,    58,    59,    60,    61,    61,    61,    62,    62,    63,
+      63,    63,    63,    63,    63,    64,    65,    65,    66,    67,
+      68,    68,    69,    69,    69,    69,    69,    69,    69,    70,
+      70,    70,    71,    71,    71,    73,    72,    74,    74,    75,
+      77,    78,    76,    79,    80,    80,    82,    81
 };
 
 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
@@ -738,9 +766,10 @@ static const yytype_int8 yyr2[] =
        0,     2,     0,     9,     0,     5,     2,     0,     1,     0,
        3,     0,     2,     1,     0,     0,     6,     1,     3,     1,
        3,     1,     0,     3,     3,     2,     0,     3,     1,     1,
-       1,     1,     1,     3,     3,     3,     3,     3,     3,     1,
-       3,     3,     1,     3,     3,     1,     0,     4,     1,     1,
-       1,     0,     0,     6,     0
+       1,     1,     1,     1,     1,     4,     3,     1,     1,     4,
+       3,     1,     3,     3,     3,     3,     3,     3,     1,     3,
+       3,     1,     3,     3,     1,     0,     4,     1,     1,     1,
+       0,     0,     6,     2,     2,     0,     0,     5
 };
 
 
@@ -1204,52 +1233,64 @@ yyreduce:
   switch (yyn)
     {
   case 2: /* $@1: %empty  */
-#line 38 "compilador.y"
+#line 41 "compilador.y"
              {
              geraCodigo (NULL, "INPP");
              }
-#line 1212 "compilador.tab.c"
+#line 1241 "compilador.tab.c"
     break;
 
   case 3: /* programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO  */
-#line 43 "compilador.y"
+#line 46 "compilador.y"
                          {
              geraCodigo (NULL, "PARA");
              }
-#line 1220 "compilador.tab.c"
+#line 1249 "compilador.tab.c"
     break;
 
   case 4: /* $@2: %empty  */
-#line 52 "compilador.y"
+#line 55 "compilador.y"
               {
               }
-#line 1227 "compilador.tab.c"
+#line 1256 "compilador.tab.c"
+    break;
+
+  case 5: /* bloco: parte_declara_rotulos parte_declara_vars parte_declara_subrotinas $@2 comando_composto  */
+#line 58 "compilador.y"
+                               {
+               retira(desloc,ts);
+               char buffer[50];
+               sprintf(buffer,"DMEM %d",desloc);
+               geraCodigo(NULL,buffer);
+               desloc = 0;
+              }
+#line 1268 "compilador.tab.c"
     break;
 
   case 9: /* $@3: %empty  */
-#line 67 "compilador.y"
+#line 76 "compilador.y"
               { }
-#line 1233 "compilador.tab.c"
+#line 1274 "compilador.tab.c"
     break;
 
   case 14: /* $@4: %empty  */
-#line 75 "compilador.y"
+#line 84 "compilador.y"
               { num_vars = 0; }
-#line 1239 "compilador.tab.c"
+#line 1280 "compilador.tab.c"
     break;
 
   case 15: /* $@5: %empty  */
-#line 78 "compilador.y"
+#line 87 "compilador.y"
               { /* AMEM num_vars */
                char buffer[50];
                sprintf(buffer, "AMEM %d", num_vars);
                geraCodigo(NULL, buffer);
               }
-#line 1249 "compilador.tab.c"
+#line 1290 "compilador.tab.c"
     break;
 
   case 17: /* tipo: IDENT  */
-#line 87 "compilador.y"
+#line 96 "compilador.y"
                {
                 if (strcmp(token, "integer") == 0) {
                     atualiza_tipo(num_vars, INTEIRO, ts);
@@ -1260,112 +1301,140 @@ yyreduce:
                 }
                 mostra_ts(ts); // Mostra a tabela após a inserção
                }
-#line 1264 "compilador.tab.c"
+#line 1305 "compilador.tab.c"
     break;
 
   case 18: /* lista_id_var: lista_id_var VIRGULA IDENT  */
-#line 100 "compilador.y"
+#line 109 "compilador.y"
               { /* insere �ltima vars na tabela de s�mbolos */ 
                num_vars += 1;
                insere_ts(token,VS,nivel_lexico,NSEI,desloc,ts);
                desloc += 1;
               }
-#line 1274 "compilador.tab.c"
+#line 1315 "compilador.tab.c"
     break;
 
   case 19: /* lista_id_var: IDENT  */
-#line 105 "compilador.y"
+#line 114 "compilador.y"
                     { 
                num_vars += 1;
                insere_ts(token,VS,nivel_lexico,NSEI,desloc,ts);
                desloc += 1;
                /* insere vars na tabela de s�mbolos */
             }
-#line 1285 "compilador.tab.c"
+#line 1326 "compilador.tab.c"
+    break;
+
+  case 38: /* simb_leitura: IDENT  */
+#line 159 "compilador.y"
+                    {
+               geraCodigo(NULL, "LEIT");
+               l_elem = busca(token,ts);
+               char buffer[50];
+               sprintf(buffer,"ARMZ %d,%d",l_elem->nivel,l_elem->desloc);
+               geraCodigo(NULL,buffer);
+            }
+#line 1338 "compilador.tab.c"
+    break;
+
+  case 40: /* lista_escritas: lista_escritas VIRGULA expressao_simples  */
+#line 171 "compilador.y"
+                                                         {
+               geraCodigo(NULL,"IMPR");
+            }
+#line 1346 "compilador.tab.c"
     break;
 
-  case 33: /* expressao: expressao IGUAL expressao_simples  */
-#line 141 "compilador.y"
+  case 41: /* lista_escritas: expressao_simples  */
+#line 174 "compilador.y"
+                                {
+               geraCodigo(NULL,"IMPR");
+            }
+#line 1354 "compilador.tab.c"
+    break;
+
+  case 42: /* expressao: expressao IGUAL expressao_simples  */
+#line 179 "compilador.y"
                                              {
             geraCodigo(NULL, "CMIG"); // Adiciona operação de cmig
          }
-#line 1293 "compilador.tab.c"
+#line 1362 "compilador.tab.c"
     break;
 
-  case 34: /* expressao: expressao DIFERENTE expressao_simples  */
-#line 144 "compilador.y"
+  case 43: /* expressao: expressao DIFERENTE expressao_simples  */
+#line 182 "compilador.y"
                                                 {
             geraCodigo(NULL, "CMDG"); // Adiciona operação de cmdg
          }
-#line 1301 "compilador.tab.c"
+#line 1370 "compilador.tab.c"
     break;
 
-  case 35: /* expressao: expressao MENOR expressao_simples  */
-#line 147 "compilador.y"
+  case 44: /* expressao: expressao MENOR expressao_simples  */
+#line 185 "compilador.y"
                                              {
             geraCodigo(NULL, "CMME"); // Adiciona operação de cmme
          }
-#line 1309 "compilador.tab.c"
+#line 1378 "compilador.tab.c"
     break;
 
-  case 36: /* expressao: expressao MENOR_IGUAL expressao_simples  */
-#line 150 "compilador.y"
+  case 45: /* expressao: expressao MENOR_IGUAL expressao_simples  */
+#line 188 "compilador.y"
                                                    {
             geraCodigo(NULL, "CMEG"); // Adiciona operação de cmeg
          }
-#line 1317 "compilador.tab.c"
+#line 1386 "compilador.tab.c"
     break;
 
-  case 37: /* expressao: expressao MAIOR expressao_simples  */
-#line 153 "compilador.y"
+  case 46: /* expressao: expressao MAIOR expressao_simples  */
+#line 191 "compilador.y"
                                              {
             geraCodigo(NULL, "CMMA"); // Adiciona operação de cmma
          }
-#line 1325 "compilador.tab.c"
+#line 1394 "compilador.tab.c"
     break;
 
-  case 38: /* expressao: expressao MAIOR_IGUAL expressao_simples  */
-#line 156 "compilador.y"
+  case 47: /* expressao: expressao MAIOR_IGUAL expressao_simples  */
+#line 194 "compilador.y"
                                                    {
             geraCodigo(NULL, "CMAG"); // Adiciona operação de cmag
          }
-#line 1333 "compilador.tab.c"
+#line 1402 "compilador.tab.c"
     break;
 
-  case 40: /* expressao_simples: expressao_simples MAIS termo  */
-#line 162 "compilador.y"
+  case 49: /* expressao_simples: expressao_simples MAIS termo  */
+#line 200 "compilador.y"
                                                 {
                geraCodigo(NULL, "SOMA"); // Adiciona operação de soma
             }
-#line 1341 "compilador.tab.c"
+#line 1410 "compilador.tab.c"
     break;
 
-  case 41: /* expressao_simples: expressao_simples MENOS termo  */
-#line 165 "compilador.y"
+  case 50: /* expressao_simples: expressao_simples MENOS termo  */
+#line 203 "compilador.y"
                                             {
                geraCodigo(NULL, "SUBT"); // Adiciona operação de subt
             }
-#line 1349 "compilador.tab.c"
+#line 1418 "compilador.tab.c"
     break;
 
-  case 43: /* termo: termo ASTERISCO fator  */
-#line 171 "compilador.y"
+  case 52: /* termo: termo ASTERISCO fator  */
+#line 209 "compilador.y"
                              {
                geraCodigo(NULL, "MULT"); // Adiciona operação de mult
             }
-#line 1357 "compilador.tab.c"
+#line 1426 "compilador.tab.c"
     break;
 
-  case 44: /* termo: termo DIV fator  */
-#line 174 "compilador.y"
+  case 53: /* termo: termo DIV fator  */
+#line 212 "compilador.y"
                               {
                geraCodigo(NULL, "DIVI"); // Adiciona operação de divi
             }
-#line 1365 "compilador.tab.c"
+#line 1434 "compilador.tab.c"
     break;
 
-  case 46: /* $@6: %empty  */
-#line 180 "compilador.y"
+  case 55: /* $@6: %empty  */
+#line 218 "compilador.y"
                   {
     // Busca variável no lado esquerdo
     l_elem = busca(token, ts);
@@ -1376,22 +1445,22 @@ yyreduce:
         destino_desloc = l_elem->desloc;
     }
 }
-#line 1380 "compilador.tab.c"
+#line 1449 "compilador.tab.c"
     break;
 
-  case 47: /* atribuicao: IDENT $@6 ATRIBUICAO expressao_simples  */
-#line 189 "compilador.y"
+  case 56: /* atribuicao: IDENT $@6 ATRIBUICAO expressao_simples  */
+#line 227 "compilador.y"
                                {
     // Gera código ARMZ para armazenar valor
     char buffer[50];
     sprintf(buffer, "ARMZ %d,%d", destino_nivel, destino_desloc);
     geraCodigo(NULL, buffer);
 }
-#line 1391 "compilador.tab.c"
+#line 1460 "compilador.tab.c"
     break;
 
-  case 48: /* fator: IDENT  */
-#line 197 "compilador.y"
+  case 57: /* fator: IDENT  */
+#line 235 "compilador.y"
              {
     // Carrega variável
     l_elem = busca(token, ts);
@@ -1403,22 +1472,22 @@ yyreduce:
         geraCodigo(NULL, buffer);
     }
 }
-#line 1407 "compilador.tab.c"
+#line 1476 "compilador.tab.c"
     break;
 
-  case 49: /* fator: NUMERO  */
-#line 208 "compilador.y"
+  case 58: /* fator: NUMERO  */
+#line 246 "compilador.y"
          {
     // Empilha constante
     char buffer[50];
     sprintf(buffer, "CRCT %s", token);
     geraCodigo(NULL, buffer);
 }
-#line 1418 "compilador.tab.c"
+#line 1487 "compilador.tab.c"
     break;
 
-  case 51: /* $@7: %empty  */
-#line 217 "compilador.y"
+  case 60: /* $@7: %empty  */
+#line 255 "compilador.y"
                     {
                char r_ini[4];
                sprintf(r_ini, "R%02d", rot_id);
@@ -1426,11 +1495,11 @@ yyreduce:
                rot_id += 1;
                geraCodigo(r_ini,"NADA");
             }
-#line 1430 "compilador.tab.c"
+#line 1499 "compilador.tab.c"
     break;
 
-  case 52: /* $@8: %empty  */
-#line 224 "compilador.y"
+  case 61: /* $@8: %empty  */
+#line 262 "compilador.y"
                                {
                char r_fim[4];
                sprintf(r_fim, "R%02d", rot_id);
@@ -1441,11 +1510,11 @@ yyreduce:
                strcat(buffer,r_fim);
                geraCodigo(NULL,buffer);
             }
-#line 1445 "compilador.tab.c"
+#line 1514 "compilador.tab.c"
     break;
 
-  case 53: /* comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo  */
-#line 234 "compilador.y"
+  case 62: /* comando_repetitivo: $@7 WHILE expressao DO $@8 comando_sem_rotulo  */
+#line 272 "compilador.y"
                                {
                char r_ini[4];
                char r_fim[4];
@@ -1460,11 +1529,60 @@ yyreduce:
 
                geraCodigo(r_fim,"NADA");
             }
-#line 1464 "compilador.tab.c"
+#line 1533 "compilador.tab.c"
+    break;
+
+  case 63: /* comando_condicional: if_then cond_else  */
+#line 288 "compilador.y"
+                                       {
+               char r_fim[4];
+               desempilha(r_fim,rot);
+               geraCodigo(r_fim,"NADA");
+            }
+#line 1543 "compilador.tab.c"
+    break;
+
+  case 66: /* $@9: %empty  */
+#line 300 "compilador.y"
+                      {
+               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;
+            }
+#line 1563 "compilador.tab.c"
+    break;
+
+  case 67: /* if_then: IF expressao $@9 THEN comando_sem_rotulo  */
+#line 315 "compilador.y"
+                                    {
+               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");
+            }
+#line 1582 "compilador.tab.c"
     break;
 
 
-#line 1468 "compilador.tab.c"
+#line 1586 "compilador.tab.c"
 
       default: break;
     }
@@ -1657,7 +1775,7 @@ yyreturnlab:
   return yyresult;
 }
 
-#line 254 "compilador.y"
+#line 332 "compilador.y"
 
 
 int main (int argc, char** argv) {
diff --git a/compilador.tab.h b/compilador.tab.h
index a923641c134b7ca9e6081a0e3259125e49d4bbc8..98da8d5548661fb0b6d86e8b8eea643b72be70af 100644
--- a/compilador.tab.h
+++ b/compilador.tab.h
@@ -90,7 +90,10 @@ extern int yydebug;
     MAIS = 291,                    /* MAIS  */
     MENOS = 292,                   /* MENOS  */
     ASTERISCO = 293,               /* ASTERISCO  */
-    NUMERO = 294                   /* NUMERO  */
+    NUMERO = 294,                  /* NUMERO  */
+    READ = 295,                    /* READ  */
+    WRITE = 296,                   /* WRITE  */
+    LOWER_THAN_ELSE = 297          /* LOWER_THAN_ELSE  */
   };
   typedef enum yytokentype yytoken_kind_t;
 #endif
diff --git a/compilador.y b/compilador.y
index 76707a455c62ad9dc7d8fbc39f204c66c8c24136..1eb9e035ed84fca88bbdeff1308364df2ff3df12 100644
--- a/compilador.y
+++ b/compilador.y
@@ -31,7 +31,10 @@ stack_t *rot;
 %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
+%token ASTERISCO NUMERO READ WRITE
+
+%nonassoc LOWER_THAN_ELSE
+%nonassoc ELSE
 
 %%
 
@@ -52,7 +55,13 @@ bloco       :
               {
               }
 
-              comando_composto
+              comando_composto {
+               retira(desloc,ts);
+               char buffer[50];
+               sprintf(buffer,"DMEM %d",desloc);
+               geraCodigo(NULL,buffer);
+               desloc = 0;
+              }
               ;
 
 
@@ -136,6 +145,35 @@ comando_sem_rotulo: atribuicao
             | comando_composto
             | comando_condicional
             | comando_repetitivo
+            | leitura
+            | escrita
+;
+
+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->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 {
@@ -247,10 +285,19 @@ comando_repetitivo: {
             }
 ;
 
-comando_condicional: if_then elses
+comando_condicional: if_then cond_else {
+               char r_fim[4];
+               desempilha(r_fim,rot);
+               geraCodigo(r_fim,"NADA");
+            }
 ;
 
-if_then: IF expressao THEN {
+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);
@@ -265,14 +312,23 @@ if_then: IF expressao THEN {
                empilha(r_fim, rot);
                rot_id += 1;
             }
-            comando_sem_rotulo {
+            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);
 
-elses: ELSE comando_sem_rotulo elses
-            |
+               geraCodigo(r_else,"NADA");
+            }
 ;
 
+
 %%
 
 int main (int argc, char** argv) {
diff --git a/lex.yy.c b/lex.yy.c
index e52d3a6d9f27bc51c1923355416c30b423604eca..ef6ad0e7b67a03c550188319338cd3adac742a1f 100644
--- a/lex.yy.c
+++ b/lex.yy.c
@@ -351,8 +351,8 @@ static void yynoreturn yy_fatal_error ( const char* msg  );
 	(yy_hold_char) = *yy_cp; \
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 41
-#define YY_END_OF_BUFFER 42
+#define YY_NUM_RULES 43
+#define YY_END_OF_BUFFER 44
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -360,20 +360,21 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[107] =
+static const flex_int16_t yy_accept[115] =
     {   0,
-        0,    0,   42,   41,    2,    1,   13,   14,   38,   36,
-       11,   37,   12,   39,   10,    9,   34,   30,   35,   40,
-       40,   40,   40,   40,   40,   40,   40,   40,   40,   40,
-       40,   40,   40,   40,    2,    0,   39,    8,   32,   31,
-       33,   40,   40,   40,   40,   40,   25,   40,   40,   40,
-       40,   21,   40,   40,   26,   40,   40,   40,   40,   40,
-        0,    0,   28,   40,   40,   27,   40,    7,   40,   40,
-       40,   29,   40,   40,   40,    5,   40,    3,   40,   40,
-       23,   40,   20,   40,   40,   40,   22,   16,   40,   17,
-        6,   40,   15,   40,   40,   24,   40,   40,   40,   40,
-
-       40,    4,   19,   40,   18,    0
+        0,    0,   44,   43,    2,    1,   15,   16,   40,   38,
+       13,   39,   14,   41,   12,   11,   36,   32,   37,   42,
+       42,   42,   42,   42,   42,   42,   42,   42,   42,   42,
+       42,   42,   42,   42,   42,    2,    0,   41,   10,   34,
+       33,   35,   42,   42,   42,   42,   42,   27,   42,   42,
+       42,   42,   23,   42,   42,   28,   42,   42,   42,   42,
+       42,   42,   42,    0,    0,   30,   42,   42,   29,   42,
+        7,   42,   42,   42,   31,   42,   42,   42,   42,    5,
+       42,   42,    3,   42,   42,   25,   42,   22,   42,   42,
+       42,    8,   24,   18,   42,   42,   19,    6,   42,   17,
+
+       42,   42,   26,    9,   42,   42,   42,   42,   42,    4,
+       21,   42,   20,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -416,78 +417,82 @@ static const YY_CHAR yy_meta[39] =
         3,    3,    3,    3,    3,    3,    3,    3
     } ;
 
-static const flex_int16_t yy_base[109] =
+static const flex_int16_t yy_base[117] =
     {   0,
-        0,    0,  116,  117,  113,  117,  108,  117,  117,  117,
-      117,  117,  117,  102,   97,  117,   24,  117,   96,    0,
-       12,   88,   16,   16,   74,   78,   84,   88,   75,   72,
-       71,   22,   84,   76,   98,   93,   87,  117,  117,  117,
-      117,    0,   76,   64,   71,   58,    0,   60,   71,   62,
-       56,    0,   70,   54,    0,   57,   64,   54,   52,   57,
-       76,   43,    0,   63,   54,    0,   57,    0,   58,   47,
-       54,    0,   30,   46,   52,    0,   46,   66,   33,   41,
-        0,   35,    0,   41,   45,   34,    0,    0,   43,    0,
-        0,   38,    0,   41,   41,    0,   28,   22,   28,   26,
-
-       21,    0,    0,   30,    0,  117,   48,   60
+        0,    0,  123,  124,  120,  124,  115,  124,  124,  124,
+      124,  124,  124,  109,  104,  124,   24,  124,  103,    0,
+       12,   95,   16,   16,   81,   85,   91,   95,   82,   79,
+       78,   87,   22,   90,   23,  105,  100,   94,  124,  124,
+      124,  124,    0,   83,   71,   78,   65,    0,   67,   78,
+       69,   63,    0,   77,   61,    0,   64,   75,   70,   60,
+       58,   63,   62,   81,   44,    0,   68,   59,    0,   62,
+        0,   63,   52,   59,    0,   32,   59,   50,   56,    0,
+       50,   42,   69,   36,   44,    0,   38,    0,   44,   48,
+       37,    0,    0,    0,   46,   45,    0,    0,   40,    0,
+
+       44,   46,    0,    0,   32,   24,   30,   28,   22,    0,
+        0,   31,    0,  124,   48,   60
     } ;
 
-static const flex_int16_t yy_def[109] =
+static const flex_int16_t yy_def[117] =
     {   0,
-      106,    1,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  107,
-      107,  107,  107,  107,  107,  107,  107,  107,  107,  107,
-      107,  107,  107,  107,  106,  108,  106,  106,  106,  106,
-      106,  107,  107,  107,  107,  107,  107,  107,  107,  107,
-      107,  107,  107,  107,  107,  107,  107,  107,  107,  107,
-      108,  108,  107,  107,  107,  107,  107,  107,  107,  107,
-      107,  107,  107,  107,  107,  107,  107,  108,  107,  107,
-      107,  107,  107,  107,  107,  107,  107,  107,  107,  107,
-      107,  107,  107,  107,  107,  107,  107,  107,  107,  107,
-
-      107,  107,  107,  107,  107,    0,  106,  106
+      114,    1,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  114,  116,  114,  114,  114,
+      114,  114,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  116,  116,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  116,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+
+      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
+      115,  115,  115,    0,  114,  114
     } ;
 
-static const flex_int16_t yy_nxt[156] =
+static const flex_int16_t yy_nxt[163] =
     {   0,
         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
        14,   15,   16,   17,   18,   19,   20,   21,   22,   20,
        23,   24,   25,   26,   20,   27,   28,   20,   29,   30,
-       31,   20,   20,   32,   20,   33,   34,   20,   39,   40,
-       43,   46,   48,   44,   49,   47,   57,   78,   62,   85,
-       42,  105,  104,   86,  103,  102,  101,  100,   99,   58,
-       61,   98,   61,   97,   96,   95,   94,   93,   92,   91,
-       90,   62,   89,   88,   87,   84,   83,   82,   81,   80,
-       79,   62,   77,   76,   75,   74,   73,   72,   71,   70,
-       69,   68,   67,   66,   65,   64,   63,   37,   62,   35,
-
-       60,   59,   56,   55,   54,   53,   52,   51,   50,   45,
-       41,   38,   37,   36,   35,  106,    3,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106
+       31,   32,   20,   33,   20,   34,   35,   20,   40,   41,
+       44,   47,   49,   45,   50,   48,   59,   62,   83,   65,
+       43,   90,  113,  112,   63,   91,  111,  110,  109,   60,
+       64,  108,   64,  107,  106,  105,  104,  103,  102,  101,
+      100,   99,   98,   97,   65,   96,   95,   94,   93,   92,
+       89,   88,   87,   86,   85,   84,   65,   82,   81,   80,
+       79,   78,   77,   76,   75,   74,   73,   72,   71,   70,
+
+       69,   68,   67,   66,   38,   65,   36,   61,   58,   57,
+       56,   55,   54,   53,   52,   51,   46,   42,   39,   38,
+       37,   36,  114,    3,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114
     } ;
 
-static const flex_int16_t yy_chk[156] =
+static const flex_int16_t yy_chk[163] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,   17,   17,
-       21,   23,   24,   21,   24,   23,   32,   62,   62,   73,
-      107,  104,  101,   73,  100,   99,   98,   97,   95,   32,
-      108,   94,  108,   92,   89,   86,   85,   84,   82,   80,
-       79,   78,   77,   75,   74,   71,   70,   69,   67,   65,
-       64,   61,   60,   59,   58,   57,   56,   54,   53,   51,
-       50,   49,   48,   46,   45,   44,   43,   37,   36,   35,
-
-       34,   33,   31,   30,   29,   28,   27,   26,   25,   22,
-       19,   15,   14,    7,    5,    3,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106
+       21,   23,   24,   21,   24,   23,   33,   35,   65,   65,
+      115,   76,  112,  109,   35,   76,  108,  107,  106,   33,
+      116,  105,  116,  102,  101,   99,   96,   95,   91,   90,
+       89,   87,   85,   84,   83,   82,   81,   79,   78,   77,
+       74,   73,   72,   70,   68,   67,   64,   63,   62,   61,
+       60,   59,   58,   57,   55,   54,   52,   51,   50,   49,
+
+       47,   46,   45,   44,   38,   37,   36,   34,   32,   31,
+       30,   29,   28,   27,   26,   25,   22,   19,   15,   14,
+        7,    5,    3,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
+      114,  114
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -531,8 +536,8 @@ char *yytext;
 
 int nl = 1;
 
-#line 535 "lex.yy.c"
-#line 536 "lex.yy.c"
+#line 540 "lex.yy.c"
+#line 541 "lex.yy.c"
 
 #define INITIAL 0
 
@@ -752,7 +757,7 @@ YY_DECL
 #line 41 "compilador.l"
 
 
-#line 756 "lex.yy.c"
+#line 761 "lex.yy.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -779,13 +784,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 107 )
+				if ( yy_current_state >= 115 )
 					yy_c = yy_meta[yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 117 );
+		while ( yy_base[yy_current_state] != 124 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -864,306 +869,324 @@ YY_RULE_SETUP
 case 8:
 YY_RULE_SETUP
 #line 73 "compilador.l"
+{ simbolo = simb_read;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("read  ");
+          return READ;
+}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 79 "compilador.l"
+{ simbolo = simb_write;
+          strncpy (token, yytext, TAM_TOKEN);
+          IMPRIME("write  ");
+          return WRITE;
+}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 85 "compilador.l"
 { simbolo = simb_atribuicao;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" atribuicao  ");
           return ATRIBUICAO;
  }
 	YY_BREAK
-case 9:
+case 11:
 YY_RULE_SETUP
-#line 79 "compilador.l"
+#line 91 "compilador.l"
 { simbolo = simb_ponto_e_virgula;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" pt_virgula  ");
           return PONTO_E_VIRGULA;
  }
 	YY_BREAK
-case 10:
+case 12:
 YY_RULE_SETUP
-#line 85 "compilador.l"
+#line 97 "compilador.l"
 { simbolo = simb_dois_pontos;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" dois pontos ");
           return DOIS_PONTOS;
  }
 	YY_BREAK
-case 11:
+case 13:
 YY_RULE_SETUP
-#line 91 "compilador.l"
+#line 103 "compilador.l"
 { simbolo = simb_virgula;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" virgula  ");
           return VIRGULA;
  }
 	YY_BREAK
-case 12:
+case 14:
 YY_RULE_SETUP
-#line 98 "compilador.l"
+#line 110 "compilador.l"
 { simbolo = simb_ponto;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" ponto  ");
           return PONTO;
     }
 	YY_BREAK
-case 13:
+case 15:
 YY_RULE_SETUP
-#line 104 "compilador.l"
+#line 116 "compilador.l"
 { simbolo = simb_abre_parenteses;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" abre_parenteses  ");
           return ABRE_PARENTESES;
     }
 	YY_BREAK
-case 14:
+case 16:
 YY_RULE_SETUP
-#line 110 "compilador.l"
+#line 122 "compilador.l"
 { simbolo = simb_fecha_parenteses;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" fecha_parenteses ");
           return FECHA_PARENTESES;
  }
 	YY_BREAK
-case 15:
+case 17:
 YY_RULE_SETUP
-#line 116 "compilador.l"
+#line 128 "compilador.l"
 { simbolo  = simb_label;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("label ");
           return LABEL;
  }
 	YY_BREAK
-case 16:
+case 18:
 YY_RULE_SETUP
-#line 122 "compilador.l"
+#line 134 "compilador.l"
 { simbolo  = simb_type;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("type ");
           return TYPE;
  }
 	YY_BREAK
-case 17:
+case 19:
 YY_RULE_SETUP
-#line 128 "compilador.l"
+#line 140 "compilador.l"
 { simbolo  = simb_array;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("array ");
           return ARRAY;
  }
 	YY_BREAK
-case 18:
+case 20:
 YY_RULE_SETUP
-#line 134 "compilador.l"
+#line 146 "compilador.l"
 { simbolo  = simb_procedure;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("procedure ");
           return PROCEDURE;
  }
 	YY_BREAK
-case 19:
+case 21:
 YY_RULE_SETUP
-#line 140 "compilador.l"
+#line 152 "compilador.l"
 { simbolo  = simb_function;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("function ");
           return FUNCTION;
  }
 	YY_BREAK
-case 20:
+case 22:
 YY_RULE_SETUP
-#line 146 "compilador.l"
+#line 158 "compilador.l"
 { simbolo  = simb_goto;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("goto ");
           return GOTO;
  }
 	YY_BREAK
-case 21:
+case 23:
 YY_RULE_SETUP
-#line 152 "compilador.l"
+#line 164 "compilador.l"
 { simbolo  = simb_if;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("if ");
           return IF;
  }
 	YY_BREAK
-case 22:
+case 24:
 YY_RULE_SETUP
-#line 158 "compilador.l"
+#line 170 "compilador.l"
 { simbolo  = simb_then;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" then ");
           return THEN;
  }
 	YY_BREAK
-case 23:
+case 25:
 YY_RULE_SETUP
-#line 164 "compilador.l"
+#line 176 "compilador.l"
 { simbolo  = simb_else;
           strncpy (token, yytext, TAM_TOKEN);
-          IMPRIME("else ");
+          IMPRIME(" else ");
           return ELSE;
  }
 	YY_BREAK
-case 24:
+case 26:
 YY_RULE_SETUP
-#line 170 "compilador.l"
+#line 182 "compilador.l"
 { simbolo  = simb_while;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME("while ");
           return WHILE;
  }
 	YY_BREAK
-case 25:
+case 27:
 YY_RULE_SETUP
-#line 176 "compilador.l"
+#line 188 "compilador.l"
 { simbolo  = simb_do;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" do ");
           return DO;
  }
 	YY_BREAK
-case 26:
+case 28:
 YY_RULE_SETUP
-#line 182 "compilador.l"
+#line 194 "compilador.l"
 { simbolo  = simb_or;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" or ");
           return OR;
  }
 	YY_BREAK
-case 27:
+case 29:
 YY_RULE_SETUP
-#line 188 "compilador.l"
+#line 200 "compilador.l"
 { simbolo  = simb_div;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" div ");
           return DIV;
  }
 	YY_BREAK
-case 28:
+case 30:
 YY_RULE_SETUP
-#line 194 "compilador.l"
+#line 206 "compilador.l"
 { simbolo  = simb_and;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" and ");
           return AND;
  }
 	YY_BREAK
-case 29:
+case 31:
 YY_RULE_SETUP
-#line 200 "compilador.l"
+#line 212 "compilador.l"
 { simbolo  = simb_not;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" not ");
           return NOT;
  }
 	YY_BREAK
-case 30:
+case 32:
 YY_RULE_SETUP
-#line 206 "compilador.l"
+#line 218 "compilador.l"
 { simbolo = simb_igual;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" igual  ");
           return IGUAL;
     }
 	YY_BREAK
-case 31:
+case 33:
 YY_RULE_SETUP
-#line 212 "compilador.l"
+#line 224 "compilador.l"
 { simbolo = simb_diferente;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" diferente  ");
           return DIFERENTE;
     }
 	YY_BREAK
-case 32:
+case 34:
 YY_RULE_SETUP
-#line 218 "compilador.l"
+#line 230 "compilador.l"
 { simbolo = simb_menor_igual;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" menor_igual  ");
           return MENOR_IGUAL;
     }
 	YY_BREAK
-case 33:
+case 35:
 YY_RULE_SETUP
-#line 224 "compilador.l"
+#line 236 "compilador.l"
 { simbolo = simb_maior_igual;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" maior_igual  ");
           return MAIOR_IGUAL;
     }
 	YY_BREAK
-case 34:
+case 36:
 YY_RULE_SETUP
-#line 230 "compilador.l"
+#line 242 "compilador.l"
 { simbolo = simb_menor;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" menor  ");
           return MENOR;
     }
 	YY_BREAK
-case 35:
+case 37:
 YY_RULE_SETUP
-#line 236 "compilador.l"
+#line 248 "compilador.l"
 { simbolo = simb_maior;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" maior  ");
           return MAIOR;
     }
 	YY_BREAK
-case 36:
+case 38:
 YY_RULE_SETUP
-#line 242 "compilador.l"
+#line 254 "compilador.l"
 { simbolo = simb_mais;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" mais  ");
           return MAIS;
     }
 	YY_BREAK
-case 37:
+case 39:
 YY_RULE_SETUP
-#line 248 "compilador.l"
+#line 260 "compilador.l"
 { simbolo = simb_menos;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" menos  ");
           return MENOS;
     }
 	YY_BREAK
-case 38:
+case 40:
 YY_RULE_SETUP
-#line 254 "compilador.l"
+#line 266 "compilador.l"
 { simbolo = simb_asterisco;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" asterisco  ");
           return ASTERISCO;
     }
 	YY_BREAK
-case 39:
+case 41:
 YY_RULE_SETUP
-#line 260 "compilador.l"
+#line 272 "compilador.l"
 {  simbolo = simb_numero;
             strncpy (token, yytext,TAM_TOKEN);
             IMPRIME(" numero ");
             return NUMERO;
     }
 	YY_BREAK
-case 40:
+case 42:
 YY_RULE_SETUP
-#line 266 "compilador.l"
+#line 278 "compilador.l"
 { simbolo = simb_identificador;
           strncpy (token, yytext, TAM_TOKEN);
           IMPRIME(" ident  ");
           return IDENT;
         }
 	YY_BREAK
-case 41:
+case 43:
 YY_RULE_SETUP
-#line 272 "compilador.l"
+#line 284 "compilador.l"
 ECHO;
 	YY_BREAK
-#line 1167 "lex.yy.c"
+#line 1190 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 	yyterminate();
 
@@ -1460,7 +1483,7 @@ static int yy_get_next_buffer (void)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 107 )
+			if ( yy_current_state >= 115 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1488,11 +1511,11 @@ static int yy_get_next_buffer (void)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 107 )
+		if ( yy_current_state >= 115 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 106);
+	yy_is_jam = (yy_current_state == 114);
 
 		return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2168,6 +2191,6 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 272 "compilador.l"
+#line 284 "compilador.l"
 
 
diff --git a/teste5.pas b/teste5.pas
new file mode 100644
index 0000000000000000000000000000000000000000..940451a66aa717183213a16fc93e922da02ef704
--- /dev/null
+++ b/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 div 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. 
+