diff --git a/MEPA b/MEPA index 1e347b2094fc5d6c126922d71cfef9b7b9c8d04c..f4b8de02ec1cce17e257c7e756b758d8b5171a3c 100644 --- a/MEPA +++ b/MEPA @@ -5,11 +5,14 @@ R01: ENPR 1 AMEM 1 DSVS R02 R02: NADA + CRVL 1,-4 ARMZ 1,0 DMEM 1 R00: NADA CRCT 8 ARMZ 0,0 + CRVL 0,0 + CRCT 2 CHPR R01,0 DMEM 0 PARA diff --git a/compilador.output b/compilador.output index c8ec77a09587e2aa3058e961cdf1dfc9b4b04eaf..ba68368d2356f1a6c323a13e92ec00d655addd6c 100644 --- a/compilador.output +++ b/compilador.output @@ -74,97 +74,101 @@ Grammar 33 @11: /* empty */ - 34 secao_pfs: @11 lista_id_pf DOIS_PONTOS tipo + 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS tipo - 35 lista_id_pf: parametro VIRGULA lista_id_pf - 36 | parametro + 35 @12: /* empty */ - 37 parametro: IDENT + 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS tipo - 38 comando_composto: T_BEGIN comandos T_END + 37 lista_id_pf: parametro VIRGULA lista_id_pf + 38 | parametro - 39 comandos: comando PONTO_E_VIRGULA comandos - 40 | comando PONTO_E_VIRGULA - 41 | /* empty */ + 39 parametro: IDENT - 42 comando: numero DOIS_PONTOS comando_sem_rotulo - 43 | comando_sem_rotulo + 40 comando_composto: T_BEGIN comandos T_END - 44 comando_sem_rotulo: atribuicao_ou_procedimento - 45 | comando_composto - 46 | comando_condicional - 47 | comando_repetitivo - 48 | leitura - 49 | escrita + 41 comandos: comando PONTO_E_VIRGULA comandos + 42 | comando PONTO_E_VIRGULA + 43 | /* empty */ - 50 @12: /* empty */ + 44 comando: numero DOIS_PONTOS comando_sem_rotulo + 45 | comando_sem_rotulo - 51 atribuicao_ou_procedimento: IDENT @12 atribuicao_ou_procedimento_token + 46 comando_sem_rotulo: atribuicao_ou_procedimento + 47 | comando_composto + 48 | comando_condicional + 49 | comando_repetitivo + 50 | leitura + 51 | escrita - 52 atribuicao_ou_procedimento_token: atribuicao - 53 | chamada_procedimento + 52 @13: /* empty */ - 54 @13: /* empty */ + 53 atribuicao_ou_procedimento: IDENT @13 atribuicao_ou_procedimento_token - 55 atribuicao: @13 ATRIBUICAO expressao_simples + 54 atribuicao_ou_procedimento_token: atribuicao + 55 | chamada_procedimento 56 @14: /* empty */ - 57 chamada_procedimento: @14 lista_parametros + 57 atribuicao: @14 ATRIBUICAO expressao_simples - 58 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES - 59 | /* empty */ + 58 @15: /* empty */ - 60 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples - 61 | expressao_simples + 59 chamada_procedimento: @15 lista_parametros - 62 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES + 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES + 61 | /* empty */ - 63 lista_leituras: lista_leituras VIRGULA simb_leitura - 64 | simb_leitura + 62 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples + 63 | expressao_simples - 65 simb_leitura: IDENT + 64 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES - 66 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES + 65 lista_leituras: lista_leituras VIRGULA simb_leitura + 66 | simb_leitura - 67 lista_escritas: lista_escritas VIRGULA expressao_simples - 68 | expressao_simples + 67 simb_leitura: IDENT - 69 expressao: expressao IGUAL expressao_simples - 70 | expressao DIFERENTE expressao_simples - 71 | expressao MENOR expressao_simples - 72 | expressao MENOR_IGUAL expressao_simples - 73 | expressao MAIOR expressao_simples - 74 | expressao MAIOR_IGUAL expressao_simples - 75 | expressao_simples + 68 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES - 76 expressao_simples: expressao_simples MAIS termo - 77 | expressao_simples MENOS termo - 78 | termo + 69 lista_escritas: lista_escritas VIRGULA expressao_simples + 70 | expressao_simples - 79 termo: termo ASTERISCO fator - 80 | termo DIV fator - 81 | fator + 71 expressao: expressao IGUAL expressao_simples + 72 | expressao DIFERENTE expressao_simples + 73 | expressao MENOR expressao_simples + 74 | expressao MENOR_IGUAL expressao_simples + 75 | expressao MAIOR expressao_simples + 76 | expressao MAIOR_IGUAL expressao_simples + 77 | expressao_simples - 82 fator: IDENT - 83 | NUMERO + 78 expressao_simples: expressao_simples MAIS termo + 79 | expressao_simples MENOS termo + 80 | termo - 84 numero: NUMERO + 81 termo: termo ASTERISCO fator + 82 | termo DIV fator + 83 | fator - 85 @15: /* empty */ + 84 fator: IDENT + 85 | NUMERO - 86 @16: /* empty */ + 86 numero: NUMERO - 87 comando_repetitivo: @15 WHILE expressao DO @16 comando_sem_rotulo + 87 @16: /* empty */ - 88 comando_condicional: if_then cond_else + 88 @17: /* empty */ - 89 cond_else: ELSE comando_sem_rotulo - 90 | /* empty */ + 89 comando_repetitivo: @16 WHILE expressao DO @17 comando_sem_rotulo - 91 @17: /* empty */ + 90 comando_condicional: if_then cond_else - 92 if_then: IF expressao @17 THEN comando_sem_rotulo + 91 cond_else: ELSE comando_sem_rotulo + 92 | /* empty */ + + 93 @18: /* empty */ + + 94 if_then: IF expressao @18 THEN comando_sem_rotulo Terminals, with rules where they appear @@ -172,44 +176,44 @@ Terminals, with rules where they appear $end (0) 0 error (256) PROGRAM (258) 2 -ABRE_PARENTESES (259) 2 29 58 62 66 -FECHA_PARENTESES (260) 2 29 58 62 66 -VIRGULA (261) 6 18 20 35 60 63 67 -PONTO_E_VIRGULA (262) 2 16 26 32 39 40 -DOIS_PONTOS (263) 16 34 42 +ABRE_PARENTESES (259) 2 29 60 64 68 +FECHA_PARENTESES (260) 2 29 60 64 68 +VIRGULA (261) 6 18 20 37 62 65 69 +PONTO_E_VIRGULA (262) 2 16 26 32 41 42 +DOIS_PONTOS (263) 16 34 36 44 PONTO (264) 2 -T_BEGIN (265) 38 -T_END (266) 38 -VAR (267) 10 -IDENT (268) 2 17 18 19 20 21 26 37 51 65 82 -ATRIBUICAO (269) 55 +T_BEGIN (265) 40 +T_END (266) 40 +VAR (267) 10 34 +IDENT (268) 2 17 18 19 20 21 26 39 53 67 84 +ATRIBUICAO (269) 57 LABEL (270) 6 TYPE (271) ARRAY (272) PROCEDURE (273) 26 FUNCTION (274) GOTO (275) -IF (276) 92 -THEN (277) 92 -ELSE (278) 89 -WHILE (279) 87 -DO (280) 87 +IF (276) 94 +THEN (277) 94 +ELSE (278) 91 +WHILE (279) 89 +DO (280) 89 OR (281) -DIV (282) 80 +DIV (282) 82 AND (283) NOT (284) -IGUAL (285) 69 -DIFERENTE (286) 70 -MENOR_IGUAL (287) 72 -MAIOR_IGUAL (288) 74 -MENOR (289) 71 -MAIOR (290) 73 -MAIS (291) 76 -MENOS (292) 77 -ASTERISCO (293) 79 -NUMERO (294) 83 84 -READ (295) 62 -WRITE (296) 66 +IGUAL (285) 71 +DIFERENTE (286) 72 +MENOR_IGUAL (287) 74 +MAIOR_IGUAL (288) 76 +MENOR (289) 73 +MAIOR (290) 75 +MAIS (291) 78 +MENOS (292) 79 +ASTERISCO (293) 81 +NUMERO (294) 85 86 +READ (295) 64 +WRITE (296) 68 LOWER_THAN_ELSE (297) @@ -244,7 +248,7 @@ declara_var (54) @6 (56) on left: 15, on right: 16 tipo (57) - on left: 17, on right: 16 34 + on left: 17, on right: 16 34 36 lista_id_var (58) on left: 18 19, on right: 16 18 lista_idents (59) @@ -266,74 +270,76 @@ parametros_ou_nada (64) paramentros_formais (67) on left: 31 32, on right: 29 32 secao_pfs (68) - on left: 34, on right: 31 32 + on left: 34 36, on right: 31 32 @11 (69) on left: 33, on right: 34 -lista_id_pf (70) - on left: 35 36, on right: 34 35 -parametro (71) - on left: 37, on right: 35 36 -comando_composto (72) - on left: 38, on right: 5 45 -comandos (73) - on left: 39 40 41, on right: 38 39 -comando (74) - on left: 42 43, on right: 39 40 -comando_sem_rotulo (75) - on left: 44 45 46 47 48 49, on right: 42 43 87 89 92 -atribuicao_ou_procedimento (76) - on left: 51, on right: 44 -@12 (77) - on left: 50, on right: 51 -atribuicao_ou_procedimento_token (78) - on left: 52 53, on right: 51 -atribuicao (79) - on left: 55, on right: 52 -@13 (80) - on left: 54, on right: 55 -chamada_procedimento (81) - on left: 57, on right: 53 -@14 (82) +@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 89 91 94 +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: 56, on right: 57 -lista_parametros (83) - on left: 58 59, on right: 57 -lista_parametros_parenteses (84) - on left: 60 61, on right: 58 60 -leitura (85) - on left: 62, on right: 48 -lista_leituras (86) - on left: 63 64, on right: 62 63 -simb_leitura (87) - on left: 65, on right: 63 64 -escrita (88) - on left: 66, on right: 49 -lista_escritas (89) - on left: 67 68, on right: 66 67 -expressao (90) - on left: 69 70 71 72 73 74 75, on right: 69 70 71 72 73 74 87 92 -expressao_simples (91) - on left: 76 77 78, on right: 55 60 61 67 68 69 70 71 72 73 74 75 - 76 77 -termo (92) - on left: 79 80 81, on right: 76 77 78 79 80 -fator (93) - on left: 82 83, on right: 79 80 81 -numero (94) - on left: 84, on right: 42 -comando_repetitivo (95) - on left: 87, on right: 47 -@15 (96) - on left: 85, on right: 87 +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: 62 63, on right: 60 62 +leitura (86) + on left: 64, on right: 50 +lista_leituras (87) + on left: 65 66, on right: 64 65 +simb_leitura (88) + on left: 67, on right: 65 66 +escrita (89) + on left: 68, on right: 51 +lista_escritas (90) + on left: 69 70, on right: 68 69 +expressao (91) + on left: 71 72 73 74 75 76 77, on right: 71 72 73 74 75 76 89 94 +expressao_simples (92) + on left: 78 79 80, on right: 57 62 63 69 70 71 72 73 74 75 76 77 + 78 79 +termo (93) + on left: 81 82 83, on right: 78 79 80 81 82 +fator (94) + on left: 84 85, on right: 81 82 83 +numero (95) + on left: 86, on right: 44 +comando_repetitivo (96) + on left: 89, on right: 49 @16 (97) - on left: 86, on right: 87 -comando_condicional (98) - on left: 88, on right: 46 -cond_else (99) - on left: 89 90, on right: 88 -if_then (100) - on left: 92, on right: 88 -@17 (101) - on left: 91, on right: 92 + on left: 87, on right: 89 +@17 (98) + on left: 88, on right: 89 +comando_condicional (99) + on left: 90, on right: 48 +cond_else (100) + on left: 91 92, on right: 90 +if_then (101) + on left: 94, on right: 90 +@18 (102) + on left: 93, on right: 94 state 0 @@ -620,7 +626,7 @@ state 33 state 34 - 38 comando_composto: T_BEGIN . comandos T_END + 40 comando_composto: T_BEGIN . comandos T_END T_BEGIN shift, and go to state 34 IDENT shift, and go to state 39 @@ -629,8 +635,8 @@ state 34 READ shift, and go to state 42 WRITE shift, and go to state 43 - WHILE reduce using rule 85 (@15) - $default reduce using rule 41 (comandos) + WHILE reduce using rule 87 (@16) + $default reduce using rule 43 (comandos) comando_composto go to state 44 comandos go to state 45 @@ -641,7 +647,7 @@ state 34 escrita go to state 50 numero go to state 51 comando_repetitivo go to state 52 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 @@ -682,16 +688,16 @@ state 38 state 39 - 51 atribuicao_ou_procedimento: IDENT . @12 atribuicao_ou_procedimento_token + 53 atribuicao_ou_procedimento: IDENT . @13 atribuicao_ou_procedimento_token - $default reduce using rule 50 (@12) + $default reduce using rule 52 (@13) - @12 go to state 61 + @13 go to state 61 state 40 - 92 if_then: IF . expressao @17 THEN comando_sem_rotulo + 94 if_then: IF . expressao @18 THEN comando_sem_rotulo IDENT shift, and go to state 62 NUMERO shift, and go to state 63 @@ -704,110 +710,110 @@ state 40 state 41 - 84 numero: NUMERO . + 86 numero: NUMERO . - $default reduce using rule 84 (numero) + $default reduce using rule 86 (numero) state 42 - 62 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES + 64 leitura: READ . ABRE_PARENTESES lista_leituras FECHA_PARENTESES ABRE_PARENTESES shift, and go to state 68 state 43 - 66 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES + 68 escrita: WRITE . ABRE_PARENTESES lista_escritas FECHA_PARENTESES ABRE_PARENTESES shift, and go to state 69 state 44 - 45 comando_sem_rotulo: comando_composto . + 47 comando_sem_rotulo: comando_composto . - $default reduce using rule 45 (comando_sem_rotulo) + $default reduce using rule 47 (comando_sem_rotulo) state 45 - 38 comando_composto: T_BEGIN comandos . T_END + 40 comando_composto: T_BEGIN comandos . T_END T_END shift, and go to state 70 state 46 - 39 comandos: comando . PONTO_E_VIRGULA comandos - 40 | comando . PONTO_E_VIRGULA + 41 comandos: comando . PONTO_E_VIRGULA comandos + 42 | comando . PONTO_E_VIRGULA PONTO_E_VIRGULA shift, and go to state 71 state 47 - 43 comando: comando_sem_rotulo . + 45 comando: comando_sem_rotulo . - $default reduce using rule 43 (comando) + $default reduce using rule 45 (comando) state 48 - 44 comando_sem_rotulo: atribuicao_ou_procedimento . + 46 comando_sem_rotulo: atribuicao_ou_procedimento . - $default reduce using rule 44 (comando_sem_rotulo) + $default reduce using rule 46 (comando_sem_rotulo) state 49 - 48 comando_sem_rotulo: leitura . + 50 comando_sem_rotulo: leitura . - $default reduce using rule 48 (comando_sem_rotulo) + $default reduce using rule 50 (comando_sem_rotulo) state 50 - 49 comando_sem_rotulo: escrita . + 51 comando_sem_rotulo: escrita . - $default reduce using rule 49 (comando_sem_rotulo) + $default reduce using rule 51 (comando_sem_rotulo) state 51 - 42 comando: numero . DOIS_PONTOS comando_sem_rotulo + 44 comando: numero . DOIS_PONTOS comando_sem_rotulo DOIS_PONTOS shift, and go to state 72 state 52 - 47 comando_sem_rotulo: comando_repetitivo . + 49 comando_sem_rotulo: comando_repetitivo . - $default reduce using rule 47 (comando_sem_rotulo) + $default reduce using rule 49 (comando_sem_rotulo) state 53 - 87 comando_repetitivo: @15 . WHILE expressao DO @16 comando_sem_rotulo + 89 comando_repetitivo: @16 . WHILE expressao DO @17 comando_sem_rotulo WHILE shift, and go to state 73 state 54 - 46 comando_sem_rotulo: comando_condicional . + 48 comando_sem_rotulo: comando_condicional . - $default reduce using rule 46 (comando_sem_rotulo) + $default reduce using rule 48 (comando_sem_rotulo) state 55 - 88 comando_condicional: if_then . cond_else + 90 comando_condicional: if_then . cond_else ELSE shift, and go to state 74 - $default reduce using rule 90 (cond_else) + $default reduce using rule 92 (cond_else) cond_else go to state 75 @@ -853,41 +859,41 @@ state 60 state 61 - 51 atribuicao_ou_procedimento: IDENT @12 . atribuicao_ou_procedimento_token + 53 atribuicao_ou_procedimento: IDENT @13 . atribuicao_ou_procedimento_token - ATRIBUICAO reduce using rule 54 (@13) - $default reduce using rule 56 (@14) + ATRIBUICAO reduce using rule 56 (@14) + $default reduce using rule 58 (@15) atribuicao_ou_procedimento_token go to state 79 atribuicao go to state 80 - @13 go to state 81 + @14 go to state 81 chamada_procedimento go to state 82 - @14 go to state 83 + @15 go to state 83 state 62 - 82 fator: IDENT . + 84 fator: IDENT . - $default reduce using rule 82 (fator) + $default reduce using rule 84 (fator) state 63 - 83 fator: NUMERO . + 85 fator: NUMERO . - $default reduce using rule 83 (fator) + $default reduce using rule 85 (fator) state 64 - 69 expressao: expressao . IGUAL expressao_simples - 70 | expressao . DIFERENTE expressao_simples - 71 | expressao . MENOR expressao_simples - 72 | expressao . MENOR_IGUAL expressao_simples - 73 | expressao . MAIOR expressao_simples - 74 | expressao . MAIOR_IGUAL expressao_simples - 92 if_then: IF expressao . @17 THEN comando_sem_rotulo + 71 expressao: expressao . IGUAL expressao_simples + 72 | expressao . DIFERENTE expressao_simples + 73 | expressao . MENOR expressao_simples + 74 | expressao . MENOR_IGUAL expressao_simples + 75 | expressao . MAIOR expressao_simples + 76 | expressao . MAIOR_IGUAL expressao_simples + 94 if_then: IF expressao . @18 THEN comando_sem_rotulo IGUAL shift, and go to state 84 DIFERENTE shift, and go to state 85 @@ -896,45 +902,45 @@ state 64 MENOR shift, and go to state 88 MAIOR shift, and go to state 89 - $default reduce using rule 91 (@17) + $default reduce using rule 93 (@18) - @17 go to state 90 + @18 go to state 90 state 65 - 75 expressao: expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 77 expressao: expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 75 (expressao) + $default reduce using rule 77 (expressao) state 66 - 78 expressao_simples: termo . - 79 termo: termo . ASTERISCO fator - 80 | termo . DIV fator + 80 expressao_simples: termo . + 81 termo: termo . ASTERISCO fator + 82 | termo . DIV fator DIV shift, and go to state 93 ASTERISCO shift, and go to state 94 - $default reduce using rule 78 (expressao_simples) + $default reduce using rule 80 (expressao_simples) state 67 - 81 termo: fator . + 83 termo: fator . - $default reduce using rule 81 (termo) + $default reduce using rule 83 (termo) state 68 - 62 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES + 64 leitura: READ ABRE_PARENTESES . lista_leituras FECHA_PARENTESES IDENT shift, and go to state 95 @@ -944,7 +950,7 @@ state 68 state 69 - 66 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES + 68 escrita: WRITE ABRE_PARENTESES . lista_escritas FECHA_PARENTESES IDENT shift, and go to state 62 NUMERO shift, and go to state 63 @@ -957,15 +963,15 @@ state 69 state 70 - 38 comando_composto: T_BEGIN comandos T_END . + 40 comando_composto: T_BEGIN comandos T_END . - $default reduce using rule 38 (comando_composto) + $default reduce using rule 40 (comando_composto) state 71 - 39 comandos: comando PONTO_E_VIRGULA . comandos - 40 | comando PONTO_E_VIRGULA . + 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 @@ -974,10 +980,10 @@ state 71 READ shift, and go to state 42 WRITE shift, and go to state 43 - T_END reduce using rule 40 (comandos) - T_END [reduce using rule 41 (comandos)] - WHILE reduce using rule 85 (@15) - $default reduce using rule 40 (comandos) + T_END reduce using rule 42 (comandos) + T_END [reduce using rule 43 (comandos)] + WHILE reduce using rule 87 (@16) + $default reduce using rule 42 (comandos) comando_composto go to state 44 comandos go to state 100 @@ -988,14 +994,14 @@ state 71 escrita go to state 50 numero go to state 51 comando_repetitivo go to state 52 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 state 72 - 42 comando: numero DOIS_PONTOS . comando_sem_rotulo + 44 comando: numero DOIS_PONTOS . comando_sem_rotulo T_BEGIN shift, and go to state 34 IDENT shift, and go to state 39 @@ -1003,7 +1009,7 @@ state 72 READ shift, and go to state 42 WRITE shift, and go to state 43 - $default reduce using rule 85 (@15) + $default reduce using rule 87 (@16) comando_composto go to state 44 comando_sem_rotulo go to state 101 @@ -1011,14 +1017,14 @@ state 72 leitura go to state 49 escrita go to state 50 comando_repetitivo go to state 52 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 state 73 - 87 comando_repetitivo: @15 WHILE . expressao DO @16 comando_sem_rotulo + 89 comando_repetitivo: @16 WHILE . expressao DO @17 comando_sem_rotulo IDENT shift, and go to state 62 NUMERO shift, and go to state 63 @@ -1031,7 +1037,7 @@ state 73 state 74 - 89 cond_else: ELSE . comando_sem_rotulo + 91 cond_else: ELSE . comando_sem_rotulo T_BEGIN shift, and go to state 34 IDENT shift, and go to state 39 @@ -1039,7 +1045,7 @@ state 74 READ shift, and go to state 42 WRITE shift, and go to state 43 - $default reduce using rule 85 (@15) + $default reduce using rule 87 (@16) comando_composto go to state 44 comando_sem_rotulo go to state 103 @@ -1047,16 +1053,16 @@ state 74 leitura go to state 49 escrita go to state 50 comando_repetitivo go to state 52 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 state 75 - 88 comando_condicional: if_then cond_else . + 90 comando_condicional: if_then cond_else . - $default reduce using rule 88 (comando_condicional) + $default reduce using rule 90 (comando_condicional) state 76 @@ -1070,11 +1076,13 @@ state 77 29 parametros_ou_nada: ABRE_PARENTESES @9 . paramentros_formais @10 FECHA_PARENTESES - $default reduce using rule 33 (@11) + VAR shift, and go to state 105 - paramentros_formais go to state 105 - secao_pfs go to state 106 - @11 go to state 107 + $default reduce using rule 35 (@12) + + paramentros_formais go to state 106 + secao_pfs go to state 107 + @12 go to state 108 state 78 @@ -1085,239 +1093,239 @@ state 78 $default reduce using rule 7 (parte_declara_rotulos) - bloco go to state 108 + bloco go to state 109 parte_declara_rotulos go to state 15 state 79 - 51 atribuicao_ou_procedimento: IDENT @12 atribuicao_ou_procedimento_token . + 53 atribuicao_ou_procedimento: IDENT @13 atribuicao_ou_procedimento_token . - $default reduce using rule 51 (atribuicao_ou_procedimento) + $default reduce using rule 53 (atribuicao_ou_procedimento) state 80 - 52 atribuicao_ou_procedimento_token: atribuicao . + 54 atribuicao_ou_procedimento_token: atribuicao . - $default reduce using rule 52 (atribuicao_ou_procedimento_token) + $default reduce using rule 54 (atribuicao_ou_procedimento_token) state 81 - 55 atribuicao: @13 . ATRIBUICAO expressao_simples + 57 atribuicao: @14 . ATRIBUICAO expressao_simples - ATRIBUICAO shift, and go to state 109 + ATRIBUICAO shift, and go to state 110 state 82 - 53 atribuicao_ou_procedimento_token: chamada_procedimento . + 55 atribuicao_ou_procedimento_token: chamada_procedimento . - $default reduce using rule 53 (atribuicao_ou_procedimento_token) + $default reduce using rule 55 (atribuicao_ou_procedimento_token) state 83 - 57 chamada_procedimento: @14 . lista_parametros + 59 chamada_procedimento: @15 . lista_parametros - ABRE_PARENTESES shift, and go to state 110 + ABRE_PARENTESES shift, and go to state 111 - $default reduce using rule 59 (lista_parametros) + $default reduce using rule 61 (lista_parametros) - lista_parametros go to state 111 + lista_parametros go to state 112 state 84 - 69 expressao: expressao IGUAL . expressao_simples + 71 expressao: expressao IGUAL . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 112 + expressao_simples go to state 113 termo go to state 66 fator go to state 67 state 85 - 70 expressao: expressao DIFERENTE . expressao_simples + 72 expressao: expressao DIFERENTE . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 113 + expressao_simples go to state 114 termo go to state 66 fator go to state 67 state 86 - 72 expressao: expressao MENOR_IGUAL . expressao_simples + 74 expressao: expressao MENOR_IGUAL . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 114 + expressao_simples go to state 115 termo go to state 66 fator go to state 67 state 87 - 74 expressao: expressao MAIOR_IGUAL . expressao_simples + 76 expressao: expressao MAIOR_IGUAL . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 115 + expressao_simples go to state 116 termo go to state 66 fator go to state 67 state 88 - 71 expressao: expressao MENOR . expressao_simples + 73 expressao: expressao MENOR . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 116 + expressao_simples go to state 117 termo go to state 66 fator go to state 67 state 89 - 73 expressao: expressao MAIOR . expressao_simples + 75 expressao: expressao MAIOR . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 117 + expressao_simples go to state 118 termo go to state 66 fator go to state 67 state 90 - 92 if_then: IF expressao @17 . THEN comando_sem_rotulo + 94 if_then: IF expressao @18 . THEN comando_sem_rotulo - THEN shift, and go to state 118 + THEN shift, and go to state 119 state 91 - 76 expressao_simples: expressao_simples MAIS . termo + 78 expressao_simples: expressao_simples MAIS . termo IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - termo go to state 119 + termo go to state 120 fator go to state 67 state 92 - 77 expressao_simples: expressao_simples MENOS . termo + 79 expressao_simples: expressao_simples MENOS . termo IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - termo go to state 120 + termo go to state 121 fator go to state 67 state 93 - 80 termo: termo DIV . fator + 82 termo: termo DIV . fator IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - fator go to state 121 + fator go to state 122 state 94 - 79 termo: termo ASTERISCO . fator + 81 termo: termo ASTERISCO . fator IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - fator go to state 122 + fator go to state 123 state 95 - 65 simb_leitura: IDENT . + 67 simb_leitura: IDENT . - $default reduce using rule 65 (simb_leitura) + $default reduce using rule 67 (simb_leitura) state 96 - 62 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES - 63 lista_leituras: lista_leituras . VIRGULA simb_leitura + 64 leitura: READ ABRE_PARENTESES lista_leituras . FECHA_PARENTESES + 65 lista_leituras: lista_leituras . VIRGULA simb_leitura - FECHA_PARENTESES shift, and go to state 123 - VIRGULA shift, and go to state 124 + FECHA_PARENTESES shift, and go to state 124 + VIRGULA shift, and go to state 125 state 97 - 64 lista_leituras: simb_leitura . + 66 lista_leituras: simb_leitura . - $default reduce using rule 64 (lista_leituras) + $default reduce using rule 66 (lista_leituras) state 98 - 66 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES - 67 lista_escritas: lista_escritas . VIRGULA expressao_simples + 68 escrita: WRITE ABRE_PARENTESES lista_escritas . FECHA_PARENTESES + 69 lista_escritas: lista_escritas . VIRGULA expressao_simples - FECHA_PARENTESES shift, and go to state 125 - VIRGULA shift, and go to state 126 + FECHA_PARENTESES shift, and go to state 126 + VIRGULA shift, and go to state 127 state 99 - 68 lista_escritas: expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 70 lista_escritas: expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 68 (lista_escritas) + $default reduce using rule 70 (lista_escritas) state 100 - 39 comandos: comando PONTO_E_VIRGULA comandos . + 41 comandos: comando PONTO_E_VIRGULA comandos . - $default reduce using rule 39 (comandos) + $default reduce using rule 41 (comandos) state 101 - 42 comando: numero DOIS_PONTOS comando_sem_rotulo . + 44 comando: numero DOIS_PONTOS comando_sem_rotulo . - $default reduce using rule 42 (comando) + $default reduce using rule 44 (comando) state 102 - 69 expressao: expressao . IGUAL expressao_simples - 70 | expressao . DIFERENTE expressao_simples - 71 | expressao . MENOR expressao_simples - 72 | expressao . MENOR_IGUAL expressao_simples - 73 | expressao . MAIOR expressao_simples - 74 | expressao . MAIOR_IGUAL expressao_simples - 87 comando_repetitivo: @15 WHILE expressao . DO @16 comando_sem_rotulo + 71 expressao: expressao . IGUAL expressao_simples + 72 | expressao . DIFERENTE expressao_simples + 73 | expressao . MENOR expressao_simples + 74 | expressao . MENOR_IGUAL expressao_simples + 75 | expressao . MAIOR expressao_simples + 76 | expressao . MAIOR_IGUAL expressao_simples + 89 comando_repetitivo: @16 WHILE expressao . DO @17 comando_sem_rotulo - DO shift, and go to state 127 + 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 @@ -1328,9 +1336,9 @@ state 102 state 103 - 89 cond_else: ELSE comando_sem_rotulo . + 91 cond_else: ELSE comando_sem_rotulo . - $default reduce using rule 89 (cond_else) + $default reduce using rule 91 (cond_else) state 104 @@ -1342,103 +1350,100 @@ state 104 state 105 + 34 secao_pfs: VAR . @11 lista_id_pf DOIS_PONTOS tipo + + $default reduce using rule 33 (@11) + + @11 go to state 129 + + +state 106 + 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais . @10 FECHA_PARENTESES 32 paramentros_formais: paramentros_formais . PONTO_E_VIRGULA secao_pfs - PONTO_E_VIRGULA shift, and go to state 128 + PONTO_E_VIRGULA shift, and go to state 130 $default reduce using rule 28 (@10) - @10 go to state 129 + @10 go to state 131 -state 106 +state 107 31 paramentros_formais: secao_pfs . $default reduce using rule 31 (paramentros_formais) -state 107 +state 108 - 34 secao_pfs: @11 . lista_id_pf DOIS_PONTOS tipo + 36 secao_pfs: @12 . lista_id_pf DOIS_PONTOS tipo - IDENT shift, and go to state 130 + IDENT shift, and go to state 132 - lista_id_pf go to state 131 - parametro go to state 132 + lista_id_pf go to state 133 + parametro go to state 134 -state 108 +state 109 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco . @8 PONTO_E_VIRGULA $default reduce using rule 25 (@8) - @8 go to state 133 + @8 go to state 135 -state 109 +state 110 - 55 atribuicao: @13 ATRIBUICAO . expressao_simples + 57 atribuicao: @14 ATRIBUICAO . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 134 + expressao_simples go to state 136 termo go to state 66 fator go to state 67 -state 110 +state 111 - 58 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES + 60 lista_parametros: ABRE_PARENTESES . lista_parametros_parenteses FECHA_PARENTESES IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - lista_parametros_parenteses go to state 135 - expressao_simples go to state 136 + lista_parametros_parenteses go to state 137 + expressao_simples go to state 138 termo go to state 66 fator go to state 67 -state 111 - - 57 chamada_procedimento: @14 lista_parametros . - - $default reduce using rule 57 (chamada_procedimento) - - state 112 - 69 expressao: expressao IGUAL expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo - - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + 59 chamada_procedimento: @15 lista_parametros . - $default reduce using rule 69 (expressao) + $default reduce using rule 59 (chamada_procedimento) state 113 - 70 expressao: expressao DIFERENTE expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 71 expressao: expressao IGUAL expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 70 (expressao) + $default reduce using rule 71 (expressao) state 114 - 72 expressao: expressao MENOR_IGUAL expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 72 expressao: expressao DIFERENTE expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 @@ -1448,9 +1453,9 @@ state 114 state 115 - 74 expressao: expressao MAIOR_IGUAL expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 74 expressao: expressao MENOR_IGUAL expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 @@ -1460,21 +1465,21 @@ state 115 state 116 - 71 expressao: expressao MENOR expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 76 expressao: expressao MAIOR_IGUAL expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 71 (expressao) + $default reduce using rule 76 (expressao) state 117 - 73 expressao: expressao MAIOR expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 73 expressao: expressao MENOR expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 @@ -1484,7 +1489,19 @@ state 117 state 118 - 92 if_then: IF expressao @17 THEN . comando_sem_rotulo + 75 expressao: expressao MAIOR expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo + + MAIS shift, and go to state 91 + MENOS shift, and go to state 92 + + $default reduce using rule 75 (expressao) + + +state 119 + + 94 if_then: IF expressao @18 THEN . comando_sem_rotulo T_BEGIN shift, and go to state 34 IDENT shift, and go to state 39 @@ -1492,211 +1509,223 @@ state 118 READ shift, and go to state 42 WRITE shift, and go to state 43 - $default reduce using rule 85 (@15) + $default reduce using rule 87 (@16) comando_composto go to state 44 - comando_sem_rotulo go to state 137 + 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 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 -state 119 +state 120 - 76 expressao_simples: expressao_simples MAIS termo . - 79 termo: termo . ASTERISCO fator - 80 | termo . DIV fator + 78 expressao_simples: expressao_simples MAIS termo . + 81 termo: termo . ASTERISCO fator + 82 | termo . DIV fator DIV shift, and go to state 93 ASTERISCO shift, and go to state 94 - $default reduce using rule 76 (expressao_simples) + $default reduce using rule 78 (expressao_simples) -state 120 +state 121 - 77 expressao_simples: expressao_simples MENOS termo . - 79 termo: termo . ASTERISCO fator - 80 | termo . DIV fator + 79 expressao_simples: expressao_simples MENOS termo . + 81 termo: termo . ASTERISCO fator + 82 | termo . DIV fator DIV shift, and go to state 93 ASTERISCO shift, and go to state 94 - $default reduce using rule 77 (expressao_simples) - - -state 121 - - 80 termo: termo DIV fator . - - $default reduce using rule 80 (termo) + $default reduce using rule 79 (expressao_simples) state 122 - 79 termo: termo ASTERISCO fator . + 82 termo: termo DIV fator . - $default reduce using rule 79 (termo) + $default reduce using rule 82 (termo) state 123 - 62 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES . + 81 termo: termo ASTERISCO fator . - $default reduce using rule 62 (leitura) + $default reduce using rule 81 (termo) state 124 - 63 lista_leituras: lista_leituras VIRGULA . simb_leitura + 64 leitura: READ ABRE_PARENTESES lista_leituras FECHA_PARENTESES . - IDENT shift, and go to state 95 - - simb_leitura go to state 138 + $default reduce using rule 64 (leitura) state 125 - 66 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES . + 65 lista_leituras: lista_leituras VIRGULA . simb_leitura - $default reduce using rule 66 (escrita) + IDENT shift, and go to state 95 + simb_leitura go to state 140 -state 126 - 67 lista_escritas: lista_escritas VIRGULA . expressao_simples +state 126 - IDENT shift, and go to state 62 - NUMERO shift, and go to state 63 + 68 escrita: WRITE ABRE_PARENTESES lista_escritas FECHA_PARENTESES . - expressao_simples go to state 139 - termo go to state 66 - fator go to state 67 + $default reduce using rule 68 (escrita) state 127 - 87 comando_repetitivo: @15 WHILE expressao DO . @16 comando_sem_rotulo + 69 lista_escritas: lista_escritas VIRGULA . expressao_simples - $default reduce using rule 86 (@16) + IDENT shift, and go to state 62 + NUMERO shift, and go to state 63 - @16 go to state 140 + expressao_simples go to state 141 + termo go to state 66 + fator go to state 67 state 128 - 32 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs + 89 comando_repetitivo: @16 WHILE expressao DO . @17 comando_sem_rotulo - $default reduce using rule 33 (@11) + $default reduce using rule 88 (@17) - secao_pfs go to state 141 - @11 go to state 107 + @17 go to state 142 state 129 - 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 . FECHA_PARENTESES + 34 secao_pfs: VAR @11 . lista_id_pf DOIS_PONTOS tipo + + IDENT shift, and go to state 132 - FECHA_PARENTESES shift, and go to state 142 + lista_id_pf go to state 143 + parametro go to state 134 state 130 - 37 parametro: IDENT . + 32 paramentros_formais: paramentros_formais PONTO_E_VIRGULA . secao_pfs + + VAR shift, and go to state 105 + + $default reduce using rule 35 (@12) - $default reduce using rule 37 (parametro) + secao_pfs go to state 144 + @12 go to state 108 state 131 - 34 secao_pfs: @11 lista_id_pf . DOIS_PONTOS tipo + 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 . FECHA_PARENTESES - DOIS_PONTOS shift, and go to state 143 + FECHA_PARENTESES shift, and go to state 145 state 132 - 35 lista_id_pf: parametro . VIRGULA lista_id_pf - 36 | parametro . - - VIRGULA shift, and go to state 144 + 39 parametro: IDENT . - $default reduce using rule 36 (lista_id_pf) + $default reduce using rule 39 (parametro) state 133 - 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 . PONTO_E_VIRGULA + 36 secao_pfs: @12 lista_id_pf . DOIS_PONTOS tipo - PONTO_E_VIRGULA shift, and go to state 145 + DOIS_PONTOS shift, and go to state 146 state 134 - 55 atribuicao: @13 ATRIBUICAO expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 37 lista_id_pf: parametro . VIRGULA lista_id_pf + 38 | parametro . - MAIS shift, and go to state 91 - MENOS shift, and go to state 92 + VIRGULA shift, and go to state 147 - $default reduce using rule 55 (atribuicao) + $default reduce using rule 38 (lista_id_pf) state 135 - 58 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES - 60 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA expressao_simples + 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 . PONTO_E_VIRGULA - FECHA_PARENTESES shift, and go to state 146 - VIRGULA shift, and go to state 147 + PONTO_E_VIRGULA shift, and go to state 148 state 136 - 61 lista_parametros_parenteses: expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 57 atribuicao: @14 ATRIBUICAO expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 61 (lista_parametros_parenteses) + $default reduce using rule 57 (atribuicao) state 137 - 92 if_then: IF expressao @17 THEN comando_sem_rotulo . + 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses . FECHA_PARENTESES + 62 lista_parametros_parenteses: lista_parametros_parenteses . VIRGULA expressao_simples - $default reduce using rule 92 (if_then) + FECHA_PARENTESES shift, and go to state 149 + VIRGULA shift, and go to state 150 state 138 - 63 lista_leituras: lista_leituras VIRGULA simb_leitura . + 63 lista_parametros_parenteses: expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo - $default reduce using rule 63 (lista_leituras) + MAIS shift, and go to state 91 + MENOS shift, and go to state 92 + + $default reduce using rule 63 (lista_parametros_parenteses) state 139 - 67 lista_escritas: lista_escritas VIRGULA expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo + 94 if_then: IF expressao @18 THEN comando_sem_rotulo . + + $default reduce using rule 94 (if_then) + + +state 140 + + 65 lista_leituras: lista_leituras VIRGULA simb_leitura . + + $default reduce using rule 65 (lista_leituras) + + +state 141 + + 69 lista_escritas: lista_escritas VIRGULA expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 67 (lista_escritas) + $default reduce using rule 69 (lista_escritas) -state 140 +state 142 - 87 comando_repetitivo: @15 WHILE expressao DO @16 . comando_sem_rotulo + 89 comando_repetitivo: @16 WHILE expressao DO @17 . comando_sem_rotulo T_BEGIN shift, and go to state 34 IDENT shift, and go to state 39 @@ -1704,106 +1733,129 @@ state 140 READ shift, and go to state 42 WRITE shift, and go to state 43 - $default reduce using rule 85 (@15) + $default reduce using rule 87 (@16) comando_composto go to state 44 - comando_sem_rotulo go to state 148 + comando_sem_rotulo go to state 151 atribuicao_ou_procedimento go to state 48 leitura go to state 49 escrita go to state 50 comando_repetitivo go to state 52 - @15 go to state 53 + @16 go to state 53 comando_condicional go to state 54 if_then go to state 55 -state 141 +state 143 + + 34 secao_pfs: VAR @11 lista_id_pf . DOIS_PONTOS tipo + + DOIS_PONTOS shift, and go to state 152 + + +state 144 32 paramentros_formais: paramentros_formais PONTO_E_VIRGULA secao_pfs . $default reduce using rule 32 (paramentros_formais) -state 142 +state 145 29 parametros_ou_nada: ABRE_PARENTESES @9 paramentros_formais @10 FECHA_PARENTESES . $default reduce using rule 29 (parametros_ou_nada) -state 143 +state 146 - 34 secao_pfs: @11 lista_id_pf DOIS_PONTOS . tipo + 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS . tipo IDENT shift, and go to state 57 - tipo go to state 149 + tipo go to state 153 -state 144 +state 147 - 35 lista_id_pf: parametro VIRGULA . lista_id_pf + 37 lista_id_pf: parametro VIRGULA . lista_id_pf - IDENT shift, and go to state 130 + IDENT shift, and go to state 132 - lista_id_pf go to state 150 - parametro go to state 132 + lista_id_pf go to state 154 + parametro go to state 134 -state 145 +state 148 26 declaracao_procedimento: PROCEDURE IDENT @7 parametros_ou_nada PONTO_E_VIRGULA bloco @8 PONTO_E_VIRGULA . $default reduce using rule 26 (declaracao_procedimento) -state 146 +state 149 - 58 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES . + 60 lista_parametros: ABRE_PARENTESES lista_parametros_parenteses FECHA_PARENTESES . - $default reduce using rule 58 (lista_parametros) + $default reduce using rule 60 (lista_parametros) -state 147 +state 150 - 60 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . expressao_simples + 62 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA . expressao_simples IDENT shift, and go to state 62 NUMERO shift, and go to state 63 - expressao_simples go to state 151 + expressao_simples go to state 155 termo go to state 66 fator go to state 67 -state 148 +state 151 - 87 comando_repetitivo: @15 WHILE expressao DO @16 comando_sem_rotulo . + 89 comando_repetitivo: @16 WHILE expressao DO @17 comando_sem_rotulo . - $default reduce using rule 87 (comando_repetitivo) + $default reduce using rule 89 (comando_repetitivo) -state 149 +state 152 - 34 secao_pfs: @11 lista_id_pf DOIS_PONTOS tipo . + 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS . tipo - $default reduce using rule 34 (secao_pfs) + IDENT shift, and go to state 57 + tipo go to state 156 -state 150 - 35 lista_id_pf: parametro VIRGULA lista_id_pf . +state 153 - $default reduce using rule 35 (lista_id_pf) + 36 secao_pfs: @12 lista_id_pf DOIS_PONTOS tipo . + $default reduce using rule 36 (secao_pfs) -state 151 - 60 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples . - 76 expressao_simples: expressao_simples . MAIS termo - 77 | expressao_simples . MENOS termo +state 154 + + 37 lista_id_pf: parametro VIRGULA lista_id_pf . + + $default reduce using rule 37 (lista_id_pf) + + +state 155 + + 62 lista_parametros_parenteses: lista_parametros_parenteses VIRGULA expressao_simples . + 78 expressao_simples: expressao_simples . MAIS termo + 79 | expressao_simples . MENOS termo MAIS shift, and go to state 91 MENOS shift, and go to state 92 - $default reduce using rule 60 (lista_parametros_parenteses) + $default reduce using rule 62 (lista_parametros_parenteses) + + +state 156 + + 34 secao_pfs: VAR @11 lista_id_pf DOIS_PONTOS tipo . + + $default reduce using rule 34 (secao_pfs) diff --git a/compilador.y b/compilador.y index 028be4367f7bd50a4a51cd8accbbad82ad290f78..8c366e669e0b49e6513405c09ebc6650f1d3eca0 100644 --- a/compilador.y +++ b/compilador.y @@ -24,6 +24,8 @@ int rot_id; custom_stack_t *rot; custom_stack_t *proc; +int val_ou_ref; + %} %token PROGRAM ABRE_PARENTESES FECHA_PARENTESES @@ -203,7 +205,17 @@ paramentros_formais: secao_pfs | paramentros_formais PONTO_E_VIRGULA secao_pfs ; -secao_pfs: {num_vars = 0;} +secao_pfs: VAR + { + num_vars = 0; + val_ou_ref = REF; + } + lista_id_pf DOIS_PONTOS tipo + { num_param += num_vars;} + | { + num_vars = 0; + val_ou_ref = VLR; + } lista_id_pf DOIS_PONTOS tipo {num_param += num_vars;} ; @@ -217,7 +229,7 @@ parametro: IDENT { info_t info; info.pf.tipo = NSEI; info.pf.desloc = NSEI; - info.pf.passagem = VLR; + info.pf.passagem = val_ou_ref; insere_ts(token,PF,nivel_lexico,info,ts); } ; diff --git a/teste9.pas b/teste9.pas new file mode 100644 index 0000000000000000000000000000000000000000..49d026417cd9fdb31760e9c1c0efcd7d61bcef9a --- /dev/null +++ b/teste9.pas @@ -0,0 +1,11 @@ +program proc1 (input, output); + var x: integer; + procedure p(var a: integer; b: integer); + var z: integer; + begin + z := a; + end; +begin + x := 8; + p(x, 2); +end. \ No newline at end of file