diff --git a/MEPA b/MEPA index 262e92eb980b02c290269fb7d03023b75a135ea6..9e6e687fcb99f485acd2874106fc963901701233 100644 --- a/MEPA +++ b/MEPA @@ -2,22 +2,3 @@ AMEM 1 DSVS R00 R01: ENPR 1 - AMEM 1 - DSVS R02 -R02: NADA - CRVI 1,-5 - ARMZ 1,0 - CRCT 1 - ARMI 1,-5 - DMEM 1 -R00: NADA - CRCT 8 - ARMZ 0,0 - CREN 0,0 - CRCT 8 - CRCT 2 - CRCT 3 - SOMA - CHPR R01,0 - DMEM 0 - PARA diff --git a/compilador.output b/compilador.output index 59f20c0024161eb8c73745b7c006403dbca36fff..e8cfddad2682c9a7be823f532fd3c384fc634602 100644 --- a/compilador.output +++ b/compilador.output @@ -2,14 +2,13 @@ Terminals which are not used TYPE ARRAY - FUNCTION GOTO OR AND NOT -State 71 conflicts: 1 reduce/reduce +State 78 conflicts: 1 reduce/reduce Grammar @@ -54,126 +53,133 @@ Grammar 21 | IDENT 22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento - 23 | /* empty */ + 23 | declaracao_funcao + 24 | /* empty */ - 24 @7: /* empty */ + 25 @7: /* empty */ - 25 @8: /* empty */ + 26 @8: /* empty */ - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - 27 @9: /* empty */ + 28 @9: /* empty */ - 28 @10: /* empty */ + 29 @10: /* empty */ - 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 FECHA_PARENTESES - 30 | /* empty */ + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA - 31 paramentros_formais: secao_pfs - 32 | paramentros_formais PONTO_E_VIRGULA secao_pfs + 31 @11: /* empty */ - 33 @11: /* empty */ + 32 @12: /* empty */ - 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS tipo + 33 parametros_ou_nada: ABRE_PARENTESES @11 paramentros_formais @12 FECHA_PARENTESES + 34 | /* empty */ - 35 @12: /* empty */ + 35 paramentros_formais: secao_pfs + 36 | paramentros_formais PONTO_E_VIRGULA secao_pfs - 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS tipo + 37 @13: /* empty */ - 37 lista_id_pf: parametro VIRGULA lista_id_pf - 38 | parametro + 38 secao_pfs: VAR @13 lista_id_pf DOIS_PONTOS tipo - 39 parametro: IDENT + 39 @14: /* empty */ - 40 comando_composto: T_BEGIN comandos T_END + 40 secao_pfs: @14 lista_id_pf DOIS_PONTOS tipo - 41 comandos: comando PONTO_E_VIRGULA comandos - 42 | comando PONTO_E_VIRGULA - 43 | /* empty */ + 41 lista_id_pf: parametro VIRGULA lista_id_pf + 42 | parametro - 44 comando: numero DOIS_PONTOS comando_sem_rotulo - 45 | comando_sem_rotulo + 43 parametro: IDENT - 46 comando_sem_rotulo: atribuicao_ou_procedimento - 47 | comando_composto - 48 | comando_condicional - 49 | comando_repetitivo - 50 | leitura - 51 | escrita + 44 comando_composto: T_BEGIN comandos T_END - 52 @13: /* empty */ + 45 comandos: comando PONTO_E_VIRGULA comandos + 46 | comando PONTO_E_VIRGULA + 47 | /* empty */ - 53 atribuicao_ou_procedimento: IDENT @13 atribuicao_ou_procedimento_token + 48 comando: numero DOIS_PONTOS comando_sem_rotulo + 49 | comando_sem_rotulo - 54 atribuicao_ou_procedimento_token: atribuicao - 55 | chamada_procedimento + 50 comando_sem_rotulo: atribuicao_ou_procedimento + 51 | comando_composto + 52 | comando_condicional + 53 | comando_repetitivo + 54 | leitura + 55 | escrita - 56 @14: /* empty */ + 56 @15: /* empty */ - 57 atribuicao: @14 ATRIBUICAO expressao_simples + 57 atribuicao_ou_procedimento: IDENT @15 atribuicao_ou_procedimento_token - 58 @15: /* empty */ + 58 atribuicao_ou_procedimento_token: atribuicao + 59 | chamada_procedimento - 59 chamada_procedimento: @15 lista_parametros + 60 @16: /* empty */ - 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES - 61 | /* empty */ + 61 atribuicao: @16 ATRIBUICAO expressao_simples - 62 @16: /* empty */ + 62 @17: /* empty */ - 63 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @16 expressao_simples + 63 chamada_procedimento: @17 lista_parametros - 64 @17: /* empty */ + 64 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES + 65 | /* empty */ - 65 lista_parametros_parenteses: @17 expressao_simples + 66 @18: /* empty */ - 66 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES + 67 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @18 expressao_simples - 67 lista_leituras: lista_leituras VIRGULA simb_leitura - 68 | simb_leitura + 68 @19: /* empty */ - 69 simb_leitura: IDENT + 69 lista_parametros_parenteses: @19 expressao_simples - 70 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES + 70 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES - 71 lista_escritas: lista_escritas VIRGULA expressao_simples - 72 | expressao_simples + 71 lista_leituras: lista_leituras VIRGULA simb_leitura + 72 | simb_leitura - 73 expressao: expressao IGUAL expressao_simples - 74 | expressao DIFERENTE expressao_simples - 75 | expressao MENOR expressao_simples - 76 | expressao MENOR_IGUAL expressao_simples - 77 | expressao MAIOR expressao_simples - 78 | expressao MAIOR_IGUAL expressao_simples - 79 | expressao_simples + 73 simb_leitura: IDENT - 80 expressao_simples: expressao_simples MAIS termo - 81 | expressao_simples MENOS termo - 82 | termo + 74 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES - 83 termo: termo ASTERISCO fator - 84 | termo DIV fator - 85 | fator + 75 lista_escritas: lista_escritas VIRGULA expressao_simples + 76 | expressao_simples - 86 fator: IDENT - 87 | NUMERO + 77 expressao: expressao IGUAL expressao_simples + 78 | expressao DIFERENTE expressao_simples + 79 | expressao MENOR expressao_simples + 80 | expressao MENOR_IGUAL expressao_simples + 81 | expressao MAIOR expressao_simples + 82 | expressao MAIOR_IGUAL expressao_simples + 83 | expressao_simples - 88 numero: NUMERO + 84 expressao_simples: expressao_simples MAIS termo + 85 | expressao_simples MENOS termo + 86 | termo - 89 @18: /* empty */ + 87 termo: termo ASTERISCO fator + 88 | termo DIV fator + 89 | fator - 90 @19: /* empty */ + 90 fator: IDENT + 91 | NUMERO - 91 comando_repetitivo: @18 WHILE expressao DO @19 comando_sem_rotulo + 92 numero: NUMERO - 92 comando_condicional: if_then cond_else + 93 @20: /* empty */ - 93 cond_else: ELSE comando_sem_rotulo - 94 | /* empty */ + 94 @21: /* empty */ - 95 @20: /* empty */ + 95 comando_repetitivo: @20 WHILE expressao DO @21 comando_sem_rotulo - 96 if_then: IF expressao @20 THEN comando_sem_rotulo + 96 comando_condicional: if_then cond_else + + 97 cond_else: ELSE comando_sem_rotulo + 98 | /* empty */ + + 99 @22: /* empty */ + + 100 if_then: IF expressao @22 THEN comando_sem_rotulo Terminals, with rules where they appear @@ -181,44 +187,44 @@ Terminals, with rules where they appear $end (0) 0 error (256) PROGRAM (258) 2 -ABRE_PARENTESES (259) 2 29 60 66 70 -FECHA_PARENTESES (260) 2 29 60 66 70 -VIRGULA (261) 6 18 20 37 63 67 71 -PONTO_E_VIRGULA (262) 2 16 26 32 41 42 -DOIS_PONTOS (263) 16 34 36 44 +ABRE_PARENTESES (259) 2 33 64 70 74 +FECHA_PARENTESES (260) 2 33 64 70 74 +VIRGULA (261) 6 18 20 41 67 71 75 +PONTO_E_VIRGULA (262) 2 16 27 30 36 45 46 +DOIS_PONTOS (263) 16 38 40 48 PONTO (264) 2 -T_BEGIN (265) 40 -T_END (266) 40 -VAR (267) 10 34 -IDENT (268) 2 17 18 19 20 21 26 39 53 69 86 -ATRIBUICAO (269) 57 +T_BEGIN (265) 44 +T_END (266) 44 +VAR (267) 10 38 +IDENT (268) 2 17 18 19 20 21 27 30 43 57 73 90 +ATRIBUICAO (269) 61 LABEL (270) 6 TYPE (271) ARRAY (272) -PROCEDURE (273) 26 -FUNCTION (274) +PROCEDURE (273) 27 +FUNCTION (274) 30 GOTO (275) -IF (276) 96 -THEN (277) 96 -ELSE (278) 93 -WHILE (279) 91 -DO (280) 91 +IF (276) 100 +THEN (277) 100 +ELSE (278) 97 +WHILE (279) 95 +DO (280) 95 OR (281) -DIV (282) 84 +DIV (282) 88 AND (283) NOT (284) -IGUAL (285) 73 -DIFERENTE (286) 74 -MENOR_IGUAL (287) 76 -MAIOR_IGUAL (288) 78 -MENOR (289) 75 -MAIOR (290) 77 -MAIS (291) 80 -MENOS (292) 81 -ASTERISCO (293) 83 -NUMERO (294) 87 88 -READ (295) 66 -WRITE (296) 70 +IGUAL (285) 77 +DIFERENTE (286) 78 +MENOR_IGUAL (287) 80 +MAIOR_IGUAL (288) 82 +MENOR (289) 79 +MAIOR (290) 81 +MAIS (291) 84 +MENOS (292) 85 +ASTERISCO (293) 87 +NUMERO (294) 91 92 +READ (295) 70 +WRITE (296) 74 LOWER_THAN_ELSE (297) @@ -231,7 +237,7 @@ programa (44) @1 (45) on left: 1, on right: 2 bloco (46) - on left: 5, on right: 2 26 + on left: 5, on right: 2 27 30 @2 (47) on left: 3, on right: 5 @3 (48) @@ -253,102 +259,108 @@ declara_var (54) @6 (56) on left: 15, on right: 16 tipo (57) - on left: 17, on right: 16 34 36 + on left: 17, on right: 16 38 40 lista_id_var (58) on left: 18 19, on right: 16 18 lista_idents (59) on left: 20 21, on right: 2 20 parte_declara_subrotinas (60) - on left: 22 23, on right: 5 22 + on left: 22 23 24, on right: 5 22 declaracao_procedimento (61) - on left: 26, on right: 22 + on left: 27, on right: 22 @7 (62) - on left: 24, on right: 26 + on left: 25, on right: 27 @8 (63) - on left: 25, on right: 26 -parametros_ou_nada (64) - on left: 29 30, on right: 26 + on left: 26, on right: 27 +declaracao_funcao (64) + on left: 30, on right: 23 @9 (65) - on left: 27, on right: 29 + on left: 28, on right: 30 @10 (66) - on left: 28, on right: 29 -paramentros_formais (67) - on left: 31 32, on right: 29 32 -secao_pfs (68) - on left: 34 36, on right: 31 32 -@11 (69) - on left: 33, on right: 34 -@12 (70) - on left: 35, on right: 36 -lista_id_pf (71) - on left: 37 38, on right: 34 36 37 -parametro (72) - on left: 39, on right: 37 38 -comando_composto (73) - on left: 40, on right: 5 47 -comandos (74) - on left: 41 42 43, on right: 40 41 -comando (75) - on left: 44 45, on right: 41 42 -comando_sem_rotulo (76) - on left: 46 47 48 49 50 51, on right: 44 45 91 93 96 -atribuicao_ou_procedimento (77) - on left: 53, on right: 46 -@13 (78) - on left: 52, on right: 53 -atribuicao_ou_procedimento_token (79) - on left: 54 55, on right: 53 -atribuicao (80) - on left: 57, on right: 54 -@14 (81) + on left: 29, on right: 30 +parametros_ou_nada (67) + on left: 33 34, on right: 27 30 +@11 (68) + on left: 31, on right: 33 +@12 (69) + on left: 32, on right: 33 +paramentros_formais (70) + on left: 35 36, on right: 33 36 +secao_pfs (71) + on left: 38 40, on right: 35 36 +@13 (72) + on left: 37, on right: 38 +@14 (73) + on left: 39, on right: 40 +lista_id_pf (74) + on left: 41 42, on right: 38 40 41 +parametro (75) + on left: 43, on right: 41 42 +comando_composto (76) + on left: 44, on right: 5 51 +comandos (77) + on left: 45 46 47, on right: 44 45 +comando (78) + on left: 48 49, on right: 45 46 +comando_sem_rotulo (79) + on left: 50 51 52 53 54 55, on right: 48 49 95 97 100 +atribuicao_ou_procedimento (80) + on left: 57, on right: 50 +@15 (81) on left: 56, on right: 57 -chamada_procedimento (82) - on left: 59, on right: 55 -@15 (83) - on left: 58, on right: 59 -lista_parametros (84) - on left: 60 61, on right: 59 -lista_parametros_parenteses (85) - on left: 63 65, on right: 60 63 -@16 (86) +atribuicao_ou_procedimento_token (82) + on left: 58 59, on right: 57 +atribuicao (83) + on left: 61, on right: 58 +@16 (84) + on left: 60, on right: 61 +chamada_procedimento (85) + on left: 63, on right: 59 +@17 (86) on left: 62, on right: 63 -@17 (87) - on left: 64, on right: 65 -leitura (88) - on left: 66, on right: 50 -lista_leituras (89) - on left: 67 68, on right: 66 67 -simb_leitura (90) - on left: 69, on right: 67 68 -escrita (91) - on left: 70, on right: 51 -lista_escritas (92) +lista_parametros (87) + on left: 64 65, on right: 63 +lista_parametros_parenteses (88) + on left: 67 69, on right: 64 67 +@18 (89) + on left: 66, on right: 67 +@19 (90) + on left: 68, on right: 69 +leitura (91) + on left: 70, on right: 54 +lista_leituras (92) on left: 71 72, on right: 70 71 -expressao (93) - on left: 73 74 75 76 77 78 79, on right: 73 74 75 76 77 78 91 96 -expressao_simples (94) - on left: 80 81 82, on right: 57 63 65 71 72 73 74 75 76 77 78 79 - 80 81 -termo (95) - on left: 83 84 85, on right: 80 81 82 83 84 -fator (96) - on left: 86 87, on right: 83 84 85 -numero (97) - on left: 88, on right: 44 -comando_repetitivo (98) - on left: 91, on right: 49 -@18 (99) - on left: 89, on right: 91 -@19 (100) - on left: 90, on right: 91 -comando_condicional (101) +simb_leitura (93) + on left: 73, on right: 71 72 +escrita (94) + on left: 74, on right: 55 +lista_escritas (95) + on left: 75 76, on right: 74 75 +expressao (96) + on left: 77 78 79 80 81 82 83, on right: 77 78 79 80 81 82 95 100 +expressao_simples (97) + on left: 84 85 86, on right: 61 67 69 75 76 77 78 79 80 81 82 83 + 84 85 +termo (98) + on left: 87 88 89, on right: 84 85 86 87 88 +fator (99) + on left: 90 91, on right: 87 88 89 +numero (100) on left: 92, on right: 48 -cond_else (102) - on left: 93 94, on right: 92 -if_then (103) - on left: 96, on right: 92 -@20 (104) - on left: 95, on right: 96 +comando_repetitivo (101) + on left: 95, on right: 53 +@20 (102) + on left: 93, on right: 95 +@21 (103) + on left: 94, on right: 95 +comando_condicional (104) + on left: 96, on right: 52 +cond_else (105) + on left: 97 98, on right: 96 +if_then (106) + on left: 100, on right: 96 +@22 (107) + on left: 99, on right: 100 state 0 @@ -521,9 +533,12 @@ state 21 5 bloco: parte_declara_rotulos parte_declara_vars @2 . parte_declara_subrotinas @3 comando_composto - $default reduce using rule 23 (parte_declara_subrotinas) + FUNCTION shift, and go to state 23 - parte_declara_subrotinas go to state 23 + $default reduce using rule 24 (parte_declara_subrotinas) + + parte_declara_subrotinas go to state 24 + declaracao_funcao go to state 25 state 22 @@ -532,1357 +547,1433 @@ state 22 $default reduce using rule 14 (@5) - declara_vars go to state 24 - declara_var go to state 25 - @5 go to state 26 + declara_vars go to state 26 + declara_var go to state 27 + @5 go to state 28 state 23 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas . @3 comando_composto - 22 parte_declara_subrotinas: parte_declara_subrotinas . declaracao_procedimento + 30 declaracao_funcao: FUNCTION . IDENT @9 parametros_ou_nada PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA - PROCEDURE shift, and go to state 27 - - $default reduce using rule 4 (@3) - - @3 go to state 28 - declaracao_procedimento go to state 29 + IDENT shift, and go to state 29 state 24 - 10 var: @4 VAR declara_vars . - 12 declara_vars: declara_vars . declara_var + 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas . @3 comando_composto + 22 parte_declara_subrotinas: parte_declara_subrotinas . declaracao_procedimento - IDENT reduce using rule 14 (@5) - $default reduce using rule 10 (var) + PROCEDURE shift, and go to state 30 + + $default reduce using rule 4 (@3) - declara_var go to state 30 - @5 go to state 26 + @3 go to state 31 + declaracao_procedimento go to state 32 state 25 - 13 declara_vars: declara_var . + 23 parte_declara_subrotinas: declaracao_funcao . - $default reduce using rule 13 (declara_vars) + $default reduce using rule 23 (parte_declara_subrotinas) state 26 - 16 declara_var: @5 . lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA + 10 var: @4 VAR declara_vars . + 12 declara_vars: declara_vars . declara_var - IDENT shift, and go to state 31 + IDENT reduce using rule 14 (@5) + $default reduce using rule 10 (var) - lista_id_var go to state 32 + declara_var go to state 33 + @5 go to state 28 state 27 - 26 declaracao_procedimento: PROCEDURE . IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA + 13 declara_vars: declara_var . - IDENT shift, and go to state 33 + $default reduce using rule 13 (declara_vars) state 28 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 . comando_composto + 16 declara_var: @5 . lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA - T_BEGIN shift, and go to state 34 + IDENT shift, and go to state 34 - comando_composto go to state 35 + lista_id_var go to state 35 state 29 - 22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento . + 30 declaracao_funcao: FUNCTION IDENT . @9 parametros_ou_nada PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA - $default reduce using rule 22 (parte_declara_subrotinas) + $default reduce using rule 28 (@9) + + @9 go to state 36 state 30 - 12 declara_vars: declara_vars declara_var . + 27 declaracao_procedimento: PROCEDURE . IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - $default reduce using rule 12 (declara_vars) + IDENT shift, and go to state 37 state 31 - 19 lista_id_var: IDENT . + 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 . comando_composto - $default reduce using rule 19 (lista_id_var) + T_BEGIN shift, and go to state 38 + + comando_composto go to state 39 state 32 - 16 declara_var: @5 lista_id_var . DOIS_PONTOS tipo @6 PONTO_E_VIRGULA - 18 lista_id_var: lista_id_var . VIRGULA IDENT + 22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento . - VIRGULA shift, and go to state 36 - DOIS_PONTOS shift, and go to state 37 + $default reduce using rule 22 (parte_declara_subrotinas) state 33 - 26 declaracao_procedimento: PROCEDURE IDENT . @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - - $default reduce using rule 24 (@7) + 12 declara_vars: declara_vars declara_var . - @7 go to state 38 + $default reduce using rule 12 (declara_vars) state 34 - 40 comando_composto: T_BEGIN . comandos T_END - - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - NUMERO shift, and go to state 41 - READ shift, and go to state 42 - WRITE shift, and go to state 43 - - WHILE reduce using rule 89 (@18) - $default reduce using rule 43 (comandos) + 19 lista_id_var: IDENT . - comando_composto go to state 44 - comandos go to state 45 - comando go to state 46 - comando_sem_rotulo go to state 47 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - numero go to state 51 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + $default reduce using rule 19 (lista_id_var) state 35 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto . + 16 declara_var: @5 lista_id_var . DOIS_PONTOS tipo @6 PONTO_E_VIRGULA + 18 lista_id_var: lista_id_var . VIRGULA IDENT - $default reduce using rule 5 (bloco) + VIRGULA shift, and go to state 40 + DOIS_PONTOS shift, and go to state 41 state 36 - 18 lista_id_var: lista_id_var VIRGULA . IDENT + 30 declaracao_funcao: FUNCTION IDENT @9 . parametros_ou_nada PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA - IDENT shift, and go to state 56 + ABRE_PARENTESES shift, and go to state 42 + + $default reduce using rule 34 (parametros_ou_nada) + + parametros_ou_nada go to state 43 state 37 - 16 declara_var: @5 lista_id_var DOIS_PONTOS . tipo @6 PONTO_E_VIRGULA + 27 declaracao_procedimento: PROCEDURE IDENT . @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - IDENT shift, and go to state 57 + $default reduce using rule 25 (@7) - tipo go to state 58 + @7 go to state 44 state 38 - 26 declaracao_procedimento: PROCEDURE IDENT @7 . parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA + 44 comando_composto: T_BEGIN . comandos T_END - ABRE_PARENTESES shift, and go to state 59 + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + NUMERO shift, and go to state 47 + READ shift, and go to state 48 + WRITE shift, and go to state 49 - $default reduce using rule 30 (parametros_ou_nada) + WHILE reduce using rule 93 (@20) + $default reduce using rule 47 (comandos) - parametros_ou_nada go to state 60 + comando_composto go to state 50 + comandos go to state 51 + comando go to state 52 + comando_sem_rotulo go to state 53 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + numero go to state 57 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 state 39 - 53 atribuicao_ou_procedimento: IDENT . @13 atribuicao_ou_procedimento_token - - $default reduce using rule 52 (@13) + 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto . - @13 go to state 61 + $default reduce using rule 5 (bloco) state 40 - 96 if_then: IF . expressao @20 THEN comando_sem_rotulo - - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 18 lista_id_var: lista_id_var VIRGULA . IDENT - expressao go to state 64 - expressao_simples go to state 65 - termo go to state 66 - fator go to state 67 + IDENT shift, and go to state 62 state 41 - 88 numero: NUMERO . + 16 declara_var: @5 lista_id_var DOIS_PONTOS . tipo @6 PONTO_E_VIRGULA + + IDENT shift, and go to state 63 - $default reduce using rule 88 (numero) + tipo go to state 64 state 42 - 66 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES + 33 parametros_ou_nada: ABRE_PARENTESES . @11 paramentros_formais @12 FECHA_PARENTESES + + $default reduce using rule 31 (@11) - ABRE_PARENTESES shift, and go to state 68 + @11 go to state 65 state 43 - 70 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada . PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA - ABRE_PARENTESES shift, and go to state 69 + PONTO_E_VIRGULA shift, and go to state 66 state 44 - 47 comando_sem_rotulo: comando_composto . + 27 declaracao_procedimento: PROCEDURE IDENT @7 . parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - $default reduce using rule 47 (comando_sem_rotulo) + ABRE_PARENTESES shift, and go to state 42 + + $default reduce using rule 34 (parametros_ou_nada) + + parametros_ou_nada go to state 67 state 45 - 40 comando_composto: T_BEGIN comandos . T_END + 57 atribuicao_ou_procedimento: IDENT . @15 atribuicao_ou_procedimento_token - T_END shift, and go to state 70 + $default reduce using rule 56 (@15) + + @15 go to state 68 state 46 - 41 comandos: comando . PONTO_E_VIRGULA comandos - 42 | comando . PONTO_E_VIRGULA + 100 if_then: IF . expressao @22 THEN comando_sem_rotulo + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - PONTO_E_VIRGULA shift, and go to state 71 + expressao go to state 71 + expressao_simples go to state 72 + termo go to state 73 + fator go to state 74 state 47 - 45 comando: comando_sem_rotulo . + 92 numero: NUMERO . - $default reduce using rule 45 (comando) + $default reduce using rule 92 (numero) state 48 - 46 comando_sem_rotulo: atribuicao_ou_procedimento . + 70 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES - $default reduce using rule 46 (comando_sem_rotulo) + ABRE_PARENTESES shift, and go to state 75 state 49 - 50 comando_sem_rotulo: leitura . + 74 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES - $default reduce using rule 50 (comando_sem_rotulo) + ABRE_PARENTESES shift, and go to state 76 state 50 - 51 comando_sem_rotulo: escrita . + 51 comando_sem_rotulo: comando_composto . $default reduce using rule 51 (comando_sem_rotulo) state 51 - 44 comando: numero . DOIS_PONTOS comando_sem_rotulo + 44 comando_composto: T_BEGIN comandos . T_END - DOIS_PONTOS shift, and go to state 72 + T_END shift, and go to state 77 state 52 - 49 comando_sem_rotulo: comando_repetitivo . + 45 comandos: comando . PONTO_E_VIRGULA comandos + 46 | comando . PONTO_E_VIRGULA - $default reduce using rule 49 (comando_sem_rotulo) + PONTO_E_VIRGULA shift, and go to state 78 state 53 - 91 comando_repetitivo: @18 . WHILE expressao DO @19 comando_sem_rotulo + 49 comando: comando_sem_rotulo . - WHILE shift, and go to state 73 + $default reduce using rule 49 (comando) state 54 - 48 comando_sem_rotulo: comando_condicional . + 50 comando_sem_rotulo: atribuicao_ou_procedimento . - $default reduce using rule 48 (comando_sem_rotulo) + $default reduce using rule 50 (comando_sem_rotulo) state 55 - 92 comando_condicional: if_then . cond_else + 54 comando_sem_rotulo: leitura . - ELSE shift, and go to state 74 - - $default reduce using rule 94 (cond_else) - - cond_else go to state 75 + $default reduce using rule 54 (comando_sem_rotulo) state 56 - 18 lista_id_var: lista_id_var VIRGULA IDENT . + 55 comando_sem_rotulo: escrita . - $default reduce using rule 18 (lista_id_var) + $default reduce using rule 55 (comando_sem_rotulo) state 57 - 17 tipo: IDENT . + 48 comando: numero . DOIS_PONTOS comando_sem_rotulo - $default reduce using rule 17 (tipo) + DOIS_PONTOS shift, and go to state 79 state 58 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo . @6 PONTO_E_VIRGULA - - $default reduce using rule 15 (@6) + 53 comando_sem_rotulo: comando_repetitivo . - @6 go to state 76 + $default reduce using rule 53 (comando_sem_rotulo) state 59 - 29 parametros_ou_nada: ABRE_PARENTESES . @9 paramentros_formais @10 FECHA_PARENTESES + 95 comando_repetitivo: @20 . WHILE expressao DO @21 comando_sem_rotulo - $default reduce using rule 27 (@9) - - @9 go to state 77 + WHILE shift, and go to state 80 state 60 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada . PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA + 52 comando_sem_rotulo: comando_condicional . - PONTO_E_VIRGULA shift, and go to state 78 + $default reduce using rule 52 (comando_sem_rotulo) state 61 - 53 atribuicao_ou_procedimento: IDENT @13 . atribuicao_ou_procedimento_token + 96 comando_condicional: if_then . cond_else - ATRIBUICAO reduce using rule 56 (@14) - $default reduce using rule 58 (@15) + ELSE shift, and go to state 81 - atribuicao_ou_procedimento_token go to state 79 - atribuicao go to state 80 - @14 go to state 81 - chamada_procedimento go to state 82 - @15 go to state 83 + $default reduce using rule 98 (cond_else) + + cond_else go to state 82 state 62 - 86 fator: IDENT . + 18 lista_id_var: lista_id_var VIRGULA IDENT . - $default reduce using rule 86 (fator) + $default reduce using rule 18 (lista_id_var) state 63 - 87 fator: NUMERO . + 17 tipo: IDENT . - $default reduce using rule 87 (fator) + $default reduce using rule 17 (tipo) state 64 - 73 expressao: expressao . IGUAL expressao_simples - 74 | expressao . DIFERENTE expressao_simples - 75 | expressao . MENOR expressao_simples - 76 | expressao . MENOR_IGUAL expressao_simples - 77 | expressao . MAIOR expressao_simples - 78 | expressao . MAIOR_IGUAL expressao_simples - 96 if_then: IF expressao . @20 THEN comando_sem_rotulo - - IGUAL shift, and go to state 84 - DIFERENTE shift, and go to state 85 - MENOR_IGUAL shift, and go to state 86 - MAIOR_IGUAL shift, and go to state 87 - MENOR shift, and go to state 88 - MAIOR shift, and go to state 89 + 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo . @6 PONTO_E_VIRGULA - $default reduce using rule 95 (@20) + $default reduce using rule 15 (@6) - @20 go to state 90 + @6 go to state 83 state 65 - 79 expressao: expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 33 parametros_ou_nada: ABRE_PARENTESES @11 . paramentros_formais @12 FECHA_PARENTESES - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + VAR shift, and go to state 84 - $default reduce using rule 79 (expressao) + $default reduce using rule 39 (@14) + + paramentros_formais go to state 85 + secao_pfs go to state 86 + @14 go to state 87 state 66 - 82 expressao_simples: termo . - 83 termo: termo . ASTERISCO fator - 84 | termo . DIV fator + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada PONTO_E_VIRGULA . bloco @10 PONTO_E_VIRGULA - DIV shift, and go to state 93 - ASTERISCO shift, and go to state 94 + LABEL shift, and go to state 13 - $default reduce using rule 82 (expressao_simples) + $default reduce using rule 7 (parte_declara_rotulos) + + bloco go to state 88 + parte_declara_rotulos go to state 15 state 67 - 85 termo: fator . + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada . PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA - $default reduce using rule 85 (termo) + PONTO_E_VIRGULA shift, and go to state 89 state 68 - 66 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES + 57 atribuicao_ou_procedimento: IDENT @15 . atribuicao_ou_procedimento_token - IDENT shift, and go to state 95 + ATRIBUICAO reduce using rule 60 (@16) + $default reduce using rule 62 (@17) - lista_leituras go to state 96 - simb_leitura go to state 97 + atribuicao_ou_procedimento_token go to state 90 + atribuicao go to state 91 + @16 go to state 92 + chamada_procedimento go to state 93 + @17 go to state 94 state 69 - 70 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES - - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 90 fator: IDENT . - lista_escritas go to state 98 - expressao_simples go to state 99 - termo go to state 66 - fator go to state 67 + $default reduce using rule 90 (fator) state 70 - 40 comando_composto: T_BEGIN comandos T_END . + 91 fator: NUMERO . - $default reduce using rule 40 (comando_composto) + $default reduce using rule 91 (fator) state 71 - 41 comandos: comando PONTO_E_VIRGULA . comandos - 42 | comando PONTO_E_VIRGULA . - - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - NUMERO shift, and go to state 41 - READ shift, and go to state 42 - WRITE shift, and go to state 43 - - T_END reduce using rule 42 (comandos) - T_END [reduce using rule 43 (comandos)] - WHILE reduce using rule 89 (@18) - $default reduce using rule 42 (comandos) - - comando_composto go to state 44 - comandos go to state 100 - comando go to state 46 - comando_sem_rotulo go to state 47 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - numero go to state 51 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + 77 expressao: expressao . IGUAL expressao_simples + 78 | expressao . DIFERENTE expressao_simples + 79 | expressao . MENOR expressao_simples + 80 | expressao . MENOR_IGUAL expressao_simples + 81 | expressao . MAIOR expressao_simples + 82 | expressao . MAIOR_IGUAL expressao_simples + 100 if_then: IF expressao . @22 THEN comando_sem_rotulo + IGUAL shift, and go to state 95 + DIFERENTE shift, and go to state 96 + MENOR_IGUAL shift, and go to state 97 + MAIOR_IGUAL shift, and go to state 98 + MENOR shift, and go to state 99 + MAIOR shift, and go to state 100 -state 72 + $default reduce using rule 99 (@22) - 44 comando: numero DOIS_PONTOS . comando_sem_rotulo + @22 go to state 101 - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - READ shift, and go to state 42 - WRITE shift, and go to state 43 - $default reduce using rule 89 (@18) +state 72 - comando_composto go to state 44 - comando_sem_rotulo go to state 101 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + 83 expressao: expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 -state 73 + $default reduce using rule 83 (expressao) - 91 comando_repetitivo: @18 WHILE . expressao DO @19 comando_sem_rotulo - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 +state 73 - expressao go to state 102 - expressao_simples go to state 65 - termo go to state 66 - fator go to state 67 + 86 expressao_simples: termo . + 87 termo: termo . ASTERISCO fator + 88 | termo . DIV fator + DIV shift, and go to state 104 + ASTERISCO shift, and go to state 105 -state 74 + $default reduce using rule 86 (expressao_simples) - 93 cond_else: ELSE . comando_sem_rotulo - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - READ shift, and go to state 42 - WRITE shift, and go to state 43 +state 74 - $default reduce using rule 89 (@18) + 89 termo: fator . - comando_composto go to state 44 - comando_sem_rotulo go to state 103 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + $default reduce using rule 89 (termo) state 75 - 92 comando_condicional: if_then cond_else . + 70 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES - $default reduce using rule 92 (comando_condicional) + IDENT shift, and go to state 106 + lista_leituras go to state 107 + simb_leitura go to state 108 -state 76 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 . PONTO_E_VIRGULA +state 76 - PONTO_E_VIRGULA shift, and go to state 104 + 74 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 -state 77 + lista_escritas go to state 109 + expressao_simples go to state 110 + termo go to state 73 + fator go to state 74 - 29 parametros_ou_nada: ABRE_PARENTESES @9 . paramentros_formais @10 FECHA_PARENTESES - VAR shift, and go to state 105 +state 77 - $default reduce using rule 35 (@12) + 44 comando_composto: T_BEGIN comandos T_END . - paramentros_formais go to state 106 - secao_pfs go to state 107 - @12 go to state 108 + $default reduce using rule 44 (comando_composto) state 78 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA . bloco @8 PONTO_E_VIRGULA - - LABEL shift, and go to state 13 + 45 comandos: comando PONTO_E_VIRGULA . comandos + 46 | comando PONTO_E_VIRGULA . + + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + NUMERO shift, and go to state 47 + READ shift, and go to state 48 + WRITE shift, and go to state 49 + + T_END reduce using rule 46 (comandos) + T_END [reduce using rule 47 (comandos)] + WHILE reduce using rule 93 (@20) + $default reduce using rule 46 (comandos) + + comando_composto go to state 50 + comandos go to state 111 + comando go to state 52 + comando_sem_rotulo go to state 53 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + numero go to state 57 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 - $default reduce using rule 7 (parte_declara_rotulos) - bloco go to state 109 - parte_declara_rotulos go to state 15 +state 79 + 48 comando: numero DOIS_PONTOS . comando_sem_rotulo -state 79 + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + READ shift, and go to state 48 + WRITE shift, and go to state 49 - 53 atribuicao_ou_procedimento: IDENT @13 atribuicao_ou_procedimento_token . + $default reduce using rule 93 (@20) - $default reduce using rule 53 (atribuicao_ou_procedimento) + comando_composto go to state 50 + comando_sem_rotulo go to state 112 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 state 80 - 54 atribuicao_ou_procedimento_token: atribuicao . + 95 comando_repetitivo: @20 WHILE . expressao DO @21 comando_sem_rotulo - $default reduce using rule 54 (atribuicao_ou_procedimento_token) + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + expressao go to state 113 + expressao_simples go to state 72 + termo go to state 73 + fator go to state 74 state 81 - 57 atribuicao: @14 . ATRIBUICAO expressao_simples + 97 cond_else: ELSE . comando_sem_rotulo - ATRIBUICAO shift, and go to state 110 + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + READ shift, and go to state 48 + WRITE shift, and go to state 49 + $default reduce using rule 93 (@20) -state 82 + comando_composto go to state 50 + comando_sem_rotulo go to state 114 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 - 55 atribuicao_ou_procedimento_token: chamada_procedimento . - $default reduce using rule 55 (atribuicao_ou_procedimento_token) +state 82 + 96 comando_condicional: if_then cond_else . -state 83 + $default reduce using rule 96 (comando_condicional) - 59 chamada_procedimento: @15 . lista_parametros - ABRE_PARENTESES shift, and go to state 111 +state 83 - $default reduce using rule 61 (lista_parametros) + 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 . PONTO_E_VIRGULA - lista_parametros go to state 112 + PONTO_E_VIRGULA shift, and go to state 115 state 84 - 73 expressao: expressao IGUAL . expressao_simples + 38 secao_pfs: VAR . @13 lista_id_pf DOIS_PONTOS tipo - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + $default reduce using rule 37 (@13) - expressao_simples go to state 113 - termo go to state 66 - fator go to state 67 + @13 go to state 116 state 85 - 74 expressao: expressao DIFERENTE . expressao_simples + 33 parametros_ou_nada: ABRE_PARENTESES @11 paramentros_formais . @12 FECHA_PARENTESES + 36 paramentros_formais: paramentros_formais . PONTO_E_VIRGULA secao_pfs - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + PONTO_E_VIRGULA shift, and go to state 117 - expressao_simples go to state 114 - termo go to state 66 - fator go to state 67 + $default reduce using rule 32 (@12) + @12 go to state 118 -state 86 - 76 expressao: expressao MENOR_IGUAL . expressao_simples +state 86 - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 35 paramentros_formais: secao_pfs . - expressao_simples go to state 115 - termo go to state 66 - fator go to state 67 + $default reduce using rule 35 (paramentros_formais) state 87 - 78 expressao: expressao MAIOR_IGUAL . expressao_simples + 40 secao_pfs: @14 . lista_id_pf DOIS_PONTOS tipo - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + IDENT shift, and go to state 119 - expressao_simples go to state 116 - termo go to state 66 - fator go to state 67 + lista_id_pf go to state 120 + parametro go to state 121 state 88 - 75 expressao: expressao MENOR . expressao_simples + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada PONTO_E_VIRGULA bloco . @10 PONTO_E_VIRGULA - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + $default reduce using rule 29 (@10) - expressao_simples go to state 117 - termo go to state 66 - fator go to state 67 + @10 go to state 122 state 89 - 77 expressao: expressao MAIOR . expressao_simples + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA . bloco @8 PONTO_E_VIRGULA - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + LABEL shift, and go to state 13 + + $default reduce using rule 7 (parte_declara_rotulos) - expressao_simples go to state 118 - termo go to state 66 - fator go to state 67 + bloco go to state 123 + parte_declara_rotulos go to state 15 state 90 - 96 if_then: IF expressao @20 . THEN comando_sem_rotulo + 57 atribuicao_ou_procedimento: IDENT @15 atribuicao_ou_procedimento_token . - THEN shift, and go to state 119 + $default reduce using rule 57 (atribuicao_ou_procedimento) state 91 - 80 expressao_simples: expressao_simples MAIS . termo + 58 atribuicao_ou_procedimento_token: atribuicao . - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 - - termo go to state 120 - fator go to state 67 + $default reduce using rule 58 (atribuicao_ou_procedimento_token) state 92 - 81 expressao_simples: expressao_simples MENOS . termo - - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 61 atribuicao: @16 . ATRIBUICAO expressao_simples - termo go to state 121 - fator go to state 67 + ATRIBUICAO shift, and go to state 124 state 93 - 84 termo: termo DIV . fator - - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 59 atribuicao_ou_procedimento_token: chamada_procedimento . - fator go to state 122 + $default reduce using rule 59 (atribuicao_ou_procedimento_token) state 94 - 83 termo: termo ASTERISCO . fator + 63 chamada_procedimento: @17 . lista_parametros - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + ABRE_PARENTESES shift, and go to state 125 - fator go to state 123 + $default reduce using rule 65 (lista_parametros) + + lista_parametros go to state 126 state 95 - 69 simb_leitura: IDENT . + 77 expressao: expressao IGUAL . expressao_simples + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 69 (simb_leitura) + expressao_simples go to state 127 + termo go to state 73 + fator go to state 74 state 96 - 66 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES - 67 lista_leituras: lista_leituras . VIRGULA simb_leitura + 78 expressao: expressao DIFERENTE . expressao_simples - FECHA_PARENTESES shift, and go to state 124 - VIRGULA shift, and go to state 125 + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + expressao_simples go to state 128 + termo go to state 73 + fator go to state 74 state 97 - 68 lista_leituras: simb_leitura . + 80 expressao: expressao MENOR_IGUAL . expressao_simples + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 68 (lista_leituras) + expressao_simples go to state 129 + termo go to state 73 + fator go to state 74 state 98 - 70 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES - 71 lista_escritas: lista_escritas . VIRGULA expressao_simples + 82 expressao: expressao MAIOR_IGUAL . expressao_simples - FECHA_PARENTESES shift, and go to state 126 - VIRGULA shift, and go to state 127 + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + expressao_simples go to state 130 + termo go to state 73 + fator go to state 74 state 99 - 72 lista_escritas: expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 79 expressao: expressao MENOR . expressao_simples - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 72 (lista_escritas) + expressao_simples go to state 131 + termo go to state 73 + fator go to state 74 state 100 - 41 comandos: comando PONTO_E_VIRGULA comandos . + 81 expressao: expressao MAIOR . expressao_simples + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 41 (comandos) + expressao_simples go to state 132 + termo go to state 73 + fator go to state 74 state 101 - 44 comando: numero DOIS_PONTOS comando_sem_rotulo . + 100 if_then: IF expressao @22 . THEN comando_sem_rotulo - $default reduce using rule 44 (comando) + THEN shift, and go to state 133 state 102 - 73 expressao: expressao . IGUAL expressao_simples - 74 | expressao . DIFERENTE expressao_simples - 75 | expressao . MENOR expressao_simples - 76 | expressao . MENOR_IGUAL expressao_simples - 77 | expressao . MAIOR expressao_simples - 78 | expressao . MAIOR_IGUAL expressao_simples - 91 comando_repetitivo: @18 WHILE expressao . DO @19 comando_sem_rotulo + 84 expressao_simples: expressao_simples MAIS . termo + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - DO shift, and go to state 128 - IGUAL shift, and go to state 84 - DIFERENTE shift, and go to state 85 - MENOR_IGUAL shift, and go to state 86 - MAIOR_IGUAL shift, and go to state 87 - MENOR shift, and go to state 88 - MAIOR shift, and go to state 89 + termo go to state 134 + fator go to state 74 state 103 - 93 cond_else: ELSE comando_sem_rotulo . + 85 expressao_simples: expressao_simples MENOS . termo - $default reduce using rule 93 (cond_else) + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + termo go to state 135 + fator go to state 74 state 104 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA . + 88 termo: termo DIV . fator - $default reduce using rule 16 (declara_var) + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + fator go to state 136 state 105 - 34 secao_pfs: VAR . @11 lista_id_pf DOIS_PONTOS tipo + 87 termo: termo ASTERISCO . fator - $default reduce using rule 33 (@11) + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - @11 go to state 129 + fator go to state 137 state 106 - 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais . @10 FECHA_PARENTESES - 32 paramentros_formais: paramentros_formais . PONTO_E_VIRGULA secao_pfs + 73 simb_leitura: IDENT . - PONTO_E_VIRGULA shift, and go to state 130 - - $default reduce using rule 28 (@10) - - @10 go to state 131 + $default reduce using rule 73 (simb_leitura) state 107 - 31 paramentros_formais: secao_pfs . + 70 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES + 71 lista_leituras: lista_leituras . VIRGULA simb_leitura - $default reduce using rule 31 (paramentros_formais) + FECHA_PARENTESES shift, and go to state 138 + VIRGULA shift, and go to state 139 state 108 - 36 secao_pfs: @12 . lista_id_pf DOIS_PONTOS tipo - - IDENT shift, and go to state 132 + 72 lista_leituras: simb_leitura . - lista_id_pf go to state 133 - parametro go to state 134 + $default reduce using rule 72 (lista_leituras) state 109 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco . @8 PONTO_E_VIRGULA + 74 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES + 75 lista_escritas: lista_escritas . VIRGULA expressao_simples - $default reduce using rule 25 (@8) - - @8 go to state 135 + FECHA_PARENTESES shift, and go to state 140 + VIRGULA shift, and go to state 141 state 110 - 57 atribuicao: @14 ATRIBUICAO . expressao_simples + 76 lista_escritas: expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - expressao_simples go to state 136 - termo go to state 66 - fator go to state 67 + $default reduce using rule 76 (lista_escritas) state 111 - 60 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES - - $default reduce using rule 64 (@17) + 45 comandos: comando PONTO_E_VIRGULA comandos . - lista_parametros_parenteses go to state 137 - @17 go to state 138 + $default reduce using rule 45 (comandos) state 112 - 59 chamada_procedimento: @15 lista_parametros . + 48 comando: numero DOIS_PONTOS comando_sem_rotulo . - $default reduce using rule 59 (chamada_procedimento) + $default reduce using rule 48 (comando) state 113 - 73 expressao: expressao IGUAL expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 77 expressao: expressao . IGUAL expressao_simples + 78 | expressao . DIFERENTE expressao_simples + 79 | expressao . MENOR expressao_simples + 80 | expressao . MENOR_IGUAL expressao_simples + 81 | expressao . MAIOR expressao_simples + 82 | expressao . MAIOR_IGUAL expressao_simples + 95 comando_repetitivo: @20 WHILE expressao . DO @21 comando_sem_rotulo - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 - - $default reduce using rule 73 (expressao) + DO shift, and go to state 142 + IGUAL shift, and go to state 95 + DIFERENTE shift, and go to state 96 + MENOR_IGUAL shift, and go to state 97 + MAIOR_IGUAL shift, and go to state 98 + MENOR shift, and go to state 99 + MAIOR shift, and go to state 100 state 114 - 74 expressao: expressao DIFERENTE expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo - - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + 97 cond_else: ELSE comando_sem_rotulo . - $default reduce using rule 74 (expressao) + $default reduce using rule 97 (cond_else) state 115 - 76 expressao: expressao MENOR_IGUAL expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo - - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA . - $default reduce using rule 76 (expressao) + $default reduce using rule 16 (declara_var) state 116 - 78 expressao: expressao MAIOR_IGUAL expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 38 secao_pfs: VAR @13 . lista_id_pf DOIS_PONTOS tipo - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + IDENT shift, and go to state 119 - $default reduce using rule 78 (expressao) + lista_id_pf go to state 143 + parametro go to state 121 state 117 - 75 expressao: expressao MENOR expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 36 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs + + VAR shift, and go to state 84 - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + $default reduce using rule 39 (@14) - $default reduce using rule 75 (expressao) + secao_pfs go to state 144 + @14 go to state 87 state 118 - 77 expressao: expressao MAIOR expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo - - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + 33 parametros_ou_nada: ABRE_PARENTESES @11 paramentros_formais @12 . FECHA_PARENTESES - $default reduce using rule 77 (expressao) + FECHA_PARENTESES shift, and go to state 145 state 119 - 96 if_then: IF expressao @20 THEN . comando_sem_rotulo - - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - READ shift, and go to state 42 - WRITE shift, and go to state 43 + 43 parametro: IDENT . - $default reduce using rule 89 (@18) - - comando_composto go to state 44 - comando_sem_rotulo go to state 139 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + $default reduce using rule 43 (parametro) state 120 - 80 expressao_simples: expressao_simples MAIS termo . - 83 termo: termo . ASTERISCO fator - 84 | termo . DIV fator - - DIV shift, and go to state 93 - ASTERISCO shift, and go to state 94 + 40 secao_pfs: @14 lista_id_pf . DOIS_PONTOS tipo - $default reduce using rule 80 (expressao_simples) + DOIS_PONTOS shift, and go to state 146 state 121 - 81 expressao_simples: expressao_simples MENOS termo . - 83 termo: termo . ASTERISCO fator - 84 | termo . DIV fator + 41 lista_id_pf: parametro . VIRGULA lista_id_pf + 42 | parametro . - DIV shift, and go to state 93 - ASTERISCO shift, and go to state 94 + VIRGULA shift, and go to state 147 - $default reduce using rule 81 (expressao_simples) + $default reduce using rule 42 (lista_id_pf) state 122 - 84 termo: termo DIV fator . + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada PONTO_E_VIRGULA bloco @10 . PONTO_E_VIRGULA - $default reduce using rule 84 (termo) + PONTO_E_VIRGULA shift, and go to state 148 state 123 - 83 termo: termo ASTERISCO fator . + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco . @8 PONTO_E_VIRGULA + + $default reduce using rule 26 (@8) - $default reduce using rule 83 (termo) + @8 go to state 149 state 124 - 66 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES . + 61 atribuicao: @16 ATRIBUICAO . expressao_simples + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 66 (leitura) + expressao_simples go to state 150 + termo go to state 73 + fator go to state 74 state 125 - 67 lista_leituras: lista_leituras VIRGULA . simb_leitura + 64 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES - IDENT shift, and go to state 95 + $default reduce using rule 68 (@19) - simb_leitura go to state 140 + lista_parametros_parenteses go to state 151 + @19 go to state 152 state 126 - 70 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES . + 63 chamada_procedimento: @17 lista_parametros . - $default reduce using rule 70 (escrita) + $default reduce using rule 63 (chamada_procedimento) state 127 - 71 lista_escritas: lista_escritas VIRGULA . expressao_simples + 77 expressao: expressao IGUAL expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - expressao_simples go to state 141 - termo go to state 66 - fator go to state 67 + $default reduce using rule 77 (expressao) state 128 - 91 comando_repetitivo: @18 WHILE expressao DO . @19 comando_sem_rotulo + 78 expressao: expressao DIFERENTE expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - $default reduce using rule 90 (@19) + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - @19 go to state 142 + $default reduce using rule 78 (expressao) state 129 - 34 secao_pfs: VAR @11 . lista_id_pf DOIS_PONTOS tipo + 80 expressao: expressao MENOR_IGUAL expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - IDENT shift, and go to state 132 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - lista_id_pf go to state 143 - parametro go to state 134 + $default reduce using rule 80 (expressao) state 130 - 32 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs + 82 expressao: expressao MAIOR_IGUAL expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - VAR shift, and go to state 105 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - $default reduce using rule 35 (@12) - - secao_pfs go to state 144 - @12 go to state 108 + $default reduce using rule 82 (expressao) state 131 - 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 . FECHA_PARENTESES + 79 expressao: expressao MENOR expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - FECHA_PARENTESES shift, and go to state 145 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 + + $default reduce using rule 79 (expressao) state 132 - 39 parametro: IDENT . + 81 expressao: expressao MAIOR expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo + + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - $default reduce using rule 39 (parametro) + $default reduce using rule 81 (expressao) state 133 - 36 secao_pfs: @12 lista_id_pf . DOIS_PONTOS tipo + 100 if_then: IF expressao @22 THEN . comando_sem_rotulo - DOIS_PONTOS shift, and go to state 146 + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + READ shift, and go to state 48 + WRITE shift, and go to state 49 + + $default reduce using rule 93 (@20) + + comando_composto go to state 50 + comando_sem_rotulo go to state 153 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 state 134 - 37 lista_id_pf: parametro . VIRGULA lista_id_pf - 38 | parametro . + 84 expressao_simples: expressao_simples MAIS termo . + 87 termo: termo . ASTERISCO fator + 88 | termo . DIV fator - VIRGULA shift, and go to state 147 + DIV shift, and go to state 104 + ASTERISCO shift, and go to state 105 - $default reduce using rule 38 (lista_id_pf) + $default reduce using rule 84 (expressao_simples) state 135 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 . PONTO_E_VIRGULA + 85 expressao_simples: expressao_simples MENOS termo . + 87 termo: termo . ASTERISCO fator + 88 | termo . DIV fator - PONTO_E_VIRGULA shift, and go to state 148 + DIV shift, and go to state 104 + ASTERISCO shift, and go to state 105 + $default reduce using rule 85 (expressao_simples) -state 136 - 57 atribuicao: @14 ATRIBUICAO expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo +state 136 - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + 88 termo: termo DIV fator . - $default reduce using rule 57 (atribuicao) + $default reduce using rule 88 (termo) state 137 - 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES - 63 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA @16 expressao_simples + 87 termo: termo ASTERISCO fator . - FECHA_PARENTESES shift, and go to state 149 - VIRGULA shift, and go to state 150 + $default reduce using rule 87 (termo) state 138 - 65 lista_parametros_parenteses: @17 . expressao_simples - - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 70 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES . - expressao_simples go to state 151 - termo go to state 66 - fator go to state 67 + $default reduce using rule 70 (leitura) state 139 - 96 if_then: IF expressao @20 THEN comando_sem_rotulo . + 71 lista_leituras: lista_leituras VIRGULA . simb_leitura - $default reduce using rule 96 (if_then) + IDENT shift, and go to state 106 + + simb_leitura go to state 154 state 140 - 67 lista_leituras: lista_leituras VIRGULA simb_leitura . + 74 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES . - $default reduce using rule 67 (lista_leituras) + $default reduce using rule 74 (escrita) state 141 - 71 lista_escritas: lista_escritas VIRGULA expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 75 lista_escritas: lista_escritas VIRGULA . expressao_simples - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 - $default reduce using rule 71 (lista_escritas) + expressao_simples go to state 155 + termo go to state 73 + fator go to state 74 state 142 - 91 comando_repetitivo: @18 WHILE expressao DO @19 . comando_sem_rotulo - - T_BEGIN shift, and go to state 34 - IDENT shift, and go to state 39 - IF shift, and go to state 40 - READ shift, and go to state 42 - WRITE shift, and go to state 43 + 95 comando_repetitivo: @20 WHILE expressao DO . @21 comando_sem_rotulo - $default reduce using rule 89 (@18) + $default reduce using rule 94 (@21) - comando_composto go to state 44 - comando_sem_rotulo go to state 152 - atribuicao_ou_procedimento go to state 48 - leitura go to state 49 - escrita go to state 50 - comando_repetitivo go to state 52 - @18 go to state 53 - comando_condicional go to state 54 - if_then go to state 55 + @21 go to state 156 state 143 - 34 secao_pfs: VAR @11 lista_id_pf . DOIS_PONTOS tipo + 38 secao_pfs: VAR @13 lista_id_pf . DOIS_PONTOS tipo - DOIS_PONTOS shift, and go to state 153 + DOIS_PONTOS shift, and go to state 157 state 144 - 32 paramentros_formais: paramentros_formais PONTO_E_VIRGULA secao_pfs . + 36 paramentros_formais: paramentros_formais PONTO_E_VIRGULA secao_pfs . - $default reduce using rule 32 (paramentros_formais) + $default reduce using rule 36 (paramentros_formais) state 145 - 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 FECHA_PARENTESES . + 33 parametros_ou_nada: ABRE_PARENTESES @11 paramentros_formais @12 FECHA_PARENTESES . - $default reduce using rule 29 (parametros_ou_nada) + $default reduce using rule 33 (parametros_ou_nada) state 146 - 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS . tipo + 40 secao_pfs: @14 lista_id_pf DOIS_PONTOS . tipo - IDENT shift, and go to state 57 + IDENT shift, and go to state 63 - tipo go to state 154 + tipo go to state 158 state 147 - 37 lista_id_pf: parametro VIRGULA . lista_id_pf + 41 lista_id_pf: parametro VIRGULA . lista_id_pf - IDENT shift, and go to state 132 + IDENT shift, and go to state 119 - lista_id_pf go to state 155 - parametro go to state 134 + lista_id_pf go to state 159 + parametro go to state 121 state 148 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA . + 30 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada PONTO_E_VIRGULA bloco @10 PONTO_E_VIRGULA . - $default reduce using rule 26 (declaracao_procedimento) + $default reduce using rule 30 (declaracao_funcao) state 149 - 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES . + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 . PONTO_E_VIRGULA - $default reduce using rule 60 (lista_parametros) + PONTO_E_VIRGULA shift, and go to state 160 state 150 - 63 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . @16 expressao_simples + 61 atribuicao: @16 ATRIBUICAO expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - $default reduce using rule 62 (@16) + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - @16 go to state 156 + $default reduce using rule 61 (atribuicao) state 151 - 65 lista_parametros_parenteses: @17 expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 64 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES + 67 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA @18 expressao_simples - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 - - $default reduce using rule 65 (lista_parametros_parenteses) + FECHA_PARENTESES shift, and go to state 161 + VIRGULA shift, and go to state 162 state 152 - 91 comando_repetitivo: @18 WHILE expressao DO @19 comando_sem_rotulo . + 69 lista_parametros_parenteses: @19 . expressao_simples - $default reduce using rule 91 (comando_repetitivo) + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + expressao_simples go to state 163 + termo go to state 73 + fator go to state 74 -state 153 - 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS . tipo +state 153 - IDENT shift, and go to state 57 + 100 if_then: IF expressao @22 THEN comando_sem_rotulo . - tipo go to state 157 + $default reduce using rule 100 (if_then) state 154 - 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS tipo . + 71 lista_leituras: lista_leituras VIRGULA simb_leitura . - $default reduce using rule 36 (secao_pfs) + $default reduce using rule 71 (lista_leituras) state 155 - 37 lista_id_pf: parametro VIRGULA lista_id_pf . + 75 lista_escritas: lista_escritas VIRGULA expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - $default reduce using rule 37 (lista_id_pf) + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 + + $default reduce using rule 75 (lista_escritas) state 156 - 63 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @16 . expressao_simples + 95 comando_repetitivo: @20 WHILE expressao DO @21 . comando_sem_rotulo + + T_BEGIN shift, and go to state 38 + IDENT shift, and go to state 45 + IF shift, and go to state 46 + READ shift, and go to state 48 + WRITE shift, and go to state 49 - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + $default reduce using rule 93 (@20) - expressao_simples go to state 158 - termo go to state 66 - fator go to state 67 + comando_composto go to state 50 + comando_sem_rotulo go to state 164 + atribuicao_ou_procedimento go to state 54 + leitura go to state 55 + escrita go to state 56 + comando_repetitivo go to state 58 + @20 go to state 59 + comando_condicional go to state 60 + if_then go to state 61 state 157 - 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS tipo . + 38 secao_pfs: VAR @13 lista_id_pf DOIS_PONTOS . tipo - $default reduce using rule 34 (secao_pfs) + IDENT shift, and go to state 63 + + tipo go to state 165 state 158 - 63 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @16 expressao_simples . - 80 expressao_simples: expressao_simples . MAIS termo - 81 | expressao_simples . MENOS termo + 40 secao_pfs: @14 lista_id_pf DOIS_PONTOS tipo . + + $default reduce using rule 40 (secao_pfs) + + +state 159 + + 41 lista_id_pf: parametro VIRGULA lista_id_pf . + + $default reduce using rule 41 (lista_id_pf) + + +state 160 + + 27 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA . + + $default reduce using rule 27 (declaracao_procedimento) + + +state 161 + + 64 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES . + + $default reduce using rule 64 (lista_parametros) + + +state 162 + + 67 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . @18 expressao_simples + + $default reduce using rule 66 (@18) + + @18 go to state 166 + + +state 163 + + 69 lista_parametros_parenteses: @19 expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo + + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 + + $default reduce using rule 69 (lista_parametros_parenteses) + + +state 164 + + 95 comando_repetitivo: @20 WHILE expressao DO @21 comando_sem_rotulo . + + $default reduce using rule 95 (comando_repetitivo) + + +state 165 + + 38 secao_pfs: VAR @13 lista_id_pf DOIS_PONTOS tipo . + + $default reduce using rule 38 (secao_pfs) + + +state 166 + + 67 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @18 . expressao_simples + + IDENT shift, and go to state 69 + NUMERO shift, and go to state 70 + + expressao_simples go to state 167 + termo go to state 73 + fator go to state 74 + + +state 167 + + 67 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @18 expressao_simples . + 84 expressao_simples: expressao_simples . MAIS termo + 85 | expressao_simples . MENOS termo - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + MAIS shift, and go to state 102 + MENOS shift, and go to state 103 - $default reduce using rule 63 (lista_parametros_parenteses) + $default reduce using rule 67 (lista_parametros_parenteses) diff --git a/compilador.y b/compilador.y index 654f76f294519d935065d1b2983f0b988ffcf52d..420f8f92038e5def8f5b16b070573502ea672746 100644 --- a/compilador.y +++ b/compilador.y @@ -155,6 +155,7 @@ lista_idents: lista_idents VIRGULA IDENT // REGRA 11 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento + | declaracao_funcao | ; @@ -191,12 +192,47 @@ declaracao_procedimento: PROCEDURE IDENT { PONTO_E_VIRGULA ; +// REGRA 13 +// Regra ajustada para declaração de procedimento +declaracao_funcao: FUNCTION IDENT { + // Insere o funcao na tabela de símbolos + info_t info; + char r_func[4]; + sprintf(r_func, "R%02d", rot_id); + rot_id += 1; + strcpy(info.fun.rot,r_func); + info.fun.quant = 0; + info.fun.param = NULL; + info.fun.tipo = NSEI; + + // Incrementa o nível léxico + nivel_lexico += 1; + desloc = 0; // Reinicia deslocamento para variáveis locais do novo nível + + insere_ts(token, FUN, nivel_lexico, info, ts); + empilha(token,proc); + + char buffer[50]; + sprintf(buffer,"ENPR %d",nivel_lexico); + geraCodigo(r_func,buffer); + mostra_ts(ts); + } + parametros_ou_nada + PONTO_E_VIRGULA bloco + { + // Retorna ao nível léxico anterior e mantém o deslocamento atualizado + nivel_lexico -= 1; + } + PONTO_E_VIRGULA +; + parametros_ou_nada: ABRE_PARENTESES {num_param = 0;} paramentros_formais { char proc_ident[50]; desempilha(proc_ident,proc); adiciona_param(proc_ident,num_param,ts); + mostra_ts(ts); } FECHA_PARENTESES | diff --git a/teste10.pas b/teste10.pas new file mode 100644 index 0000000000000000000000000000000000000000..339526fc4d838906e237c5f415cf214bb39ad39e --- /dev/null +++ b/teste10.pas @@ -0,0 +1,11 @@ +program proc1 (input, output); + var x: integer; + function f(var a: integer; b: integer): integer; + var z: integer; + begin + z := a; + a := 1; + end; +begin + x := f(x, 2+3); +end. \ No newline at end of file diff --git a/teste9.pas b/teste9.pas index 96ad0495cf12b4366870d6c70acab9dd991f071d..5e3e87b6a6929dbeb627cc92778f31887286931b 100644 --- a/teste9.pas +++ b/teste9.pas @@ -8,5 +8,5 @@ program proc1 (input, output); end; begin x := 8; - p(x+9, 2+3); + p(x, 2+3); end. \ No newline at end of file