diff --git a/MEPA b/MEPA index 64486ddc95b7ca36bcb2a343316ade68a17fbee7..1b8ad2f68c6c365f19bc28c66cc48e4ea862f1ff 100644 --- a/MEPA +++ b/MEPA @@ -5,17 +5,19 @@ R01: ENPR 1 AMEM 1 DSVS R02 R02: NADA + CRVI 1,-5 ARMZ 1,0 CRCT 1 ARMI 1,-5 DMEM 1 + RTPR 1,2 R00: NADA - AMEM 1 - CREN 1,0 + CRCT 8 + ARMZ 0,0 + CREN 0,0 CRCT 2 CRCT 3 SOMA - CHPR R01,0 - ARMZ 0,0 - DMEM 0 + CHPR R01,2 + DMEM 1 PARA diff --git a/compilador.output b/compilador.output index 5732871be4bff4cbf0cf6ab5a94336382b3e7451..39be27f4b52065aea45c766d5648cc801d15674a 100644 --- a/compilador.output +++ b/compilador.output @@ -1,11 +1,11 @@ -Terminals which are not used +Terminals unused in grammar - TYPE - ARRAY - GOTO - OR - AND - NOT + TYPE + ARRAY + GOTO + OR + AND + NOT State 78 conflicts: 1 reduce/reduce @@ -15,34 +15,34 @@ Grammar 0 $accept: programa $end - 1 @1: /* empty */ + 1 $@1: %empty - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO - 3 @2: /* empty */ + 3 $@2: %empty - 4 @3: /* empty */ + 4 $@3: %empty - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto + 5 bloco: parte_declara_rotulos parte_declara_vars $@2 parte_declara_subrotinas $@3 comando_composto 6 parte_declara_rotulos: LABEL VIRGULA - 7 | /* empty */ + 7 | %empty 8 parte_declara_vars: var - 9 @4: /* empty */ + 9 $@4: %empty - 10 var: @4 VAR declara_vars - 11 | /* empty */ + 10 var: $@4 VAR declara_vars + 11 | %empty 12 declara_vars: declara_vars declara_var 13 | declara_var - 14 @5: /* empty */ + 14 $@5: %empty - 15 @6: /* empty */ + 15 $@6: %empty - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA + 16 declara_var: $@5 lista_id_var DOIS_PONTOS tipo $@6 PONTO_E_VIRGULA 17 tipo: IDENT @@ -54,39 +54,39 @@ Grammar 22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento 23 | declaracao_funcao - 24 | /* empty */ + 24 | %empty - 25 @7: /* empty */ + 25 $@7: %empty - 26 @8: /* empty */ + 26 $@8: %empty - 27 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 - 28 @9: /* empty */ + 28 $@9: %empty - 29 @10: /* empty */ + 29 $@10: %empty - 30 @11: /* empty */ + 30 $@11: %empty - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA - 32 @12: /* empty */ + 32 $@12: %empty - 33 @13: /* empty */ + 33 $@13: %empty - 34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 FECHA_PARENTESES - 35 | /* empty */ + 34 parametros_ou_nada: ABRE_PARENTESES $@12 paramentros_formais $@13 FECHA_PARENTESES + 35 | %empty 36 paramentros_formais: secao_pfs 37 | paramentros_formais PONTO_E_VIRGULA secao_pfs - 38 @14: /* empty */ + 38 $@14: %empty - 39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS tipo + 39 secao_pfs: VAR $@14 lista_id_pf DOIS_PONTOS tipo - 40 @15: /* empty */ + 40 $@15: %empty - 41 secao_pfs: @15 lista_id_pf DOIS_PONTOS tipo + 41 secao_pfs: $@15 lista_id_pf DOIS_PONTOS tipo 42 lista_id_pf: parametro VIRGULA lista_id_pf 43 | parametro @@ -97,7 +97,7 @@ Grammar 46 comandos: comando PONTO_E_VIRGULA comandos 47 | comando PONTO_E_VIRGULA - 48 | /* empty */ + 48 | %empty 49 comando: numero DOIS_PONTOS comando_sem_rotulo 50 | comando_sem_rotulo @@ -109,31 +109,31 @@ Grammar 55 | leitura 56 | escrita - 57 @16: /* empty */ + 57 $@16: %empty - 58 atribuicao_ou_procedimento: IDENT @16 atribuicao_ou_procedimento_token + 58 atribuicao_ou_procedimento: IDENT $@16 atribuicao_ou_procedimento_token 59 atribuicao_ou_procedimento_token: atribuicao 60 | chamada_procedimento - 61 @17: /* empty */ + 61 $@17: %empty - 62 atribuicao: @17 ATRIBUICAO expressao_simples + 62 atribuicao: $@17 ATRIBUICAO expressao_simples - 63 @18: /* empty */ + 63 $@18: %empty - 64 chamada_procedimento: @18 lista_parametros + 64 chamada_procedimento: $@18 lista_parametros 65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES - 66 | /* empty */ + 66 | %empty - 67 @19: /* empty */ + 67 $@19: %empty - 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 expressao_simples + 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA $@19 expressao_simples - 69 @20: /* empty */ + 69 $@20: %empty - 70 lista_parametros_parenteses: @20 expressao_simples + 70 lista_parametros_parenteses: $@20 expressao_simples 71 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES @@ -163,301 +163,366 @@ Grammar 89 | termo DIV fator 90 | fator - 91 @21: /* empty */ + 91 $@21: %empty - 92 fator: IDENT @21 chamada_procedimento + 92 fator: IDENT $@21 chamada_procedimento 93 | NUMERO 94 numero: NUMERO - 95 @22: /* empty */ + 95 $@22: %empty - 96 @23: /* empty */ + 96 $@23: %empty - 97 comando_repetitivo: @22 WHILE expressao DO @23 comando_sem_rotulo + 97 comando_repetitivo: $@22 WHILE expressao DO $@23 comando_sem_rotulo 98 comando_condicional: if_then cond_else 99 cond_else: ELSE comando_sem_rotulo - 100 | /* empty */ + 100 | %empty - 101 @24: /* empty */ + 101 $@24: %empty - 102 if_then: IF expressao @24 THEN comando_sem_rotulo + 102 if_then: IF expressao $@24 THEN comando_sem_rotulo Terminals, with rules where they appear -$end (0) 0 -error (256) -PROGRAM (258) 2 -ABRE_PARENTESES (259) 2 34 65 71 75 -FECHA_PARENTESES (260) 2 34 65 71 75 -VIRGULA (261) 6 18 20 42 68 72 76 -PONTO_E_VIRGULA (262) 2 16 27 31 37 46 47 -DOIS_PONTOS (263) 16 31 39 41 49 -PONTO (264) 2 -T_BEGIN (265) 45 -T_END (266) 45 -VAR (267) 10 39 -IDENT (268) 2 17 18 19 20 21 27 31 44 58 74 92 -ATRIBUICAO (269) 62 -LABEL (270) 6 -TYPE (271) -ARRAY (272) -PROCEDURE (273) 27 -FUNCTION (274) 31 -GOTO (275) -IF (276) 102 -THEN (277) 102 -ELSE (278) 99 -WHILE (279) 97 -DO (280) 97 -OR (281) -DIV (282) 89 -AND (283) -NOT (284) -IGUAL (285) 78 -DIFERENTE (286) 79 -MENOR_IGUAL (287) 81 -MAIOR_IGUAL (288) 83 -MENOR (289) 80 -MAIOR (290) 82 -MAIS (291) 85 -MENOS (292) 86 -ASTERISCO (293) 88 -NUMERO (294) 93 94 -READ (295) 71 -WRITE (296) 75 -LOWER_THAN_ELSE (297) + $end (0) 0 + error (256) + PROGRAM (258) 2 + ABRE_PARENTESES (259) 2 34 65 71 75 + FECHA_PARENTESES (260) 2 34 65 71 75 + VIRGULA (261) 6 18 20 42 68 72 76 + PONTO_E_VIRGULA (262) 2 16 27 31 37 46 47 + DOIS_PONTOS (263) 16 31 39 41 49 + PONTO (264) 2 + T_BEGIN (265) 45 + T_END (266) 45 + VAR (267) 10 39 + IDENT (268) 2 17 18 19 20 21 27 31 44 58 74 92 + ATRIBUICAO (269) 62 + LABEL (270) 6 + TYPE (271) + ARRAY (272) + PROCEDURE (273) 27 + FUNCTION (274) 31 + GOTO (275) + IF (276) 102 + THEN (277) 102 + ELSE (278) 99 + WHILE (279) 97 + DO (280) 97 + OR (281) + DIV (282) 89 + AND (283) + NOT (284) + IGUAL (285) 78 + DIFERENTE (286) 79 + MENOR_IGUAL (287) 81 + MAIOR_IGUAL (288) 83 + MENOR (289) 80 + MAIOR (290) 82 + MAIS (291) 85 + MENOS (292) 86 + ASTERISCO (293) 88 + NUMERO (294) 93 94 + READ (295) 71 + WRITE (296) 75 + LOWER_THAN_ELSE (297) Nonterminals, with rules where they appear -$accept (43) - on left: 0 -programa (44) - on left: 2, on right: 0 -@1 (45) - on left: 1, on right: 2 -bloco (46) - on left: 5, on right: 2 27 31 -@2 (47) - on left: 3, on right: 5 -@3 (48) - on left: 4, on right: 5 -parte_declara_rotulos (49) - on left: 6 7, on right: 5 -parte_declara_vars (50) - on left: 8, on right: 5 -var (51) - on left: 10 11, on right: 8 -@4 (52) - on left: 9, on right: 10 -declara_vars (53) - on left: 12 13, on right: 10 12 -declara_var (54) - on left: 16, on right: 12 13 -@5 (55) - on left: 14, on right: 16 -@6 (56) - on left: 15, on right: 16 -tipo (57) - on left: 17, on right: 16 31 39 41 -lista_id_var (58) - on left: 18 19, on right: 16 18 -lista_idents (59) - on left: 20 21, on right: 2 20 -parte_declara_subrotinas (60) - on left: 22 23 24, on right: 5 22 -declaracao_procedimento (61) - on left: 27, on right: 22 -@7 (62) - on left: 25, on right: 27 -@8 (63) - on left: 26, on right: 27 -declaracao_funcao (64) - on left: 31, on right: 23 -@9 (65) - on left: 28, on right: 31 -@10 (66) - on left: 29, on right: 31 -@11 (67) - on left: 30, on right: 31 -parametros_ou_nada (68) - on left: 34 35, on right: 27 31 -@12 (69) - on left: 32, on right: 34 -@13 (70) - on left: 33, on right: 34 -paramentros_formais (71) - on left: 36 37, on right: 34 37 -secao_pfs (72) - on left: 39 41, on right: 36 37 -@14 (73) - on left: 38, on right: 39 -@15 (74) - on left: 40, on right: 41 -lista_id_pf (75) - on left: 42 43, on right: 39 41 42 -parametro (76) - on left: 44, on right: 42 43 -comando_composto (77) - on left: 45, on right: 5 52 -comandos (78) - on left: 46 47 48, on right: 45 46 -comando (79) - on left: 49 50, on right: 46 47 -comando_sem_rotulo (80) - on left: 51 52 53 54 55 56, on right: 49 50 97 99 102 -atribuicao_ou_procedimento (81) - on left: 58, on right: 51 -@16 (82) - on left: 57, on right: 58 -atribuicao_ou_procedimento_token (83) - on left: 59 60, on right: 58 -atribuicao (84) - on left: 62, on right: 59 -@17 (85) - on left: 61, on right: 62 -chamada_procedimento (86) - on left: 64, on right: 60 92 -@18 (87) - on left: 63, on right: 64 -lista_parametros (88) - on left: 65 66, on right: 64 -lista_parametros_parenteses (89) - on left: 68 70, on right: 65 68 -@19 (90) - on left: 67, on right: 68 -@20 (91) - on left: 69, on right: 70 -leitura (92) - on left: 71, on right: 55 -lista_leituras (93) - on left: 72 73, on right: 71 72 -simb_leitura (94) - on left: 74, on right: 72 73 -escrita (95) - on left: 75, on right: 56 -lista_escritas (96) - on left: 76 77, on right: 75 76 -expressao (97) - on left: 78 79 80 81 82 83 84, on right: 78 79 80 81 82 83 97 102 -expressao_simples (98) - on left: 85 86 87, on right: 62 68 70 76 77 78 79 80 81 82 83 84 - 85 86 -termo (99) - on left: 88 89 90, on right: 85 86 87 88 89 -fator (100) - on left: 92 93, on right: 88 89 90 -@21 (101) - on left: 91, on right: 92 -numero (102) - on left: 94, on right: 49 -comando_repetitivo (103) - on left: 97, on right: 54 -@22 (104) - on left: 95, on right: 97 -@23 (105) - on left: 96, on right: 97 -comando_condicional (106) - on left: 98, on right: 53 -cond_else (107) - on left: 99 100, on right: 98 -if_then (108) - on left: 102, on right: 98 -@24 (109) - on left: 101, on right: 102 - - -state 0 + $accept (43) + on left: 0 + programa (44) + on left: 2 + on right: 0 + $@1 (45) + on left: 1 + on right: 2 + bloco (46) + on left: 5 + on right: 2 27 31 + $@2 (47) + on left: 3 + on right: 5 + $@3 (48) + on left: 4 + on right: 5 + parte_declara_rotulos (49) + on left: 6 7 + on right: 5 + parte_declara_vars (50) + on left: 8 + on right: 5 + var (51) + on left: 10 11 + on right: 8 + $@4 (52) + on left: 9 + on right: 10 + declara_vars (53) + on left: 12 13 + on right: 10 12 + declara_var (54) + on left: 16 + on right: 12 13 + $@5 (55) + on left: 14 + on right: 16 + $@6 (56) + on left: 15 + on right: 16 + tipo (57) + on left: 17 + on right: 16 31 39 41 + lista_id_var (58) + on left: 18 19 + on right: 16 18 + lista_idents (59) + on left: 20 21 + on right: 2 20 + parte_declara_subrotinas (60) + on left: 22 23 24 + on right: 5 22 + declaracao_procedimento (61) + on left: 27 + on right: 22 + $@7 (62) + on left: 25 + on right: 27 + $@8 (63) + on left: 26 + on right: 27 + declaracao_funcao (64) + on left: 31 + on right: 23 + $@9 (65) + on left: 28 + on right: 31 + $@10 (66) + on left: 29 + on right: 31 + $@11 (67) + on left: 30 + on right: 31 + parametros_ou_nada (68) + on left: 34 35 + on right: 27 31 + $@12 (69) + on left: 32 + on right: 34 + $@13 (70) + on left: 33 + on right: 34 + paramentros_formais (71) + on left: 36 37 + on right: 34 37 + secao_pfs (72) + on left: 39 41 + on right: 36 37 + $@14 (73) + on left: 38 + on right: 39 + $@15 (74) + on left: 40 + on right: 41 + lista_id_pf (75) + on left: 42 43 + on right: 39 41 42 + parametro (76) + on left: 44 + on right: 42 43 + comando_composto (77) + on left: 45 + on right: 5 52 + comandos (78) + on left: 46 47 48 + on right: 45 46 + comando (79) + on left: 49 50 + on right: 46 47 + comando_sem_rotulo (80) + on left: 51 52 53 54 55 56 + on right: 49 50 97 99 102 + atribuicao_ou_procedimento (81) + on left: 58 + on right: 51 + $@16 (82) + on left: 57 + on right: 58 + atribuicao_ou_procedimento_token (83) + on left: 59 60 + on right: 58 + atribuicao (84) + on left: 62 + on right: 59 + $@17 (85) + on left: 61 + on right: 62 + chamada_procedimento (86) + on left: 64 + on right: 60 92 + $@18 (87) + on left: 63 + on right: 64 + lista_parametros (88) + on left: 65 66 + on right: 64 + lista_parametros_parenteses (89) + on left: 68 70 + on right: 65 68 + $@19 (90) + on left: 67 + on right: 68 + $@20 (91) + on left: 69 + on right: 70 + leitura (92) + on left: 71 + on right: 55 + lista_leituras (93) + on left: 72 73 + on right: 71 72 + simb_leitura (94) + on left: 74 + on right: 72 73 + escrita (95) + on left: 75 + on right: 56 + lista_escritas (96) + on left: 76 77 + on right: 75 76 + expressao (97) + on left: 78 79 80 81 82 83 84 + on right: 78 79 80 81 82 83 97 102 + expressao_simples (98) + on left: 85 86 87 + on right: 62 68 70 76 77 78 79 80 81 82 83 84 85 86 + termo (99) + on left: 88 89 90 + on right: 85 86 87 88 89 + fator (100) + on left: 92 93 + on right: 88 89 90 + $@21 (101) + on left: 91 + on right: 92 + numero (102) + on left: 94 + on right: 49 + comando_repetitivo (103) + on left: 97 + on right: 54 + $@22 (104) + on left: 95 + on right: 97 + $@23 (105) + on left: 96 + on right: 97 + comando_condicional (106) + on left: 98 + on right: 53 + cond_else (107) + on left: 99 100 + on right: 98 + if_then (108) + on left: 102 + on right: 98 + $@24 (109) + on left: 101 + on right: 102 + + +State 0 0 $accept: . programa $end - $default reduce using rule 1 (@1) + $default reduce using rule 1 ($@1) programa go to state 1 - @1 go to state 2 + $@1 go to state 2 -state 1 +State 1 0 $accept: programa . $end $end shift, and go to state 3 -state 2 +State 2 - 2 programa: @1 . PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 . PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO PROGRAM shift, and go to state 4 -state 3 +State 3 0 $accept: programa $end . $default accept -state 4 +State 4 - 2 programa: @1 PROGRAM . IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM . IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO IDENT shift, and go to state 5 -state 5 +State 5 - 2 programa: @1 PROGRAM IDENT . ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM IDENT . ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO ABRE_PARENTESES shift, and go to state 6 -state 6 +State 6 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES . lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES . lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO IDENT shift, and go to state 7 lista_idents go to state 8 -state 7 +State 7 21 lista_idents: IDENT . $default reduce using rule 21 (lista_idents) -state 8 +State 8 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents . FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents . FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO 20 lista_idents: lista_idents . VIRGULA IDENT FECHA_PARENTESES shift, and go to state 9 VIRGULA shift, and go to state 10 -state 9 +State 9 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES . PONTO_E_VIRGULA bloco PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES . PONTO_E_VIRGULA bloco PONTO PONTO_E_VIRGULA shift, and go to state 11 -state 10 +State 10 20 lista_idents: lista_idents VIRGULA . IDENT IDENT shift, and go to state 12 -state 11 +State 11 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA . bloco PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA . bloco PONTO LABEL shift, and go to state 13 @@ -467,79 +532,79 @@ state 11 parte_declara_rotulos go to state 15 -state 12 +State 12 20 lista_idents: lista_idents VIRGULA IDENT . $default reduce using rule 20 (lista_idents) -state 13 +State 13 6 parte_declara_rotulos: LABEL . VIRGULA VIRGULA shift, and go to state 16 -state 14 +State 14 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco . PONTO + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco . PONTO PONTO shift, and go to state 17 -state 15 +State 15 - 5 bloco: parte_declara_rotulos . parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto + 5 bloco: parte_declara_rotulos . parte_declara_vars $@2 parte_declara_subrotinas $@3 comando_composto - VAR reduce using rule 9 (@4) + VAR reduce using rule 9 ($@4) $default reduce using rule 11 (var) parte_declara_vars go to state 18 var go to state 19 - @4 go to state 20 + $@4 go to state 20 -state 16 +State 16 6 parte_declara_rotulos: LABEL VIRGULA . $default reduce using rule 6 (parte_declara_rotulos) -state 17 +State 17 - 2 programa: @1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO . + 2 programa: $@1 PROGRAM IDENT ABRE_PARENTESES lista_idents FECHA_PARENTESES PONTO_E_VIRGULA bloco PONTO . $default reduce using rule 2 (programa) -state 18 +State 18 - 5 bloco: parte_declara_rotulos parte_declara_vars . @2 parte_declara_subrotinas @3 comando_composto + 5 bloco: parte_declara_rotulos parte_declara_vars . $@2 parte_declara_subrotinas $@3 comando_composto - $default reduce using rule 3 (@2) + $default reduce using rule 3 ($@2) - @2 go to state 21 + $@2 go to state 21 -state 19 +State 19 8 parte_declara_vars: var . $default reduce using rule 8 (parte_declara_vars) -state 20 +State 20 - 10 var: @4 . VAR declara_vars + 10 var: $@4 . VAR declara_vars VAR shift, and go to state 22 -state 21 +State 21 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 . parte_declara_subrotinas @3 comando_composto + 5 bloco: parte_declara_rotulos parte_declara_vars $@2 . parte_declara_subrotinas $@3 comando_composto FUNCTION shift, and go to state 23 @@ -549,130 +614,130 @@ state 21 declaracao_funcao go to state 25 -state 22 +State 22 - 10 var: @4 VAR . declara_vars + 10 var: $@4 VAR . declara_vars - $default reduce using rule 14 (@5) + $default reduce using rule 14 ($@5) declara_vars go to state 26 declara_var go to state 27 - @5 go to state 28 + $@5 go to state 28 -state 23 +State 23 - 31 declaracao_funcao: FUNCTION . IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION . IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA IDENT shift, and go to state 29 -state 24 +State 24 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas . @3 comando_composto + 5 bloco: parte_declara_rotulos parte_declara_vars $@2 parte_declara_subrotinas . $@3 comando_composto 22 parte_declara_subrotinas: parte_declara_subrotinas . declaracao_procedimento PROCEDURE shift, and go to state 30 - $default reduce using rule 4 (@3) + $default reduce using rule 4 ($@3) - @3 go to state 31 + $@3 go to state 31 declaracao_procedimento go to state 32 -state 25 +State 25 23 parte_declara_subrotinas: declaracao_funcao . $default reduce using rule 23 (parte_declara_subrotinas) -state 26 +State 26 - 10 var: @4 VAR declara_vars . + 10 var: $@4 VAR declara_vars . 12 declara_vars: declara_vars . declara_var - IDENT reduce using rule 14 (@5) + IDENT reduce using rule 14 ($@5) $default reduce using rule 10 (var) declara_var go to state 33 - @5 go to state 28 + $@5 go to state 28 -state 27 +State 27 13 declara_vars: declara_var . $default reduce using rule 13 (declara_vars) -state 28 +State 28 - 16 declara_var: @5 . lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA + 16 declara_var: $@5 . lista_id_var DOIS_PONTOS tipo $@6 PONTO_E_VIRGULA IDENT shift, and go to state 34 lista_id_var go to state 35 -state 29 +State 29 - 31 declaracao_funcao: FUNCTION IDENT . @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT . $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA - $default reduce using rule 28 (@9) + $default reduce using rule 28 ($@9) - @9 go to state 36 + $@9 go to state 36 -state 30 +State 30 - 27 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 IDENT shift, and go to state 37 -state 31 +State 31 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 . comando_composto + 5 bloco: parte_declara_rotulos parte_declara_vars $@2 parte_declara_subrotinas $@3 . comando_composto T_BEGIN shift, and go to state 38 comando_composto go to state 39 -state 32 +State 32 22 parte_declara_subrotinas: parte_declara_subrotinas declaracao_procedimento . $default reduce using rule 22 (parte_declara_subrotinas) -state 33 +State 33 12 declara_vars: declara_vars declara_var . $default reduce using rule 12 (declara_vars) -state 34 +State 34 19 lista_id_var: IDENT . $default reduce using rule 19 (lista_id_var) -state 35 +State 35 - 16 declara_var: @5 lista_id_var . DOIS_PONTOS tipo @6 PONTO_E_VIRGULA + 16 declara_var: $@5 lista_id_var . DOIS_PONTOS tipo $@6 PONTO_E_VIRGULA 18 lista_id_var: lista_id_var . VIRGULA IDENT VIRGULA shift, and go to state 40 DOIS_PONTOS shift, and go to state 41 -state 36 +State 36 - 31 declaracao_funcao: FUNCTION IDENT @9 . parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 . parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA ABRE_PARENTESES shift, and go to state 42 @@ -681,16 +746,16 @@ state 36 parametros_ou_nada go to state 43 -state 37 +State 37 - 27 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 - $default reduce using rule 25 (@7) + $default reduce using rule 25 ($@7) - @7 go to state 44 + $@7 go to state 44 -state 38 +State 38 45 comando_composto: T_BEGIN . comandos T_END @@ -701,7 +766,7 @@ state 38 READ shift, and go to state 48 WRITE shift, and go to state 49 - WHILE reduce using rule 95 (@22) + WHILE reduce using rule 95 ($@22) $default reduce using rule 48 (comandos) comando_composto go to state 50 @@ -713,53 +778,53 @@ state 38 escrita go to state 56 numero go to state 57 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 39 +State 39 - 5 bloco: parte_declara_rotulos parte_declara_vars @2 parte_declara_subrotinas @3 comando_composto . + 5 bloco: parte_declara_rotulos parte_declara_vars $@2 parte_declara_subrotinas $@3 comando_composto . $default reduce using rule 5 (bloco) -state 40 +State 40 18 lista_id_var: lista_id_var VIRGULA . IDENT IDENT shift, and go to state 62 -state 41 +State 41 - 16 declara_var: @5 lista_id_var DOIS_PONTOS . tipo @6 PONTO_E_VIRGULA + 16 declara_var: $@5 lista_id_var DOIS_PONTOS . tipo $@6 PONTO_E_VIRGULA IDENT shift, and go to state 63 tipo go to state 64 -state 42 +State 42 - 34 parametros_ou_nada: ABRE_PARENTESES . @12 paramentros_formais @13 FECHA_PARENTESES + 34 parametros_ou_nada: ABRE_PARENTESES . $@12 paramentros_formais $@13 FECHA_PARENTESES - $default reduce using rule 32 (@12) + $default reduce using rule 32 ($@12) - @12 go to state 65 + $@12 go to state 65 -state 43 +State 43 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada . DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada . DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA DOIS_PONTOS shift, and go to state 66 -state 44 +State 44 - 27 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 ABRE_PARENTESES shift, and go to state 42 @@ -768,18 +833,18 @@ state 44 parametros_ou_nada go to state 67 -state 45 +State 45 - 58 atribuicao_ou_procedimento: IDENT . @16 atribuicao_ou_procedimento_token + 58 atribuicao_ou_procedimento: IDENT . $@16 atribuicao_ou_procedimento_token - $default reduce using rule 57 (@16) + $default reduce using rule 57 ($@16) - @16 go to state 68 + $@16 go to state 68 -state 46 +State 46 - 102 if_then: IF . expressao @24 THEN comando_sem_rotulo + 102 if_then: IF . expressao $@24 THEN comando_sem_rotulo IDENT shift, and go to state 69 NUMERO shift, and go to state 70 @@ -790,42 +855,42 @@ state 46 fator go to state 74 -state 47 +State 47 94 numero: NUMERO . $default reduce using rule 94 (numero) -state 48 +State 48 71 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES ABRE_PARENTESES shift, and go to state 75 -state 49 +State 49 75 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES ABRE_PARENTESES shift, and go to state 76 -state 50 +State 50 52 comando_sem_rotulo: comando_composto . $default reduce using rule 52 (comando_sem_rotulo) -state 51 +State 51 45 comando_composto: T_BEGIN comandos . T_END T_END shift, and go to state 77 -state 52 +State 52 46 comandos: comando . PONTO_E_VIRGULA comandos 47 | comando . PONTO_E_VIRGULA @@ -833,63 +898,63 @@ state 52 PONTO_E_VIRGULA shift, and go to state 78 -state 53 +State 53 50 comando: comando_sem_rotulo . $default reduce using rule 50 (comando) -state 54 +State 54 51 comando_sem_rotulo: atribuicao_ou_procedimento . $default reduce using rule 51 (comando_sem_rotulo) -state 55 +State 55 55 comando_sem_rotulo: leitura . $default reduce using rule 55 (comando_sem_rotulo) -state 56 +State 56 56 comando_sem_rotulo: escrita . $default reduce using rule 56 (comando_sem_rotulo) -state 57 +State 57 49 comando: numero . DOIS_PONTOS comando_sem_rotulo DOIS_PONTOS shift, and go to state 79 -state 58 +State 58 54 comando_sem_rotulo: comando_repetitivo . $default reduce using rule 54 (comando_sem_rotulo) -state 59 +State 59 - 97 comando_repetitivo: @22 . WHILE expressao DO @23 comando_sem_rotulo + 97 comando_repetitivo: $@22 . WHILE expressao DO $@23 comando_sem_rotulo WHILE shift, and go to state 80 -state 60 +State 60 53 comando_sem_rotulo: comando_condicional . $default reduce using rule 53 (comando_sem_rotulo) -state 61 +State 61 98 comando_condicional: if_then . cond_else @@ -900,89 +965,89 @@ state 61 cond_else go to state 82 -state 62 +State 62 18 lista_id_var: lista_id_var VIRGULA IDENT . $default reduce using rule 18 (lista_id_var) -state 63 +State 63 17 tipo: IDENT . $default reduce using rule 17 (tipo) -state 64 +State 64 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo . @6 PONTO_E_VIRGULA + 16 declara_var: $@5 lista_id_var DOIS_PONTOS tipo . $@6 PONTO_E_VIRGULA - $default reduce using rule 15 (@6) + $default reduce using rule 15 ($@6) - @6 go to state 83 + $@6 go to state 83 -state 65 +State 65 - 34 parametros_ou_nada: ABRE_PARENTESES @12 . paramentros_formais @13 FECHA_PARENTESES + 34 parametros_ou_nada: ABRE_PARENTESES $@12 . paramentros_formais $@13 FECHA_PARENTESES VAR shift, and go to state 84 - $default reduce using rule 40 (@15) + $default reduce using rule 40 ($@15) paramentros_formais go to state 85 secao_pfs go to state 86 - @15 go to state 87 + $@15 go to state 87 -state 66 +State 66 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS . @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS . $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA - $default reduce using rule 29 (@10) + $default reduce using rule 29 ($@10) - @10 go to state 88 + $@10 go to state 88 -state 67 +State 67 - 27 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 PONTO_E_VIRGULA shift, and go to state 89 -state 68 +State 68 - 58 atribuicao_ou_procedimento: IDENT @16 . atribuicao_ou_procedimento_token + 58 atribuicao_ou_procedimento: IDENT $@16 . atribuicao_ou_procedimento_token - ATRIBUICAO reduce using rule 61 (@17) - $default reduce using rule 63 (@18) + ATRIBUICAO reduce using rule 61 ($@17) + $default reduce using rule 63 ($@18) atribuicao_ou_procedimento_token go to state 90 atribuicao go to state 91 - @17 go to state 92 + $@17 go to state 92 chamada_procedimento go to state 93 - @18 go to state 94 + $@18 go to state 94 -state 69 +State 69 - 92 fator: IDENT . @21 chamada_procedimento + 92 fator: IDENT . $@21 chamada_procedimento - $default reduce using rule 91 (@21) + $default reduce using rule 91 ($@21) - @21 go to state 95 + $@21 go to state 95 -state 70 +State 70 93 fator: NUMERO . $default reduce using rule 93 (fator) -state 71 +State 71 78 expressao: expressao . IGUAL expressao_simples 79 | expressao . DIFERENTE expressao_simples @@ -990,7 +1055,7 @@ state 71 81 | expressao . MENOR_IGUAL expressao_simples 82 | expressao . MAIOR expressao_simples 83 | expressao . MAIOR_IGUAL expressao_simples - 102 if_then: IF expressao . @24 THEN comando_sem_rotulo + 102 if_then: IF expressao . $@24 THEN comando_sem_rotulo IGUAL shift, and go to state 96 DIFERENTE shift, and go to state 97 @@ -999,12 +1064,12 @@ state 71 MENOR shift, and go to state 100 MAIOR shift, and go to state 101 - $default reduce using rule 101 (@24) + $default reduce using rule 101 ($@24) - @24 go to state 102 + $@24 go to state 102 -state 72 +State 72 84 expressao: expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1016,7 +1081,7 @@ state 72 $default reduce using rule 84 (expressao) -state 73 +State 73 87 expressao_simples: termo . 88 termo: termo . ASTERISCO fator @@ -1028,14 +1093,14 @@ state 73 $default reduce using rule 87 (expressao_simples) -state 74 +State 74 90 termo: fator . $default reduce using rule 90 (termo) -state 75 +State 75 71 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES @@ -1045,7 +1110,7 @@ state 75 simb_leitura go to state 109 -state 76 +State 76 75 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES @@ -1058,14 +1123,14 @@ state 76 fator go to state 74 -state 77 +State 77 45 comando_composto: T_BEGIN comandos T_END . $default reduce using rule 45 (comando_composto) -state 78 +State 78 46 comandos: comando PONTO_E_VIRGULA . comandos 47 | comando PONTO_E_VIRGULA . @@ -1079,7 +1144,7 @@ state 78 T_END reduce using rule 47 (comandos) T_END [reduce using rule 48 (comandos)] - WHILE reduce using rule 95 (@22) + WHILE reduce using rule 95 ($@22) $default reduce using rule 47 (comandos) comando_composto go to state 50 @@ -1091,12 +1156,12 @@ state 78 escrita go to state 56 numero go to state 57 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 79 +State 79 49 comando: numero DOIS_PONTOS . comando_sem_rotulo @@ -1106,7 +1171,7 @@ state 79 READ shift, and go to state 48 WRITE shift, and go to state 49 - $default reduce using rule 95 (@22) + $default reduce using rule 95 ($@22) comando_composto go to state 50 comando_sem_rotulo go to state 113 @@ -1114,14 +1179,14 @@ state 79 leitura go to state 55 escrita go to state 56 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 80 +State 80 - 97 comando_repetitivo: @22 WHILE . expressao DO @23 comando_sem_rotulo + 97 comando_repetitivo: $@22 WHILE . expressao DO $@23 comando_sem_rotulo IDENT shift, and go to state 69 NUMERO shift, and go to state 70 @@ -1132,7 +1197,7 @@ state 80 fator go to state 74 -state 81 +State 81 99 cond_else: ELSE . comando_sem_rotulo @@ -1142,7 +1207,7 @@ state 81 READ shift, and go to state 48 WRITE shift, and go to state 49 - $default reduce using rule 95 (@22) + $default reduce using rule 95 ($@22) comando_composto go to state 50 comando_sem_rotulo go to state 115 @@ -1150,56 +1215,56 @@ state 81 leitura go to state 55 escrita go to state 56 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 82 +State 82 98 comando_condicional: if_then cond_else . $default reduce using rule 98 (comando_condicional) -state 83 +State 83 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 . PONTO_E_VIRGULA + 16 declara_var: $@5 lista_id_var DOIS_PONTOS tipo $@6 . PONTO_E_VIRGULA PONTO_E_VIRGULA shift, and go to state 116 -state 84 +State 84 - 39 secao_pfs: VAR . @14 lista_id_pf DOIS_PONTOS tipo + 39 secao_pfs: VAR . $@14 lista_id_pf DOIS_PONTOS tipo - $default reduce using rule 38 (@14) + $default reduce using rule 38 ($@14) - @14 go to state 117 + $@14 go to state 117 -state 85 +State 85 - 34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais . @13 FECHA_PARENTESES + 34 parametros_ou_nada: ABRE_PARENTESES $@12 paramentros_formais . $@13 FECHA_PARENTESES 37 paramentros_formais: paramentros_formais . PONTO_E_VIRGULA secao_pfs PONTO_E_VIRGULA shift, and go to state 118 - $default reduce using rule 33 (@13) + $default reduce using rule 33 ($@13) - @13 go to state 119 + $@13 go to state 119 -state 86 +State 86 36 paramentros_formais: secao_pfs . $default reduce using rule 36 (paramentros_formais) -state 87 +State 87 - 41 secao_pfs: @15 . lista_id_pf DOIS_PONTOS tipo + 41 secao_pfs: $@15 . lista_id_pf DOIS_PONTOS tipo IDENT shift, and go to state 120 @@ -1207,18 +1272,18 @@ state 87 parametro go to state 122 -state 88 +State 88 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 . tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 . tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA IDENT shift, and go to state 63 tipo go to state 123 -state 89 +State 89 - 27 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 LABEL shift, and go to state 13 @@ -1228,37 +1293,37 @@ state 89 parte_declara_rotulos go to state 15 -state 90 +State 90 - 58 atribuicao_ou_procedimento: IDENT @16 atribuicao_ou_procedimento_token . + 58 atribuicao_ou_procedimento: IDENT $@16 atribuicao_ou_procedimento_token . $default reduce using rule 58 (atribuicao_ou_procedimento) -state 91 +State 91 59 atribuicao_ou_procedimento_token: atribuicao . $default reduce using rule 59 (atribuicao_ou_procedimento_token) -state 92 +State 92 - 62 atribuicao: @17 . ATRIBUICAO expressao_simples + 62 atribuicao: $@17 . ATRIBUICAO expressao_simples ATRIBUICAO shift, and go to state 125 -state 93 +State 93 60 atribuicao_ou_procedimento_token: chamada_procedimento . $default reduce using rule 60 (atribuicao_ou_procedimento_token) -state 94 +State 94 - 64 chamada_procedimento: @18 . lista_parametros + 64 chamada_procedimento: $@18 . lista_parametros ABRE_PARENTESES shift, and go to state 126 @@ -1267,17 +1332,17 @@ state 94 lista_parametros go to state 127 -state 95 +State 95 - 92 fator: IDENT @21 . chamada_procedimento + 92 fator: IDENT $@21 . chamada_procedimento - $default reduce using rule 63 (@18) + $default reduce using rule 63 ($@18) chamada_procedimento go to state 128 - @18 go to state 94 + $@18 go to state 94 -state 96 +State 96 78 expressao: expressao IGUAL . expressao_simples @@ -1289,7 +1354,7 @@ state 96 fator go to state 74 -state 97 +State 97 79 expressao: expressao DIFERENTE . expressao_simples @@ -1301,7 +1366,7 @@ state 97 fator go to state 74 -state 98 +State 98 81 expressao: expressao MENOR_IGUAL . expressao_simples @@ -1313,7 +1378,7 @@ state 98 fator go to state 74 -state 99 +State 99 83 expressao: expressao MAIOR_IGUAL . expressao_simples @@ -1325,7 +1390,7 @@ state 99 fator go to state 74 -state 100 +State 100 80 expressao: expressao MENOR . expressao_simples @@ -1337,7 +1402,7 @@ state 100 fator go to state 74 -state 101 +State 101 82 expressao: expressao MAIOR . expressao_simples @@ -1349,14 +1414,14 @@ state 101 fator go to state 74 -state 102 +State 102 - 102 if_then: IF expressao @24 . THEN comando_sem_rotulo + 102 if_then: IF expressao $@24 . THEN comando_sem_rotulo THEN shift, and go to state 135 -state 103 +State 103 85 expressao_simples: expressao_simples MAIS . termo @@ -1367,7 +1432,7 @@ state 103 fator go to state 74 -state 104 +State 104 86 expressao_simples: expressao_simples MENOS . termo @@ -1378,7 +1443,7 @@ state 104 fator go to state 74 -state 105 +State 105 89 termo: termo DIV . fator @@ -1388,7 +1453,7 @@ state 105 fator go to state 138 -state 106 +State 106 88 termo: termo ASTERISCO . fator @@ -1398,14 +1463,14 @@ state 106 fator go to state 139 -state 107 +State 107 74 simb_leitura: IDENT . $default reduce using rule 74 (simb_leitura) -state 108 +State 108 71 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES 72 lista_leituras: lista_leituras . VIRGULA simb_leitura @@ -1414,14 +1479,14 @@ state 108 VIRGULA shift, and go to state 141 -state 109 +State 109 73 lista_leituras: simb_leitura . $default reduce using rule 73 (lista_leituras) -state 110 +State 110 75 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES 76 lista_escritas: lista_escritas . VIRGULA expressao_simples @@ -1430,7 +1495,7 @@ state 110 VIRGULA shift, and go to state 143 -state 111 +State 111 77 lista_escritas: expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1442,21 +1507,21 @@ state 111 $default reduce using rule 77 (lista_escritas) -state 112 +State 112 46 comandos: comando PONTO_E_VIRGULA comandos . $default reduce using rule 46 (comandos) -state 113 +State 113 49 comando: numero DOIS_PONTOS comando_sem_rotulo . $default reduce using rule 49 (comando) -state 114 +State 114 78 expressao: expressao . IGUAL expressao_simples 79 | expressao . DIFERENTE expressao_simples @@ -1464,7 +1529,7 @@ state 114 81 | expressao . MENOR_IGUAL expressao_simples 82 | expressao . MAIOR expressao_simples 83 | expressao . MAIOR_IGUAL expressao_simples - 97 comando_repetitivo: @22 WHILE expressao . DO @23 comando_sem_rotulo + 97 comando_repetitivo: $@22 WHILE expressao . DO $@23 comando_sem_rotulo DO shift, and go to state 144 IGUAL shift, and go to state 96 @@ -1475,23 +1540,23 @@ state 114 MAIOR shift, and go to state 101 -state 115 +State 115 99 cond_else: ELSE comando_sem_rotulo . $default reduce using rule 99 (cond_else) -state 116 +State 116 - 16 declara_var: @5 lista_id_var DOIS_PONTOS tipo @6 PONTO_E_VIRGULA . + 16 declara_var: $@5 lista_id_var DOIS_PONTOS tipo $@6 PONTO_E_VIRGULA . $default reduce using rule 16 (declara_var) -state 117 +State 117 - 39 secao_pfs: VAR @14 . lista_id_pf DOIS_PONTOS tipo + 39 secao_pfs: VAR $@14 . lista_id_pf DOIS_PONTOS tipo IDENT shift, and go to state 120 @@ -1499,40 +1564,40 @@ state 117 parametro go to state 122 -state 118 +State 118 37 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs VAR shift, and go to state 84 - $default reduce using rule 40 (@15) + $default reduce using rule 40 ($@15) secao_pfs go to state 146 - @15 go to state 87 + $@15 go to state 87 -state 119 +State 119 - 34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 . FECHA_PARENTESES + 34 parametros_ou_nada: ABRE_PARENTESES $@12 paramentros_formais $@13 . FECHA_PARENTESES FECHA_PARENTESES shift, and go to state 147 -state 120 +State 120 44 parametro: IDENT . $default reduce using rule 44 (parametro) -state 121 +State 121 - 41 secao_pfs: @15 lista_id_pf . DOIS_PONTOS tipo + 41 secao_pfs: $@15 lista_id_pf . DOIS_PONTOS tipo DOIS_PONTOS shift, and go to state 148 -state 122 +State 122 42 lista_id_pf: parametro . VIRGULA lista_id_pf 43 | parametro . @@ -1542,25 +1607,25 @@ state 122 $default reduce using rule 43 (lista_id_pf) -state 123 +State 123 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo . PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo . PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA PONTO_E_VIRGULA shift, and go to state 150 -state 124 +State 124 - 27 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 - $default reduce using rule 26 (@8) + $default reduce using rule 26 ($@8) - @8 go to state 151 + $@8 go to state 151 -state 125 +State 125 - 62 atribuicao: @17 ATRIBUICAO . expressao_simples + 62 atribuicao: $@17 ATRIBUICAO . expressao_simples IDENT shift, and go to state 69 NUMERO shift, and go to state 70 @@ -1570,31 +1635,31 @@ state 125 fator go to state 74 -state 126 +State 126 65 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES - $default reduce using rule 69 (@20) + $default reduce using rule 69 ($@20) lista_parametros_parenteses go to state 153 - @20 go to state 154 + $@20 go to state 154 -state 127 +State 127 - 64 chamada_procedimento: @18 lista_parametros . + 64 chamada_procedimento: $@18 lista_parametros . $default reduce using rule 64 (chamada_procedimento) -state 128 +State 128 - 92 fator: IDENT @21 chamada_procedimento . + 92 fator: IDENT $@21 chamada_procedimento . $default reduce using rule 92 (fator) -state 129 +State 129 78 expressao: expressao IGUAL expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1606,7 +1671,7 @@ state 129 $default reduce using rule 78 (expressao) -state 130 +State 130 79 expressao: expressao DIFERENTE expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1618,7 +1683,7 @@ state 130 $default reduce using rule 79 (expressao) -state 131 +State 131 81 expressao: expressao MENOR_IGUAL expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1630,7 +1695,7 @@ state 131 $default reduce using rule 81 (expressao) -state 132 +State 132 83 expressao: expressao MAIOR_IGUAL expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1642,7 +1707,7 @@ state 132 $default reduce using rule 83 (expressao) -state 133 +State 133 80 expressao: expressao MENOR expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1654,7 +1719,7 @@ state 133 $default reduce using rule 80 (expressao) -state 134 +State 134 82 expressao: expressao MAIOR expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1666,9 +1731,9 @@ state 134 $default reduce using rule 82 (expressao) -state 135 +State 135 - 102 if_then: IF expressao @24 THEN . comando_sem_rotulo + 102 if_then: IF expressao $@24 THEN . comando_sem_rotulo T_BEGIN shift, and go to state 38 IDENT shift, and go to state 45 @@ -1676,7 +1741,7 @@ state 135 READ shift, and go to state 48 WRITE shift, and go to state 49 - $default reduce using rule 95 (@22) + $default reduce using rule 95 ($@22) comando_composto go to state 50 comando_sem_rotulo go to state 155 @@ -1684,12 +1749,12 @@ state 135 leitura go to state 55 escrita go to state 56 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 136 +State 136 85 expressao_simples: expressao_simples MAIS termo . 88 termo: termo . ASTERISCO fator @@ -1701,7 +1766,7 @@ state 136 $default reduce using rule 85 (expressao_simples) -state 137 +State 137 86 expressao_simples: expressao_simples MENOS termo . 88 termo: termo . ASTERISCO fator @@ -1713,28 +1778,28 @@ state 137 $default reduce using rule 86 (expressao_simples) -state 138 +State 138 89 termo: termo DIV fator . $default reduce using rule 89 (termo) -state 139 +State 139 88 termo: termo ASTERISCO fator . $default reduce using rule 88 (termo) -state 140 +State 140 71 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES . $default reduce using rule 71 (leitura) -state 141 +State 141 72 lista_leituras: lista_leituras VIRGULA . simb_leitura @@ -1743,14 +1808,14 @@ state 141 simb_leitura go to state 156 -state 142 +State 142 75 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES . $default reduce using rule 75 (escrita) -state 143 +State 143 76 lista_escritas: lista_escritas VIRGULA . expressao_simples @@ -1762,46 +1827,46 @@ state 143 fator go to state 74 -state 144 +State 144 - 97 comando_repetitivo: @22 WHILE expressao DO . @23 comando_sem_rotulo + 97 comando_repetitivo: $@22 WHILE expressao DO . $@23 comando_sem_rotulo - $default reduce using rule 96 (@23) + $default reduce using rule 96 ($@23) - @23 go to state 158 + $@23 go to state 158 -state 145 +State 145 - 39 secao_pfs: VAR @14 lista_id_pf . DOIS_PONTOS tipo + 39 secao_pfs: VAR $@14 lista_id_pf . DOIS_PONTOS tipo DOIS_PONTOS shift, and go to state 159 -state 146 +State 146 37 paramentros_formais: paramentros_formais PONTO_E_VIRGULA secao_pfs . $default reduce using rule 37 (paramentros_formais) -state 147 +State 147 - 34 parametros_ou_nada: ABRE_PARENTESES @12 paramentros_formais @13 FECHA_PARENTESES . + 34 parametros_ou_nada: ABRE_PARENTESES $@12 paramentros_formais $@13 FECHA_PARENTESES . $default reduce using rule 34 (parametros_ou_nada) -state 148 +State 148 - 41 secao_pfs: @15 lista_id_pf DOIS_PONTOS . tipo + 41 secao_pfs: $@15 lista_id_pf DOIS_PONTOS . tipo IDENT shift, and go to state 63 tipo go to state 160 -state 149 +State 149 42 lista_id_pf: parametro VIRGULA . lista_id_pf @@ -1811,9 +1876,9 @@ state 149 parametro go to state 122 -state 150 +State 150 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA . bloco @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA . bloco $@11 PONTO_E_VIRGULA LABEL shift, and go to state 13 @@ -1823,16 +1888,16 @@ state 150 parte_declara_rotulos go to state 15 -state 151 +State 151 - 27 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 PONTO_E_VIRGULA shift, and go to state 163 -state 152 +State 152 - 62 atribuicao: @17 ATRIBUICAO expressao_simples . + 62 atribuicao: $@17 ATRIBUICAO expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo 86 | expressao_simples . MENOS termo @@ -1842,18 +1907,18 @@ state 152 $default reduce using rule 62 (atribuicao) -state 153 +State 153 65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES - 68 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA @19 expressao_simples + 68 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA $@19 expressao_simples FECHA_PARENTESES shift, and go to state 164 VIRGULA shift, and go to state 165 -state 154 +State 154 - 70 lista_parametros_parenteses: @20 . expressao_simples + 70 lista_parametros_parenteses: $@20 . expressao_simples IDENT shift, and go to state 69 NUMERO shift, and go to state 70 @@ -1863,21 +1928,21 @@ state 154 fator go to state 74 -state 155 +State 155 - 102 if_then: IF expressao @24 THEN comando_sem_rotulo . + 102 if_then: IF expressao $@24 THEN comando_sem_rotulo . $default reduce using rule 102 (if_then) -state 156 +State 156 72 lista_leituras: lista_leituras VIRGULA simb_leitura . $default reduce using rule 72 (lista_leituras) -state 157 +State 157 76 lista_escritas: lista_escritas VIRGULA expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo @@ -1889,9 +1954,9 @@ state 157 $default reduce using rule 76 (lista_escritas) -state 158 +State 158 - 97 comando_repetitivo: @22 WHILE expressao DO @23 . comando_sem_rotulo + 97 comando_repetitivo: $@22 WHILE expressao DO $@23 . comando_sem_rotulo T_BEGIN shift, and go to state 38 IDENT shift, and go to state 45 @@ -1899,7 +1964,7 @@ state 158 READ shift, and go to state 48 WRITE shift, and go to state 49 - $default reduce using rule 95 (@22) + $default reduce using rule 95 ($@22) comando_composto go to state 50 comando_sem_rotulo go to state 167 @@ -1907,69 +1972,69 @@ state 158 leitura go to state 55 escrita go to state 56 comando_repetitivo go to state 58 - @22 go to state 59 + $@22 go to state 59 comando_condicional go to state 60 if_then go to state 61 -state 159 +State 159 - 39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS . tipo + 39 secao_pfs: VAR $@14 lista_id_pf DOIS_PONTOS . tipo IDENT shift, and go to state 63 tipo go to state 168 -state 160 +State 160 - 41 secao_pfs: @15 lista_id_pf DOIS_PONTOS tipo . + 41 secao_pfs: $@15 lista_id_pf DOIS_PONTOS tipo . $default reduce using rule 41 (secao_pfs) -state 161 +State 161 42 lista_id_pf: parametro VIRGULA lista_id_pf . $default reduce using rule 42 (lista_id_pf) -state 162 +State 162 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco . @11 PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco . $@11 PONTO_E_VIRGULA - $default reduce using rule 30 (@11) + $default reduce using rule 30 ($@11) - @11 go to state 169 + $@11 go to state 169 -state 163 +State 163 - 27 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 . $default reduce using rule 27 (declaracao_procedimento) -state 164 +State 164 65 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES . $default reduce using rule 65 (lista_parametros) -state 165 +State 165 - 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . @19 expressao_simples + 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . $@19 expressao_simples - $default reduce using rule 67 (@19) + $default reduce using rule 67 ($@19) - @19 go to state 170 + $@19 go to state 170 -state 166 +State 166 - 70 lista_parametros_parenteses: @20 expressao_simples . + 70 lista_parametros_parenteses: $@20 expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo 86 | expressao_simples . MENOS termo @@ -1979,30 +2044,30 @@ state 166 $default reduce using rule 70 (lista_parametros_parenteses) -state 167 +State 167 - 97 comando_repetitivo: @22 WHILE expressao DO @23 comando_sem_rotulo . + 97 comando_repetitivo: $@22 WHILE expressao DO $@23 comando_sem_rotulo . $default reduce using rule 97 (comando_repetitivo) -state 168 +State 168 - 39 secao_pfs: VAR @14 lista_id_pf DOIS_PONTOS tipo . + 39 secao_pfs: VAR $@14 lista_id_pf DOIS_PONTOS tipo . $default reduce using rule 39 (secao_pfs) -state 169 +State 169 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 . PONTO_E_VIRGULA + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 . PONTO_E_VIRGULA PONTO_E_VIRGULA shift, and go to state 171 -state 170 +State 170 - 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 . expressao_simples + 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA $@19 . expressao_simples IDENT shift, and go to state 69 NUMERO shift, and go to state 70 @@ -2012,16 +2077,16 @@ state 170 fator go to state 74 -state 171 +State 171 - 31 declaracao_funcao: FUNCTION IDENT @9 parametros_ou_nada DOIS_PONTOS @10 tipo PONTO_E_VIRGULA bloco @11 PONTO_E_VIRGULA . + 31 declaracao_funcao: FUNCTION IDENT $@9 parametros_ou_nada DOIS_PONTOS $@10 tipo PONTO_E_VIRGULA bloco $@11 PONTO_E_VIRGULA . $default reduce using rule 31 (declaracao_funcao) -state 172 +State 172 - 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA @19 expressao_simples . + 68 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA $@19 expressao_simples . 85 expressao_simples: expressao_simples . MAIS termo 86 | expressao_simples . MENOS termo diff --git a/compilador.y b/compilador.y index 4adb5825a16358277a65dcbf610962feeb82eb0c..24419a48f240c1eb156a6848d9b58d6f05f88fdf 100644 --- a/compilador.y +++ b/compilador.y @@ -78,11 +78,12 @@ bloco : } comando_composto { - retira(desloc,ts); char buffer[50]; sprintf(buffer,"DMEM %d",desloc); + desloc = retira(desloc,ts); geraCodigo(NULL,buffer); - desloc = 0; + if (nivel_lexico > 0) + nivel_lexico += 1; } ; @@ -162,32 +163,42 @@ parte_declara_subrotinas: parte_declara_subrotinas // REGRA 12 // Regra ajustada para declaração de procedimento declaracao_procedimento: PROCEDURE IDENT { - // Insere o procedimento na tabela de símbolos - info_t info; - char r_proc[4]; - sprintf(r_proc, "R%02d", rot_id); - rot_id += 1; - strcpy(info.pr.rot,r_proc); - info.pr.quant = 0; - info.pr.param = NULL; + // Insere o procedimento na tabela de símbolos + info_t info; + char r_proc[4]; + sprintf(r_proc, "R%02d", rot_id); + rot_id += 1; + strcpy(info.pr.rot,r_proc); + info.pr.quant = 0; + info.pr.param = NULL; - // Incrementa o nível léxico - nivel_lexico += 1; - desloc = 0; // Reinicia deslocamento para variáveis locais do novo nível + // Incrementa o nível léxico + nivel_lexico += 1; + desloc = 0; // Reinicia deslocamento para variáveis locais do novo nível - insere_ts(token, PR, nivel_lexico, info, ts); - empilha(token,proc); + insere_ts(token, PR, nivel_lexico, info, ts); + empilha(token,proc); - char buffer[50]; - sprintf(buffer,"ENPR %d",nivel_lexico); - geraCodigo(r_proc,buffer); - mostra_ts(ts); + char buffer[50]; + sprintf(buffer,"ENPR %d",nivel_lexico); + geraCodigo(r_proc,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; + { + char buffer[50]; + desempilha(buffer,proc); + l_elem = busca(buffer,ts); + int n; + if(l_elem->categ == PR) + n = l_elem->info.pr.quant; + else if (l_elem->categ == FUN) + n = l_elem->info.pr.quant; + sprintf(buffer,"RTPR %d,%d",l_elem->nivel,n); + geraCodigo(NULL,buffer); + desloc = retira(n,ts); + mostra_ts(ts); } PONTO_E_VIRGULA ; @@ -235,6 +246,7 @@ parametros_ou_nada: ABRE_PARENTESES char proc_ident[50]; desempilha(proc_ident,proc); adiciona_param(proc_ident,num_param,ts); + empilha(proc_ident,proc); mostra_ts(ts); } FECHA_PARENTESES @@ -329,9 +341,9 @@ atribuicao: { chamada_procedimento: { - if (l_elem == NULL || (l_elem->categ != PR && l_elem->categ != FUN)) { + if (l_elem == NULL){ yyerror("Procedimento não declarado"); - } else { + } else if (l_elem->categ == PR || l_elem->categ == FUN) { // Gera código para chamar o procedimento empilha(l_elem->ident, proc); } @@ -343,21 +355,28 @@ chamada_procedimento: lista_parametros { - char buffer[50]; - mostra_ts(ts); - desempilha(buffer, proc); - l_elem = busca(buffer, ts); - - // Verifica se o número de parâmetros reais bate com os formais - if (num_param != l_elem->info.pr.quant) { - char error_msg[100]; - sprintf(error_msg, "Erro: número de parâmetros incorreto. Esperado: %d, recebido: %d.", - l_elem->info.pr.quant, num_param); - yyerror(error_msg); - } - - // Gera o código de chamada do procedimento if (l_elem->categ == PR || l_elem->categ ==FUN) { + char buffer[50]; + mostra_ts(ts); + desempilha(buffer, proc); + l_elem = busca(buffer, ts); + + // Verifica se o número de parâmetros reais bate com os formais + if (num_param != l_elem->info.pr.quant) { + char error_msg[100]; + if(l_elem->categ == PR){ + sprintf(error_msg, "Erro: número de parâmetros incorreto. Esperado: %d, recebido: %d.", + l_elem->info.pr.quant, num_param); + yyerror(error_msg); + } else if(l_elem->categ == FUN){ + sprintf(error_msg, "Erro: número de parâmetros incorreto. Esperado: %d, recebido: %d.", + l_elem->info.fun.quant, num_param); + yyerror(error_msg); + } + } + + // Gera o código de chamada do procedimento + sprintf(buffer, "CHPR %s,%d", l_elem->info.pr.rot, nivel_lexico); geraCodigo(NULL, buffer); } @@ -479,7 +498,7 @@ fator: IDENT { char buffer[50]; desempilha(buffer, proc); l_elem = busca(buffer, ts); - if (l_elem == NULL || l_elem->categ == PR) { + if (l_elem == NULL) { yyerror("Variável não declarada"); } else { if (val_ou_ref == REF) { diff --git a/ts/ts.c b/ts/ts.c index d231a90f8f8bc9f4efbb7d64bd436b577f950631..a291481ef17d877d2943f4a9bd765c311f9fd265 100644 --- a/ts/ts.c +++ b/ts/ts.c @@ -61,14 +61,20 @@ simb_t *busca(char *ident, ts_t *ts){ return NULL;//nao tem } -void retira(int n, ts_t *ts) { - if (ts == NULL || ts->topo == NULL || n <= 0) { - return; // Nenhum elemento a ser removido +simb_t *topo(ts_t *ts){ + if(ts == NULL) return NULL; + return ts->topo; +} + +int retira(int n, ts_t *ts) { + if (ts == NULL || ts->topo == NULL) { + return 0; // Nenhum elemento a ser removido } - int i = 0; // Contador de elementos removidos - for (; i < n && ts->topo != NULL; i++) { - simb_t *temp = ts->topo; + int i; // Contador de elementos removidos + simb_t *temp = ts->topo; + for (i = 0; i < n && ts->topo != NULL; i++) { + temp = ts->topo; ts->topo = ts->topo->prox; free(temp); ts->tam--; @@ -77,6 +83,15 @@ void retira(int n, ts_t *ts) { if (i < n) { printf("Aviso: Tentativa de remover mais itens (%d) do que a pilha possui (%d). Removidos apenas %d itens.\n", n, i, i); } + + //retorna novo deslocamento + while (temp != NULL) { + if (temp->categ == VS) { + return temp->info.vs.desloc + 1; + } + temp = temp->prox; + } + return 0; } void atualiza_tipo(int n, int tipo, ts_t *ts){ diff --git a/ts/ts.h b/ts/ts.h index 54bb6aae68f77f7728c59233868a100bb380953a..8c2c536d5374140efa30cd9073fd6a0d76f3143c 100644 --- a/ts/ts.h +++ b/ts/ts.h @@ -67,7 +67,9 @@ void insere_ts(char *ident, int categ, int nivel, info_t info, ts_t *ts); simb_t *busca(char *ident, ts_t *ts); // Corrigido: retorna ponteiro para simb_t -void retira(int n, ts_t *ts); +simb_t *topo(ts_t *ts); + +int retira(int n, ts_t *ts); void atualiza_tipo(int n, int tipo, ts_t *ts);