diff --git a/a.out b/a.out index 2a3c0d4..a7cd74d 100755 Binary files a/a.out and b/a.out differ diff --git a/analyse_lexicale.lex b/analyse_lexicale.lex index 03da24f..b8d5686 100644 --- a/analyse_lexicale.lex +++ b/analyse_lexicale.lex @@ -39,6 +39,7 @@ tNOT "!" tAND "&&" tOR "||" tDIFF "!=" +tAPPERSAND "&" DIGIT [0-9] VARIABLE [A-Za-z0-9_]+ CONST "const" @@ -90,6 +91,7 @@ SEPARATOR {SPACE}|{TAB} {tELSE} {return tELSE ;} {tWHILE} {return tWHILE ;} +{tAPPERSAND} {return tAPPERSAND;} {CONST} {return tCONST ;} {ENTIER} {yylval.nombre = atoi(yytext); return tENTIER ;} {ENTIEREXP} {yylval.nombre = -1; return tENTIEREXP;} diff --git a/analyse_syntaxique.output b/analyse_syntaxique.output index 4e43f01..57848fc 100644 --- a/analyse_syntaxique.output +++ b/analyse_syntaxique.output @@ -1,1588 +1,1954 @@ -Terminaux inutilisés dans la grammaire +Terminals which are not used tENTIEREXP tERROR -Grammaire +Grammar - 0 $accept: Main $end + 0 $accept: C $end - 1 Main: tINT tMAIN tPO Params tPF Body + 1 C: Fonctions - 2 Params: %empty - 3 | Param SuiteParams + 2 Fonctions: Main + 3 | Fonction Fonctions - 4 Param: tINT tVAR + 4 @1: /* empty */ - 5 SuiteParams: tVIRGULE Param SuiteParams tPV - 6 | %empty + 5 Main: tINT tMAIN @1 tPO Params tPF Body - 7 Body: tAO Instructions Return tAF + 6 @2: /* empty */ - 8 Instructions: Instruction Instructions - 9 | %empty + 7 Fonction: Function_type tVAR @2 tPO Params tPF Body - 10 Instruction: Aff - 11 | If - 12 | While - 13 | Print - 14 | Decl - 15 | Invocation tPV + 8 Function_type: tINT + 9 | tINT tMUL - 16 Decl: Type Valeur SuiteDecl tPV + 10 Params: /* empty */ + 11 | Param SuiteParams - 17 SuiteDecl: tVIRGULE Valeur SuiteDecl - 18 | %empty + 12 Param: Param_type tVAR - 19 Type: tINT - 20 | tCONST tINT + 13 Param_type: tINT + 14 | tINT tMUL - 21 $@1: %empty + 15 SuiteParams: tVIRGULE Param SuiteParams + 16 | /* empty */ - 22 Valeur: tVAR $@1 tAFFECTATION E - 23 | tVAR + 17 Body: tAO Instructions Return tAF - 24 Aff: tVAR tAFFECTATION E tPV + 18 Instructions: Instruction Instructions + 19 | /* empty */ - 25 E: tENTIER - 26 | tVAR - 27 | E tADD E - 28 | E tMUL E - 29 | E tSUB E - 30 | E tDIV E - 31 | tSUB E - 32 | Invocation - 33 | tPO E tPF + 20 Instruction: Aff + 21 | If + 22 | While + 23 | Print + 24 | Decl + 25 | Invocation tPV - 34 Args: tVAR SuiteArgs - 35 | %empty + 26 Decl: Type Valeur SuiteDecl tPV - 36 SuiteArgs: tVIRGULE tVAR SuiteArgs - 37 | %empty + 27 SuiteDecl: tVIRGULE Valeur SuiteDecl + 28 | /* empty */ - 38 $@2: %empty + 29 Type: tINT + 30 | tCONST tINT + 31 | tINT tMUL - 39 $@3: %empty + 32 @3: /* empty */ - 40 If: tIF tPO Cond tPF $@2 tAO Instructions tAF $@3 Else + 33 Valeur: tVAR @3 tAFFECTATION E + 34 | tVAR - 41 Else: tELSE tAO Instructions tAF - 42 | %empty - 43 | tELSE tIF tPO Cond tPF tAO Instructions tAF Else + 35 Aff: tVAR tAFFECTATION E tPV + 36 | tMUL tVAR tAFFECTATION E tPV - 44 $@4: %empty + 37 E: tENTIER + 38 | tVAR + 39 | E tADD E + 40 | E tMUL E + 41 | E tSUB E + 42 | E tDIV E + 43 | tSUB E + 44 | Invocation + 45 | tPO E tPF + 46 | tAPPERSAND tVAR + 47 | tMUL tVAR - 45 $@5: %empty + 48 @4: /* empty */ - 46 While: tWHILE tPO $@4 Cond tPF $@5 tAO Instructions tAF + 49 @5: /* empty */ - 47 Cond: E tEGAL E - 48 | E tDIFF E - 49 | E tLT E - 50 | E tGT E - 51 | E tLTE E - 52 | E tGTE E - 53 | E tAND E - 54 | E tOR E - 55 | tNOT Cond - 56 | E + 50 @6: /* empty */ - 57 Invocation: tVAR tPO Args tPF + 51 @7: /* empty */ - 58 Print: tPRINT tPO E tPF tPV + 52 @8: /* empty */ - 59 Return: tRETURN E tPV + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 tAF @7 @8 Else + + 54 @9: /* empty */ + + 55 @10: /* empty */ + + 56 Else: tELSE tAO @9 Instructions tAF @10 + 57 | /* empty */ + 58 | tELSE If + + 59 @11: /* empty */ + + 60 @12: /* empty */ + + 61 @13: /* empty */ + + 62 @14: /* empty */ + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO @13 Instructions tAF @14 + + 64 Cond: E tEGAL E + 65 | E tDIFF E + 66 | E tLT E + 67 | E tGT E + 68 | E tLTE E + 69 | E tGTE E + 70 | E tAND E + 71 | E tOR E + 72 | tNOT Cond + 73 | E + + 74 @15: /* empty */ + + 75 Invocation: tVAR tPO @15 Args tPF + + 76 Args: Arg SuiteArgs + 77 | /* empty */ + + 78 Arg: E + + 79 SuiteArgs: tVIRGULE Arg SuiteArgs + 80 | /* empty */ + + 81 Print: tPRINT tPO E tPF tPV + + 82 Return: tRETURN E tPV -Terminaux, suivis des règles où ils apparaissent +Terminals, with rules where they appear $end (0) 0 error (256) -tENTIER (258) 25 +tENTIER (258) 37 tENTIEREXP (259) -tADD (260) 27 -tSUB (261) 29 31 -tMUL (262) 28 -tDIV (263) 30 -tPO (264) 1 33 40 43 46 57 58 -tPF (265) 1 33 40 43 46 57 58 -tAO (266) 7 40 41 43 46 -tAF (267) 7 40 41 43 46 +tADD (260) 39 +tSUB (261) 41 43 +tMUL (262) 9 14 31 36 40 47 +tDIV (263) 42 +tPO (264) 5 7 45 53 63 75 81 +tPF (265) 5 7 45 53 63 75 81 +tAO (266) 17 53 56 63 +tAF (267) 17 53 56 63 tERROR (268) -tPV (269) 5 15 16 24 58 59 -tVIRGULE (270) 5 17 36 -tAFFECTATION (271) 22 24 -tEGAL (272) 47 -tDIFF (273) 48 -tLT (274) 49 -tGT (275) 50 -tGTE (276) 52 -tLTE (277) 51 -tMAIN (278) 1 -tINT (279) 1 4 19 20 -tPRINT (280) 58 -tRETURN (281) 59 -tOR (282) 54 -tAND (283) 53 -tIF (284) 40 43 -tELSE (285) 41 43 -tWHILE (286) 46 -tCONST (287) 20 -tVAR (288) 4 22 23 24 26 34 36 57 -tNOT (289) 55 - - -Non-terminaux, suivis des règles où ils apparaissent - -$accept (35) - à gauche: 0 -Main (36) - à gauche: 1, à droite: 0 -Params (37) - à gauche: 2 3, à droite: 1 -Param (38) - à gauche: 4, à droite: 3 5 -SuiteParams (39) - à gauche: 5 6, à droite: 3 5 -Body (40) - à gauche: 7, à droite: 1 -Instructions (41) - à gauche: 8 9, à droite: 7 8 40 41 43 46 -Instruction (42) - à gauche: 10 11 12 13 14 15, à droite: 8 -Decl (43) - à gauche: 16, à droite: 14 -SuiteDecl (44) - à gauche: 17 18, à droite: 16 17 -Type (45) - à gauche: 19 20, à droite: 16 -Valeur (46) - à gauche: 22 23, à droite: 16 17 -$@1 (47) - à gauche: 21, à droite: 22 -Aff (48) - à gauche: 24, à droite: 10 -E (49) - à gauche: 25 26 27 28 29 30 31 32 33, à droite: 22 24 27 28 29 - 30 31 33 47 48 49 50 51 52 53 54 56 58 59 -Args (50) - à gauche: 34 35, à droite: 57 -SuiteArgs (51) - à gauche: 36 37, à droite: 34 36 -If (52) - à gauche: 40, à droite: 11 -$@2 (53) - à gauche: 38, à droite: 40 -$@3 (54) - à gauche: 39, à droite: 40 -Else (55) - à gauche: 41 42 43, à droite: 40 43 -While (56) - à gauche: 46, à droite: 12 -$@4 (57) - à gauche: 44, à droite: 46 -$@5 (58) - à gauche: 45, à droite: 46 -Cond (59) - à gauche: 47 48 49 50 51 52 53 54 55 56, à droite: 40 43 46 55 -Invocation (60) - à gauche: 57, à droite: 15 32 -Print (61) - à gauche: 58, à droite: 13 -Return (62) - à gauche: 59, à droite: 7 +tAPPERSAND (269) 46 +tPV (270) 25 26 35 36 81 82 +tVIRGULE (271) 15 27 79 +tAFFECTATION (272) 33 35 36 +tEGAL (273) 64 +tDIFF (274) 65 +tLT (275) 66 +tGT (276) 67 +tGTE (277) 69 +tLTE (278) 68 +tMAIN (279) 5 +tINT (280) 5 8 9 13 14 29 30 31 +tPRINT (281) 81 +tRETURN (282) 82 +tOR (283) 71 +tAND (284) 70 +tIF (285) 53 +tELSE (286) 56 58 +tWHILE (287) 63 +tCONST (288) 30 +tVAR (289) 7 12 33 34 35 36 38 46 47 75 +tNOT (290) 72 + + +Nonterminals, with rules where they appear + +$accept (36) + on left: 0 +C (37) + on left: 1, on right: 0 +Fonctions (38) + on left: 2 3, on right: 1 3 +Main (39) + on left: 5, on right: 2 +@1 (40) + on left: 4, on right: 5 +Fonction (41) + on left: 7, on right: 3 +@2 (42) + on left: 6, on right: 7 +Function_type (43) + on left: 8 9, on right: 7 +Params (44) + on left: 10 11, on right: 5 7 +Param (45) + on left: 12, on right: 11 15 +Param_type (46) + on left: 13 14, on right: 12 +SuiteParams (47) + on left: 15 16, on right: 11 15 +Body (48) + on left: 17, on right: 5 7 +Instructions (49) + on left: 18 19, on right: 17 18 53 56 63 +Instruction (50) + on left: 20 21 22 23 24 25, on right: 18 +Decl (51) + on left: 26, on right: 24 +SuiteDecl (52) + on left: 27 28, on right: 26 27 +Type (53) + on left: 29 30 31, on right: 26 +Valeur (54) + on left: 33 34, on right: 26 27 +@3 (55) + on left: 32, on right: 33 +Aff (56) + on left: 35 36, on right: 20 +E (57) + on left: 37 38 39 40 41 42 43 44 45 46 47, on right: 33 35 36 39 + 40 41 42 43 45 64 65 66 67 68 69 70 71 73 78 81 82 +If (58) + on left: 53, on right: 21 58 +@4 (59) + on left: 48, on right: 53 +@5 (60) + on left: 49, on right: 53 +@6 (61) + on left: 50, on right: 53 +@7 (62) + on left: 51, on right: 53 +@8 (63) + on left: 52, on right: 53 +Else (64) + on left: 56 57 58, on right: 53 +@9 (65) + on left: 54, on right: 56 +@10 (66) + on left: 55, on right: 56 +While (67) + on left: 63, on right: 22 +@11 (68) + on left: 59, on right: 63 +@12 (69) + on left: 60, on right: 63 +@13 (70) + on left: 61, on right: 63 +@14 (71) + on left: 62, on right: 63 +Cond (72) + on left: 64 65 66 67 68 69 70 71 72 73, on right: 53 63 72 +Invocation (73) + on left: 75, on right: 25 44 +@15 (74) + on left: 74, on right: 75 +Args (75) + on left: 76 77, on right: 75 +Arg (76) + on left: 78, on right: 76 79 +SuiteArgs (77) + on left: 79 80, on right: 76 79 +Print (78) + on left: 81, on right: 23 +Return (79) + on left: 82, on right: 17 -État 0 +state 0 - 0 $accept: . Main $end + 0 $accept: . C $end - tINT décalage et aller à l'état 1 + tINT shift, and go to state 1 - Main aller à l'état 2 + C go to state 2 + Fonctions go to state 3 + Main go to state 4 + Fonction go to state 5 + Function_type go to state 6 -État 1 +state 1 - 1 Main: tINT . tMAIN tPO Params tPF Body + 5 Main: tINT . tMAIN @1 tPO Params tPF Body + 8 Function_type: tINT . + 9 | tINT . tMUL - tMAIN décalage et aller à l'état 3 + tMUL shift, and go to state 7 + tMAIN shift, and go to state 8 + $default reduce using rule 8 (Function_type) -État 2 - 0 $accept: Main . $end +state 2 - $end décalage et aller à l'état 4 + 0 $accept: C . $end + $end shift, and go to state 9 -État 3 - 1 Main: tINT tMAIN . tPO Params tPF Body +state 3 - tPO décalage et aller à l'état 5 + 1 C: Fonctions . + $default reduce using rule 1 (C) -État 4 - 0 $accept: Main $end . +state 4 - $défaut accepter + 2 Fonctions: Main . + $default reduce using rule 2 (Fonctions) -État 5 - 1 Main: tINT tMAIN tPO . Params tPF Body +state 5 - tINT décalage et aller à l'état 6 + 3 Fonctions: Fonction . Fonctions - $défaut réduction par utilisation de la règle 2 (Params) + tINT shift, and go to state 1 - Params aller à l'état 7 - Param aller à l'état 8 + Fonctions go to state 10 + Main go to state 4 + Fonction go to state 5 + Function_type go to state 6 -État 6 +state 6 - 4 Param: tINT . tVAR + 7 Fonction: Function_type . tVAR @2 tPO Params tPF Body - tVAR décalage et aller à l'état 9 + tVAR shift, and go to state 11 -État 7 +state 7 - 1 Main: tINT tMAIN tPO Params . tPF Body + 9 Function_type: tINT tMUL . - tPF décalage et aller à l'état 10 + $default reduce using rule 9 (Function_type) -État 8 +state 8 - 3 Params: Param . SuiteParams + 5 Main: tINT tMAIN . @1 tPO Params tPF Body - tVIRGULE décalage et aller à l'état 11 + $default reduce using rule 4 (@1) - $défaut réduction par utilisation de la règle 6 (SuiteParams) + @1 go to state 12 - SuiteParams aller à l'état 12 +state 9 -État 9 + 0 $accept: C $end . - 4 Param: tINT tVAR . + $default accept - $défaut réduction par utilisation de la règle 4 (Param) +state 10 -État 10 + 3 Fonctions: Fonction Fonctions . - 1 Main: tINT tMAIN tPO Params tPF . Body + $default reduce using rule 3 (Fonctions) - tAO décalage et aller à l'état 13 - Body aller à l'état 14 +state 11 + 7 Fonction: Function_type tVAR . @2 tPO Params tPF Body -État 11 + $default reduce using rule 6 (@2) - 5 SuiteParams: tVIRGULE . Param SuiteParams tPV + @2 go to state 13 - tINT décalage et aller à l'état 6 - Param aller à l'état 15 +state 12 + 5 Main: tINT tMAIN @1 . tPO Params tPF Body -État 12 + tPO shift, and go to state 14 - 3 Params: Param SuiteParams . - $défaut réduction par utilisation de la règle 3 (Params) +state 13 + 7 Fonction: Function_type tVAR @2 . tPO Params tPF Body -État 13 + tPO shift, and go to state 15 - 7 Body: tAO . Instructions Return tAF - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 +state 14 - $défaut réduction par utilisation de la règle 9 (Instructions) + 5 Main: tINT tMAIN @1 tPO . Params tPF Body - Instructions aller à l'état 22 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 + tINT shift, and go to state 16 + $default reduce using rule 10 (Params) -État 14 + Params go to state 17 + Param go to state 18 + Param_type go to state 19 - 1 Main: tINT tMAIN tPO Params tPF Body . - $défaut réduction par utilisation de la règle 1 (Main) +state 15 + 7 Fonction: Function_type tVAR @2 tPO . Params tPF Body -État 15 + tINT shift, and go to state 16 - 5 SuiteParams: tVIRGULE Param . SuiteParams tPV + $default reduce using rule 10 (Params) - tVIRGULE décalage et aller à l'état 11 + Params go to state 20 + Param go to state 18 + Param_type go to state 19 - $défaut réduction par utilisation de la règle 6 (SuiteParams) - SuiteParams aller à l'état 31 +state 16 + 13 Param_type: tINT . + 14 | tINT . tMUL -État 16 + tMUL shift, and go to state 21 - 19 Type: tINT . + $default reduce using rule 13 (Param_type) - $défaut réduction par utilisation de la règle 19 (Type) +state 17 -État 17 + 5 Main: tINT tMAIN @1 tPO Params . tPF Body - 58 Print: tPRINT . tPO E tPF tPV + tPF shift, and go to state 22 - tPO décalage et aller à l'état 32 +state 18 -État 18 + 11 Params: Param . SuiteParams - 40 If: tIF . tPO Cond tPF $@2 tAO Instructions tAF $@3 Else + tVIRGULE shift, and go to state 23 - tPO décalage et aller à l'état 33 + $default reduce using rule 16 (SuiteParams) + SuiteParams go to state 24 -État 19 - 46 While: tWHILE . tPO $@4 Cond tPF $@5 tAO Instructions tAF +state 19 - tPO décalage et aller à l'état 34 + 12 Param: Param_type . tVAR + tVAR shift, and go to state 25 -État 20 - 20 Type: tCONST . tINT +state 20 - tINT décalage et aller à l'état 35 + 7 Fonction: Function_type tVAR @2 tPO Params . tPF Body + tPF shift, and go to state 26 -État 21 - 24 Aff: tVAR . tAFFECTATION E tPV - 57 Invocation: tVAR . tPO Args tPF +state 21 - tPO décalage et aller à l'état 36 - tAFFECTATION décalage et aller à l'état 37 + 14 Param_type: tINT tMUL . + $default reduce using rule 14 (Param_type) -État 22 - 7 Body: tAO Instructions . Return tAF +state 22 - tRETURN décalage et aller à l'état 38 + 5 Main: tINT tMAIN @1 tPO Params tPF . Body - Return aller à l'état 39 + tAO shift, and go to state 27 + Body go to state 28 -État 23 - 8 Instructions: Instruction . Instructions +state 23 - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 + 15 SuiteParams: tVIRGULE . Param SuiteParams - $défaut réduction par utilisation de la règle 9 (Instructions) + tINT shift, and go to state 16 - Instructions aller à l'état 40 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 + Param go to state 29 + Param_type go to state 19 -État 24 +state 24 - 14 Instruction: Decl . + 11 Params: Param SuiteParams . - $défaut réduction par utilisation de la règle 14 (Instruction) + $default reduce using rule 11 (Params) -État 25 +state 25 - 16 Decl: Type . Valeur SuiteDecl tPV + 12 Param: Param_type tVAR . - tVAR décalage et aller à l'état 41 + $default reduce using rule 12 (Param) - Valeur aller à l'état 42 +state 26 -État 26 + 7 Fonction: Function_type tVAR @2 tPO Params tPF . Body - 10 Instruction: Aff . + tAO shift, and go to state 27 - $défaut réduction par utilisation de la règle 10 (Instruction) + Body go to state 30 -État 27 +state 27 - 11 Instruction: If . + 17 Body: tAO . Instructions Return tAF - $défaut réduction par utilisation de la règle 11 (Instruction) + tMUL shift, and go to state 31 + tINT shift, and go to state 32 + tPRINT shift, and go to state 33 + tIF shift, and go to state 34 + tWHILE shift, and go to state 35 + tCONST shift, and go to state 36 + tVAR shift, and go to state 37 + $default reduce using rule 19 (Instructions) -État 28 + Instructions go to state 38 + Instruction go to state 39 + Decl go to state 40 + Type go to state 41 + Aff go to state 42 + If go to state 43 + While go to state 44 + Invocation go to state 45 + Print go to state 46 - 12 Instruction: While . - $défaut réduction par utilisation de la règle 12 (Instruction) +state 28 + 5 Main: tINT tMAIN @1 tPO Params tPF Body . -État 29 + $default reduce using rule 5 (Main) - 15 Instruction: Invocation . tPV - tPV décalage et aller à l'état 43 +state 29 + 15 SuiteParams: tVIRGULE Param . SuiteParams -État 30 + tVIRGULE shift, and go to state 23 - 13 Instruction: Print . + $default reduce using rule 16 (SuiteParams) - $défaut réduction par utilisation de la règle 13 (Instruction) + SuiteParams go to state 47 -État 31 +state 30 - 5 SuiteParams: tVIRGULE Param SuiteParams . tPV + 7 Fonction: Function_type tVAR @2 tPO Params tPF Body . - tPV décalage et aller à l'état 44 + $default reduce using rule 7 (Fonction) -État 32 +state 31 - 58 Print: tPRINT tPO . E tPF tPV + 36 Aff: tMUL . tVAR tAFFECTATION E tPV - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + tVAR shift, and go to state 48 - E aller à l'état 49 - Invocation aller à l'état 50 +state 32 -État 33 + 29 Type: tINT . + 31 | tINT . tMUL - 40 If: tIF tPO . Cond tPF $@2 tAO Instructions tAF $@3 Else + tMUL shift, and go to state 49 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - tNOT décalage et aller à l'état 51 + $default reduce using rule 29 (Type) - E aller à l'état 52 - Cond aller à l'état 53 - Invocation aller à l'état 50 +state 33 -État 34 + 81 Print: tPRINT . tPO E tPF tPV - 46 While: tWHILE tPO . $@4 Cond tPF $@5 tAO Instructions tAF + tPO shift, and go to state 50 - $défaut réduction par utilisation de la règle 44 ($@4) - $@4 aller à l'état 54 +state 34 + 53 If: tIF . tPO Cond tPF @4 tAO @5 Instructions @6 tAF @7 @8 Else -État 35 + tPO shift, and go to state 51 - 20 Type: tCONST tINT . - $défaut réduction par utilisation de la règle 20 (Type) +state 35 + 63 While: tWHILE . tPO @11 Cond tPF @12 tAO @13 Instructions tAF @14 -État 36 + tPO shift, and go to state 52 - 57 Invocation: tVAR tPO . Args tPF - tVAR décalage et aller à l'état 55 +state 36 - $défaut réduction par utilisation de la règle 35 (Args) + 30 Type: tCONST . tINT - Args aller à l'état 56 + tINT shift, and go to state 53 -État 37 +state 37 - 24 Aff: tVAR tAFFECTATION . E tPV + 35 Aff: tVAR . tAFFECTATION E tPV + 75 Invocation: tVAR . tPO @15 Args tPF - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + tPO shift, and go to state 54 + tAFFECTATION shift, and go to state 55 - E aller à l'état 57 - Invocation aller à l'état 50 +state 38 -État 38 + 17 Body: tAO Instructions . Return tAF - 59 Return: tRETURN . E tPV + tRETURN shift, and go to state 56 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + Return go to state 57 - E aller à l'état 58 - Invocation aller à l'état 50 +state 39 -État 39 + 18 Instructions: Instruction . Instructions - 7 Body: tAO Instructions Return . tAF + tMUL shift, and go to state 31 + tINT shift, and go to state 32 + tPRINT shift, and go to state 33 + tIF shift, and go to state 34 + tWHILE shift, and go to state 35 + tCONST shift, and go to state 36 + tVAR shift, and go to state 37 - tAF décalage et aller à l'état 59 + $default reduce using rule 19 (Instructions) + Instructions go to state 58 + Instruction go to state 39 + Decl go to state 40 + Type go to state 41 + Aff go to state 42 + If go to state 43 + While go to state 44 + Invocation go to state 45 + Print go to state 46 -État 40 - 8 Instructions: Instruction Instructions . +state 40 - $défaut réduction par utilisation de la règle 8 (Instructions) + 24 Instruction: Decl . + $default reduce using rule 24 (Instruction) -État 41 - 22 Valeur: tVAR . $@1 tAFFECTATION E - 23 | tVAR . +state 41 - tAFFECTATION réduction par utilisation de la règle 21 ($@1) - $défaut réduction par utilisation de la règle 23 (Valeur) + 26 Decl: Type . Valeur SuiteDecl tPV - $@1 aller à l'état 60 + tVAR shift, and go to state 59 + Valeur go to state 60 -État 42 - 16 Decl: Type Valeur . SuiteDecl tPV +state 42 - tVIRGULE décalage et aller à l'état 61 + 20 Instruction: Aff . - $défaut réduction par utilisation de la règle 18 (SuiteDecl) + $default reduce using rule 20 (Instruction) - SuiteDecl aller à l'état 62 +state 43 -État 43 + 21 Instruction: If . - 15 Instruction: Invocation tPV . + $default reduce using rule 21 (Instruction) - $défaut réduction par utilisation de la règle 15 (Instruction) +state 44 -État 44 + 22 Instruction: While . - 5 SuiteParams: tVIRGULE Param SuiteParams tPV . + $default reduce using rule 22 (Instruction) - $défaut réduction par utilisation de la règle 5 (SuiteParams) +state 45 -État 45 + 25 Instruction: Invocation . tPV - 25 E: tENTIER . + tPV shift, and go to state 61 - $défaut réduction par utilisation de la règle 25 (E) +state 46 -État 46 + 23 Instruction: Print . - 31 E: tSUB . E + $default reduce using rule 23 (Instruction) - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 63 - Invocation aller à l'état 50 +state 47 + 15 SuiteParams: tVIRGULE Param SuiteParams . -État 47 + $default reduce using rule 15 (SuiteParams) - 33 E: tPO . E tPF - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 +state 48 - E aller à l'état 64 - Invocation aller à l'état 50 + 36 Aff: tMUL tVAR . tAFFECTATION E tPV + tAFFECTATION shift, and go to state 62 -État 48 - 26 E: tVAR . - 57 Invocation: tVAR . tPO Args tPF +state 49 - tPO décalage et aller à l'état 36 + 31 Type: tINT tMUL . - $défaut réduction par utilisation de la règle 26 (E) + $default reduce using rule 31 (Type) -État 49 +state 50 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 58 Print: tPRINT tPO E . tPF tPV + 81 Print: tPRINT tPO . E tPF tPV - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - tPF décalage et aller à l'état 69 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 69 + Invocation go to state 70 -État 50 - 32 E: Invocation . +state 51 - $défaut réduction par utilisation de la règle 32 (E) + 53 If: tIF tPO . Cond tPF @4 tAO @5 Instructions @6 tAF @7 @8 Else + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + tNOT shift, and go to state 71 -État 51 + E go to state 72 + Cond go to state 73 + Invocation go to state 70 - 55 Cond: tNOT . Cond - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - tNOT décalage et aller à l'état 51 +state 52 - E aller à l'état 52 - Cond aller à l'état 70 - Invocation aller à l'état 50 + 63 While: tWHILE tPO . @11 Cond tPF @12 tAO @13 Instructions tAF @14 + $default reduce using rule 59 (@11) -État 52 + @11 go to state 74 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 47 Cond: E . tEGAL E - 48 | E . tDIFF E - 49 | E . tLT E - 50 | E . tGT E - 51 | E . tLTE E - 52 | E . tGTE E - 53 | E . tAND E - 54 | E . tOR E - 56 | E . - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - tEGAL décalage et aller à l'état 71 - tDIFF décalage et aller à l'état 72 - tLT décalage et aller à l'état 73 - tGT décalage et aller à l'état 74 - tGTE décalage et aller à l'état 75 - tLTE décalage et aller à l'état 76 - tOR décalage et aller à l'état 77 - tAND décalage et aller à l'état 78 +state 53 - $défaut réduction par utilisation de la règle 56 (Cond) + 30 Type: tCONST tINT . + $default reduce using rule 30 (Type) -État 53 - 40 If: tIF tPO Cond . tPF $@2 tAO Instructions tAF $@3 Else +state 54 - tPF décalage et aller à l'état 79 + 75 Invocation: tVAR tPO . @15 Args tPF + $default reduce using rule 74 (@15) -État 54 + @15 go to state 75 - 46 While: tWHILE tPO $@4 . Cond tPF $@5 tAO Instructions tAF - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - tNOT décalage et aller à l'état 51 +state 55 - E aller à l'état 52 - Cond aller à l'état 80 - Invocation aller à l'état 50 + 35 Aff: tVAR tAFFECTATION . E tPV + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 -État 55 + E go to state 76 + Invocation go to state 70 - 34 Args: tVAR . SuiteArgs - tVIRGULE décalage et aller à l'état 81 +state 56 - $défaut réduction par utilisation de la règle 37 (SuiteArgs) + 82 Return: tRETURN . E tPV - SuiteArgs aller à l'état 82 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 77 + Invocation go to state 70 -État 56 - 57 Invocation: tVAR tPO Args . tPF +state 57 - tPF décalage et aller à l'état 83 + 17 Body: tAO Instructions Return . tAF + tAF shift, and go to state 78 -État 57 - 24 Aff: tVAR tAFFECTATION E . tPV - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E +state 58 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - tPV décalage et aller à l'état 84 + 18 Instructions: Instruction Instructions . + $default reduce using rule 18 (Instructions) -État 58 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 59 Return: tRETURN E . tPV +state 59 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - tPV décalage et aller à l'état 85 + 33 Valeur: tVAR . @3 tAFFECTATION E + 34 | tVAR . + tAFFECTATION reduce using rule 32 (@3) + $default reduce using rule 34 (Valeur) -État 59 + @3 go to state 79 - 7 Body: tAO Instructions Return tAF . - $défaut réduction par utilisation de la règle 7 (Body) +state 60 + 26 Decl: Type Valeur . SuiteDecl tPV -État 60 + tVIRGULE shift, and go to state 80 - 22 Valeur: tVAR $@1 . tAFFECTATION E + $default reduce using rule 28 (SuiteDecl) - tAFFECTATION décalage et aller à l'état 86 + SuiteDecl go to state 81 -État 61 +state 61 - 17 SuiteDecl: tVIRGULE . Valeur SuiteDecl + 25 Instruction: Invocation tPV . - tVAR décalage et aller à l'état 41 + $default reduce using rule 25 (Instruction) - Valeur aller à l'état 87 +state 62 -État 62 + 36 Aff: tMUL tVAR tAFFECTATION . E tPV - 16 Decl: Type Valeur SuiteDecl . tPV + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - tPV décalage et aller à l'état 88 + E go to state 82 + Invocation go to state 70 -État 63 +state 63 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 31 | tSUB E . + 37 E: tENTIER . - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + $default reduce using rule 37 (E) - $défaut réduction par utilisation de la règle 31 (E) +state 64 -État 64 + 43 E: tSUB . E - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 33 | tPO E . tPF + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - tPF décalage et aller à l'état 89 + E go to state 83 + Invocation go to state 70 -État 65 +state 65 - 27 E: E tADD . E + 47 E: tMUL . tVAR - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + tVAR shift, and go to state 84 - E aller à l'état 90 - Invocation aller à l'état 50 +state 66 -État 66 + 45 E: tPO . E tPF - 29 E: E tSUB . E + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + E go to state 85 + Invocation go to state 70 - E aller à l'état 91 - Invocation aller à l'état 50 +state 67 -État 67 + 46 E: tAPPERSAND . tVAR - 28 E: E tMUL . E + tVAR shift, and go to state 86 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 92 - Invocation aller à l'état 50 +state 68 + 38 E: tVAR . + 75 Invocation: tVAR . tPO @15 Args tPF -État 68 + tPO shift, and go to state 54 - 30 E: E tDIV . E + $default reduce using rule 38 (E) - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 93 - Invocation aller à l'état 50 +state 69 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 81 Print: tPRINT tPO E . tPF tPV -État 69 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tPF shift, and go to state 91 - 58 Print: tPRINT tPO E tPF . tPV - tPV décalage et aller à l'état 94 +state 70 + 44 E: Invocation . -État 70 + $default reduce using rule 44 (E) - 55 Cond: tNOT Cond . - $défaut réduction par utilisation de la règle 55 (Cond) +state 71 + 72 Cond: tNOT . Cond -État 71 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + tNOT shift, and go to state 71 - 47 Cond: E tEGAL . E + E go to state 72 + Cond go to state 92 + Invocation go to state 70 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 95 - Invocation aller à l'état 50 +state 72 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 64 Cond: E . tEGAL E + 65 | E . tDIFF E + 66 | E . tLT E + 67 | E . tGT E + 68 | E . tLTE E + 69 | E . tGTE E + 70 | E . tAND E + 71 | E . tOR E + 73 | E . -État 72 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tEGAL shift, and go to state 93 + tDIFF shift, and go to state 94 + tLT shift, and go to state 95 + tGT shift, and go to state 96 + tGTE shift, and go to state 97 + tLTE shift, and go to state 98 + tOR shift, and go to state 99 + tAND shift, and go to state 100 - 48 Cond: E tDIFF . E + $default reduce using rule 73 (Cond) - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 96 - Invocation aller à l'état 50 +state 73 + 53 If: tIF tPO Cond . tPF @4 tAO @5 Instructions @6 tAF @7 @8 Else -État 73 + tPF shift, and go to state 101 - 49 Cond: E tLT . E - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 +state 74 - E aller à l'état 97 - Invocation aller à l'état 50 + 63 While: tWHILE tPO @11 . Cond tPF @12 tAO @13 Instructions tAF @14 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + tNOT shift, and go to state 71 -État 74 + E go to state 72 + Cond go to state 102 + Invocation go to state 70 - 50 Cond: E tGT . E - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 +state 75 - E aller à l'état 98 - Invocation aller à l'état 50 + 75 Invocation: tVAR tPO @15 . Args tPF + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 -État 75 + $default reduce using rule 77 (Args) - 52 Cond: E tGTE . E + E go to state 103 + Invocation go to state 70 + Args go to state 104 + Arg go to state 105 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - E aller à l'état 99 - Invocation aller à l'état 50 +state 76 + 35 Aff: tVAR tAFFECTATION E . tPV + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E -État 76 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tPV shift, and go to state 106 - 51 Cond: E tLTE . E - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 +state 77 - E aller à l'état 100 - Invocation aller à l'état 50 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 82 Return: tRETURN E . tPV + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tPV shift, and go to state 107 -État 77 - 54 Cond: E tOR . E +state 78 - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + 17 Body: tAO Instructions Return tAF . - E aller à l'état 101 - Invocation aller à l'état 50 + $default reduce using rule 17 (Body) -État 78 +state 79 - 53 Cond: E tAND . E + 33 Valeur: tVAR @3 . tAFFECTATION E - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + tAFFECTATION shift, and go to state 108 - E aller à l'état 102 - Invocation aller à l'état 50 +state 80 -État 79 + 27 SuiteDecl: tVIRGULE . Valeur SuiteDecl - 40 If: tIF tPO Cond tPF . $@2 tAO Instructions tAF $@3 Else + tVAR shift, and go to state 59 - $défaut réduction par utilisation de la règle 38 ($@2) + Valeur go to state 109 - $@2 aller à l'état 103 +state 81 -État 80 + 26 Decl: Type Valeur SuiteDecl . tPV - 46 While: tWHILE tPO $@4 Cond . tPF $@5 tAO Instructions tAF + tPV shift, and go to state 110 - tPF décalage et aller à l'état 104 +state 82 -État 81 + 36 Aff: tMUL tVAR tAFFECTATION E . tPV + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E - 36 SuiteArgs: tVIRGULE . tVAR SuiteArgs + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tPV shift, and go to state 111 - tVAR décalage et aller à l'état 105 +state 83 -État 82 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 43 | tSUB E . - 34 Args: tVAR SuiteArgs . + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - $défaut réduction par utilisation de la règle 34 (Args) + $default reduce using rule 43 (E) -État 83 +state 84 - 57 Invocation: tVAR tPO Args tPF . + 47 E: tMUL tVAR . - $défaut réduction par utilisation de la règle 57 (Invocation) + $default reduce using rule 47 (E) -État 84 +state 85 - 24 Aff: tVAR tAFFECTATION E tPV . + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 45 | tPO E . tPF - $défaut réduction par utilisation de la règle 24 (Aff) + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + tPF shift, and go to state 112 -État 85 +state 86 - 59 Return: tRETURN E tPV . + 46 E: tAPPERSAND tVAR . - $défaut réduction par utilisation de la règle 59 (Return) + $default reduce using rule 46 (E) -État 86 +state 87 - 22 Valeur: tVAR $@1 tAFFECTATION . E + 39 E: E tADD . E - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - E aller à l'état 106 - Invocation aller à l'état 50 + E go to state 113 + Invocation go to state 70 -État 87 +state 88 - 17 SuiteDecl: tVIRGULE Valeur . SuiteDecl + 41 E: E tSUB . E - tVIRGULE décalage et aller à l'état 61 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - $défaut réduction par utilisation de la règle 18 (SuiteDecl) + E go to state 114 + Invocation go to state 70 - SuiteDecl aller à l'état 107 +state 89 -État 88 + 40 E: E tMUL . E - 16 Decl: Type Valeur SuiteDecl tPV . + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - $défaut réduction par utilisation de la règle 16 (Decl) + E go to state 115 + Invocation go to state 70 -État 89 +state 90 - 33 E: tPO E tPF . + 42 E: E tDIV . E - $défaut réduction par utilisation de la règle 33 (E) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 116 + Invocation go to state 70 -État 90 - 27 E: E . tADD E - 27 | E tADD E . - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E +state 91 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 81 Print: tPRINT tPO E tPF . tPV - $défaut réduction par utilisation de la règle 27 (E) + tPV shift, and go to state 117 -État 91 +state 92 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 29 | E tSUB E . - 30 | E . tDIV E + 72 Cond: tNOT Cond . - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + $default reduce using rule 72 (Cond) - $défaut réduction par utilisation de la règle 29 (E) +state 93 -État 92 + 64 Cond: E tEGAL . E - 27 E: E . tADD E - 28 | E . tMUL E - 28 | E tMUL E . - 29 | E . tSUB E - 30 | E . tDIV E + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - tDIV décalage et aller à l'état 68 + E go to state 118 + Invocation go to state 70 - $défaut réduction par utilisation de la règle 28 (E) +state 94 -État 93 + 65 Cond: E tDIFF . E - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 30 | E tDIV E . + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - $défaut réduction par utilisation de la règle 30 (E) + E go to state 119 + Invocation go to state 70 -État 94 +state 95 - 58 Print: tPRINT tPO E tPF tPV . + 66 Cond: E tLT . E - $défaut réduction par utilisation de la règle 58 (Print) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 120 + Invocation go to state 70 -État 95 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 47 Cond: E tEGAL E . +state 96 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 67 Cond: E tGT . E - $défaut réduction par utilisation de la règle 47 (Cond) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 121 + Invocation go to state 70 -État 96 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 48 Cond: E tDIFF E . +state 97 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 69 Cond: E tGTE . E - $défaut réduction par utilisation de la règle 48 (Cond) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 122 + Invocation go to state 70 -État 97 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 49 Cond: E tLT E . +state 98 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 68 Cond: E tLTE . E - $défaut réduction par utilisation de la règle 49 (Cond) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 123 + Invocation go to state 70 -État 98 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 50 Cond: E tGT E . +state 99 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 71 Cond: E tOR . E - $défaut réduction par utilisation de la règle 50 (Cond) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 124 + Invocation go to state 70 -État 99 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 52 Cond: E tGTE E . +state 100 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 70 Cond: E tAND . E - $défaut réduction par utilisation de la règle 52 (Cond) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 + E go to state 125 + Invocation go to state 70 -État 100 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 51 Cond: E tLTE E . +state 101 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 53 If: tIF tPO Cond tPF . @4 tAO @5 Instructions @6 tAF @7 @8 Else - $défaut réduction par utilisation de la règle 51 (Cond) + $default reduce using rule 48 (@4) + @4 go to state 126 -État 101 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 54 Cond: E tOR E . +state 102 - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + 63 While: tWHILE tPO @11 Cond . tPF @12 tAO @13 Instructions tAF @14 - $défaut réduction par utilisation de la règle 54 (Cond) + tPF shift, and go to state 127 -État 102 +state 103 - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E - 53 Cond: E tAND E . + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 78 Arg: E . - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - $défaut réduction par utilisation de la règle 53 (Cond) + $default reduce using rule 78 (Arg) -État 103 +state 104 - 40 If: tIF tPO Cond tPF $@2 . tAO Instructions tAF $@3 Else + 75 Invocation: tVAR tPO @15 Args . tPF - tAO décalage et aller à l'état 108 + tPF shift, and go to state 128 -État 104 +state 105 - 46 While: tWHILE tPO $@4 Cond tPF . $@5 tAO Instructions tAF + 76 Args: Arg . SuiteArgs - $défaut réduction par utilisation de la règle 45 ($@5) + tVIRGULE shift, and go to state 129 - $@5 aller à l'état 109 + $default reduce using rule 80 (SuiteArgs) + SuiteArgs go to state 130 -État 105 - 36 SuiteArgs: tVIRGULE tVAR . SuiteArgs +state 106 - tVIRGULE décalage et aller à l'état 81 + 35 Aff: tVAR tAFFECTATION E tPV . - $défaut réduction par utilisation de la règle 37 (SuiteArgs) + $default reduce using rule 35 (Aff) - SuiteArgs aller à l'état 110 +state 107 -État 106 + 82 Return: tRETURN E tPV . - 22 Valeur: tVAR $@1 tAFFECTATION E . - 27 E: E . tADD E - 28 | E . tMUL E - 29 | E . tSUB E - 30 | E . tDIV E + $default reduce using rule 82 (Return) - tADD décalage et aller à l'état 65 - tSUB décalage et aller à l'état 66 - tMUL décalage et aller à l'état 67 - tDIV décalage et aller à l'état 68 - $défaut réduction par utilisation de la règle 22 (Valeur) +state 108 + 33 Valeur: tVAR @3 tAFFECTATION . E -État 107 + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - 17 SuiteDecl: tVIRGULE Valeur SuiteDecl . + E go to state 131 + Invocation go to state 70 - $défaut réduction par utilisation de la règle 17 (SuiteDecl) +state 109 -État 108 + 27 SuiteDecl: tVIRGULE Valeur . SuiteDecl - 40 If: tIF tPO Cond tPF $@2 tAO . Instructions tAF $@3 Else + tVIRGULE shift, and go to state 80 - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 + $default reduce using rule 28 (SuiteDecl) - $défaut réduction par utilisation de la règle 9 (Instructions) + SuiteDecl go to state 132 - Instructions aller à l'état 111 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 +state 110 -État 109 + 26 Decl: Type Valeur SuiteDecl tPV . - 46 While: tWHILE tPO $@4 Cond tPF $@5 . tAO Instructions tAF + $default reduce using rule 26 (Decl) - tAO décalage et aller à l'état 112 +state 111 -État 110 + 36 Aff: tMUL tVAR tAFFECTATION E tPV . - 36 SuiteArgs: tVIRGULE tVAR SuiteArgs . + $default reduce using rule 36 (Aff) - $défaut réduction par utilisation de la règle 36 (SuiteArgs) +state 112 -État 111 + 45 E: tPO E tPF . - 40 If: tIF tPO Cond tPF $@2 tAO Instructions . tAF $@3 Else + $default reduce using rule 45 (E) - tAF décalage et aller à l'état 113 +state 113 -État 112 + 39 E: E . tADD E + 39 | E tADD E . + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E - 46 While: tWHILE tPO $@4 Cond tPF $@5 tAO . Instructions tAF + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 + $default reduce using rule 39 (E) - $défaut réduction par utilisation de la règle 9 (Instructions) - Instructions aller à l'état 114 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 +state 114 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 41 | E tSUB E . + 42 | E . tDIV E -État 113 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - 40 If: tIF tPO Cond tPF $@2 tAO Instructions tAF . $@3 Else + $default reduce using rule 41 (E) - $défaut réduction par utilisation de la règle 39 ($@3) - $@3 aller à l'état 115 +state 115 + 39 E: E . tADD E + 40 | E . tMUL E + 40 | E tMUL E . + 41 | E . tSUB E + 42 | E . tDIV E -État 114 + tDIV shift, and go to state 90 - 46 While: tWHILE tPO $@4 Cond tPF $@5 tAO Instructions . tAF + $default reduce using rule 40 (E) - tAF décalage et aller à l'état 116 +state 116 -État 115 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 42 | E tDIV E . - 40 If: tIF tPO Cond tPF $@2 tAO Instructions tAF $@3 . Else + $default reduce using rule 42 (E) - tELSE décalage et aller à l'état 117 - $défaut réduction par utilisation de la règle 42 (Else) +state 117 - Else aller à l'état 118 + 81 Print: tPRINT tPO E tPF tPV . + $default reduce using rule 81 (Print) -État 116 - 46 While: tWHILE tPO $@4 Cond tPF $@5 tAO Instructions tAF . +state 118 - $défaut réduction par utilisation de la règle 46 (While) + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 64 Cond: E tEGAL E . + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 -État 117 + $default reduce using rule 64 (Cond) - 41 Else: tELSE . tAO Instructions tAF - 43 | tELSE . tIF tPO Cond tPF tAO Instructions tAF Else - tAO décalage et aller à l'état 119 - tIF décalage et aller à l'état 120 +state 119 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 65 Cond: E tDIFF E . -État 118 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - 40 If: tIF tPO Cond tPF $@2 tAO Instructions tAF $@3 Else . + $default reduce using rule 65 (Cond) - $défaut réduction par utilisation de la règle 40 (If) +state 120 -État 119 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 66 Cond: E tLT E . - 41 Else: tELSE tAO . Instructions tAF + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 + $default reduce using rule 66 (Cond) - $défaut réduction par utilisation de la règle 9 (Instructions) - Instructions aller à l'état 121 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 +state 121 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 67 Cond: E tGT E . -État 120 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - 43 Else: tELSE tIF . tPO Cond tPF tAO Instructions tAF Else + $default reduce using rule 67 (Cond) - tPO décalage et aller à l'état 122 +state 122 -État 121 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 69 Cond: E tGTE E . - 41 Else: tELSE tAO Instructions . tAF + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - tAF décalage et aller à l'état 123 + $default reduce using rule 69 (Cond) -État 122 +state 123 - 43 Else: tELSE tIF tPO . Cond tPF tAO Instructions tAF Else + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 68 Cond: E tLTE E . - tENTIER décalage et aller à l'état 45 - tSUB décalage et aller à l'état 46 - tPO décalage et aller à l'état 47 - tVAR décalage et aller à l'état 48 - tNOT décalage et aller à l'état 51 + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 - E aller à l'état 52 - Cond aller à l'état 124 - Invocation aller à l'état 50 + $default reduce using rule 68 (Cond) -État 123 +state 124 - 41 Else: tELSE tAO Instructions tAF . + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 71 Cond: E tOR E . - $défaut réduction par utilisation de la règle 41 (Else) + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + $default reduce using rule 71 (Cond) -État 124 - 43 Else: tELSE tIF tPO Cond . tPF tAO Instructions tAF Else +state 125 - tPF décalage et aller à l'état 125 + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + 70 Cond: E tAND E . + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 -État 125 + $default reduce using rule 70 (Cond) - 43 Else: tELSE tIF tPO Cond tPF . tAO Instructions tAF Else - tAO décalage et aller à l'état 126 +state 126 + 53 If: tIF tPO Cond tPF @4 . tAO @5 Instructions @6 tAF @7 @8 Else -État 126 + tAO shift, and go to state 133 - 43 Else: tELSE tIF tPO Cond tPF tAO . Instructions tAF Else - tINT décalage et aller à l'état 16 - tPRINT décalage et aller à l'état 17 - tIF décalage et aller à l'état 18 - tWHILE décalage et aller à l'état 19 - tCONST décalage et aller à l'état 20 - tVAR décalage et aller à l'état 21 +state 127 - $défaut réduction par utilisation de la règle 9 (Instructions) + 63 While: tWHILE tPO @11 Cond tPF . @12 tAO @13 Instructions tAF @14 - Instructions aller à l'état 127 - Instruction aller à l'état 23 - Decl aller à l'état 24 - Type aller à l'état 25 - Aff aller à l'état 26 - If aller à l'état 27 - While aller à l'état 28 - Invocation aller à l'état 29 - Print aller à l'état 30 + $default reduce using rule 60 (@12) + @12 go to state 134 -État 127 - 43 Else: tELSE tIF tPO Cond tPF tAO Instructions . tAF Else +state 128 - tAF décalage et aller à l'état 128 + 75 Invocation: tVAR tPO @15 Args tPF . + $default reduce using rule 75 (Invocation) -État 128 - 43 Else: tELSE tIF tPO Cond tPF tAO Instructions tAF . Else +state 129 - tELSE décalage et aller à l'état 117 + 79 SuiteArgs: tVIRGULE . Arg SuiteArgs - $défaut réduction par utilisation de la règle 42 (Else) + tENTIER shift, and go to state 63 + tSUB shift, and go to state 64 + tMUL shift, and go to state 65 + tPO shift, and go to state 66 + tAPPERSAND shift, and go to state 67 + tVAR shift, and go to state 68 - Else aller à l'état 129 + E go to state 103 + Invocation go to state 70 + Arg go to state 135 -État 129 +state 130 - 43 Else: tELSE tIF tPO Cond tPF tAO Instructions tAF Else . + 76 Args: Arg SuiteArgs . - $défaut réduction par utilisation de la règle 43 (Else) + $default reduce using rule 76 (Args) + + +state 131 + + 33 Valeur: tVAR @3 tAFFECTATION E . + 39 E: E . tADD E + 40 | E . tMUL E + 41 | E . tSUB E + 42 | E . tDIV E + + tADD shift, and go to state 87 + tSUB shift, and go to state 88 + tMUL shift, and go to state 89 + tDIV shift, and go to state 90 + + $default reduce using rule 33 (Valeur) + + +state 132 + + 27 SuiteDecl: tVIRGULE Valeur SuiteDecl . + + $default reduce using rule 27 (SuiteDecl) + + +state 133 + + 53 If: tIF tPO Cond tPF @4 tAO . @5 Instructions @6 tAF @7 @8 Else + + $default reduce using rule 49 (@5) + + @5 go to state 136 + + +state 134 + + 63 While: tWHILE tPO @11 Cond tPF @12 . tAO @13 Instructions tAF @14 + + tAO shift, and go to state 137 + + +state 135 + + 79 SuiteArgs: tVIRGULE Arg . SuiteArgs + + tVIRGULE shift, and go to state 129 + + $default reduce using rule 80 (SuiteArgs) + + SuiteArgs go to state 138 + + +state 136 + + 53 If: tIF tPO Cond tPF @4 tAO @5 . Instructions @6 tAF @7 @8 Else + + tMUL shift, and go to state 31 + tINT shift, and go to state 32 + tPRINT shift, and go to state 33 + tIF shift, and go to state 34 + tWHILE shift, and go to state 35 + tCONST shift, and go to state 36 + tVAR shift, and go to state 37 + + $default reduce using rule 19 (Instructions) + + Instructions go to state 139 + Instruction go to state 39 + Decl go to state 40 + Type go to state 41 + Aff go to state 42 + If go to state 43 + While go to state 44 + Invocation go to state 45 + Print go to state 46 + + +state 137 + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO . @13 Instructions tAF @14 + + $default reduce using rule 61 (@13) + + @13 go to state 140 + + +state 138 + + 79 SuiteArgs: tVIRGULE Arg SuiteArgs . + + $default reduce using rule 79 (SuiteArgs) + + +state 139 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions . @6 tAF @7 @8 Else + + $default reduce using rule 50 (@6) + + @6 go to state 141 + + +state 140 + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO @13 . Instructions tAF @14 + + tMUL shift, and go to state 31 + tINT shift, and go to state 32 + tPRINT shift, and go to state 33 + tIF shift, and go to state 34 + tWHILE shift, and go to state 35 + tCONST shift, and go to state 36 + tVAR shift, and go to state 37 + + $default reduce using rule 19 (Instructions) + + Instructions go to state 142 + Instruction go to state 39 + Decl go to state 40 + Type go to state 41 + Aff go to state 42 + If go to state 43 + While go to state 44 + Invocation go to state 45 + Print go to state 46 + + +state 141 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 . tAF @7 @8 Else + + tAF shift, and go to state 143 + + +state 142 + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO @13 Instructions . tAF @14 + + tAF shift, and go to state 144 + + +state 143 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 tAF . @7 @8 Else + + $default reduce using rule 51 (@7) + + @7 go to state 145 + + +state 144 + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO @13 Instructions tAF . @14 + + $default reduce using rule 62 (@14) + + @14 go to state 146 + + +state 145 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 tAF @7 . @8 Else + + $default reduce using rule 52 (@8) + + @8 go to state 147 + + +state 146 + + 63 While: tWHILE tPO @11 Cond tPF @12 tAO @13 Instructions tAF @14 . + + $default reduce using rule 63 (While) + + +state 147 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 tAF @7 @8 . Else + + tELSE shift, and go to state 148 + + $default reduce using rule 57 (Else) + + Else go to state 149 + + +state 148 + + 56 Else: tELSE . tAO @9 Instructions tAF @10 + 58 | tELSE . If + + tAO shift, and go to state 150 + tIF shift, and go to state 34 + + If go to state 151 + + +state 149 + + 53 If: tIF tPO Cond tPF @4 tAO @5 Instructions @6 tAF @7 @8 Else . + + $default reduce using rule 53 (If) + + +state 150 + + 56 Else: tELSE tAO . @9 Instructions tAF @10 + + $default reduce using rule 54 (@9) + + @9 go to state 152 + + +state 151 + + 58 Else: tELSE If . + + $default reduce using rule 58 (Else) + + +state 152 + + 56 Else: tELSE tAO @9 . Instructions tAF @10 + + tMUL shift, and go to state 31 + tINT shift, and go to state 32 + tPRINT shift, and go to state 33 + tIF shift, and go to state 34 + tWHILE shift, and go to state 35 + tCONST shift, and go to state 36 + tVAR shift, and go to state 37 + + $default reduce using rule 19 (Instructions) + + Instructions go to state 153 + Instruction go to state 39 + Decl go to state 40 + Type go to state 41 + Aff go to state 42 + If go to state 43 + While go to state 44 + Invocation go to state 45 + Print go to state 46 + + +state 153 + + 56 Else: tELSE tAO @9 Instructions . tAF @10 + + tAF shift, and go to state 154 + + +state 154 + + 56 Else: tELSE tAO @9 Instructions tAF . @10 + + $default reduce using rule 55 (@10) + + @10 go to state 155 + + +state 155 + + 56 Else: tELSE tAO @9 Instructions tAF @10 . + + $default reduce using rule 56 (Else) diff --git a/analyse_syntaxique.tab.c b/analyse_syntaxique.tab.c index 3b93487..71240d1 100644 --- a/analyse_syntaxique.tab.c +++ b/analyse_syntaxique.tab.c @@ -1,13 +1,14 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Bison implementation for Yacc-like parsers in C +/* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. - This program is free software: you can redistribute it and/or modify + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -44,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -52,26 +55,97 @@ /* Pure parsers. */ #define YYPURE 0 -/* Push parsers. */ -#define YYPUSH 0 +/* Using locations. */ +#define YYLSP_NEEDED 0 -/* Pull parsers. */ -#define YYPULL 1 + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + tENTIER = 258, + tENTIEREXP = 259, + tADD = 260, + tSUB = 261, + tMUL = 262, + tDIV = 263, + tPO = 264, + tPF = 265, + tAO = 266, + tAF = 267, + tERROR = 268, + tAPPERSAND = 269, + tPV = 270, + tVIRGULE = 271, + tAFFECTATION = 272, + tEGAL = 273, + tDIFF = 274, + tLT = 275, + tGT = 276, + tGTE = 277, + tLTE = 278, + tMAIN = 279, + tINT = 280, + tPRINT = 281, + tRETURN = 282, + tOR = 283, + tAND = 284, + tIF = 285, + tELSE = 286, + tWHILE = 287, + tCONST = 288, + tVAR = 289, + tNOT = 290 + }; +#endif +/* Tokens. */ +#define tENTIER 258 +#define tENTIEREXP 259 +#define tADD 260 +#define tSUB 261 +#define tMUL 262 +#define tDIV 263 +#define tPO 264 +#define tPF 265 +#define tAO 266 +#define tAF 267 +#define tERROR 268 +#define tAPPERSAND 269 +#define tPV 270 +#define tVIRGULE 271 +#define tAFFECTATION 272 +#define tEGAL 273 +#define tDIFF 274 +#define tLT 275 +#define tGT 276 +#define tGTE 277 +#define tLTE 278 +#define tMAIN 279 +#define tINT 280 +#define tPRINT 281 +#define tRETURN 282 +#define tOR 283 +#define tAND 284 +#define tIF 285 +#define tELSE 286 +#define tWHILE 287 +#define tCONST 288 +#define tVAR 289 +#define tNOT 290 /* Copy the first part of user declarations. */ -#line 67 "analyse_syntaxique.tab.c" /* yacc.c:339 */ -# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# endif +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -81,97 +155,48 @@ # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "analyse_syntaxique.tab.h". */ -#ifndef YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED -# define YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int yydebug; +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 #endif -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - tENTIER = 258, - tENTIEREXP = 259, - tADD = 260, - tSUB = 261, - tMUL = 262, - tDIV = 263, - tPO = 264, - tPF = 265, - tAO = 266, - tAF = 267, - tERROR = 268, - tPV = 269, - tVIRGULE = 270, - tAFFECTATION = 271, - tEGAL = 272, - tDIFF = 273, - tLT = 274, - tGT = 275, - tGTE = 276, - tLTE = 277, - tMAIN = 278, - tINT = 279, - tPRINT = 280, - tRETURN = 281, - tOR = 282, - tAND = 283, - tIF = 284, - tELSE = 285, - tWHILE = 286, - tCONST = 287, - tVAR = 288, - tNOT = 289 - }; -#endif - -/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE +typedef union YYSTYPE +#line 1 "analyse_syntaxique.y" { -#line 1 "analyse_syntaxique.y" /* yacc.c:355 */ - int nombre; char id[30]; - -#line 147 "analyse_syntaxique.tab.c" /* yacc.c:355 */ -}; - -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 +} +/* Line 193 of yacc.c. */ +#line 172 "analyse_syntaxique.tab.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ -#line 6 "analyse_syntaxique.y" /* yacc.c:358 */ +#line 6 "analyse_syntaxique.y" #include #include "table_symboles.h" +#include "table_fonctions.h" #include "gen_assembleur.h" enum Initialised_Variable init; enum Symbole_Type type; +enum Return_Type return_type; Table_Symboles table; +Table_Fonctions table_fonctions; instructions_array array; int whileCondition; +int return_value; -#line 175 "analyse_syntaxique.tab.c" /* yacc.c:358 */ + +/* Line 216 of yacc.c. */ +#line 200 "analyse_syntaxique.tab.c" #ifdef short # undef short @@ -185,8 +210,11 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#else +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -206,7 +234,8 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -220,67 +249,38 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YYUSE(e) ((void) (e)) #else -# define YYUSE(E) /* empty */ +# define YYUSE(e) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) #else -# define YY_INITIAL_VALUE(Value) Value +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; #endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END +{ + return i; +} #endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - #if ! defined yyoverflow || YYERROR_VERBOSE @@ -299,11 +299,11 @@ typedef short int yytype_int16; # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # endif @@ -311,8 +311,8 @@ typedef short int yytype_int16; # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -326,23 +326,25 @@ typedef short int yytype_int16; # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ +# if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -352,14 +354,14 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; + yytype_int16 yyss; + YYSTYPE yyvs; + }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -370,70 +372,64 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -# define YYCOPY_NEEDED 1 +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) #endif -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (0) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 4 +#define YYFINAL 9 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 140 +#define YYLAST 156 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 35 +#define YYNTOKENS 36 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 28 +#define YYNNTS 44 /* YYNRULES -- Number of rules. */ -#define YYNRULES 60 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 130 +#define YYNRULES 83 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 156 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 289 +#define YYMAXUTOK 290 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -464,236 +460,353 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35 }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 7, 10, 11, 19, 20, 28, + 30, 33, 34, 37, 40, 42, 45, 49, 50, 55, + 58, 59, 61, 63, 65, 67, 69, 72, 77, 81, + 82, 84, 87, 90, 91, 96, 98, 103, 109, 111, + 113, 117, 121, 125, 129, 132, 134, 138, 141, 144, + 145, 146, 147, 148, 149, 163, 164, 165, 172, 173, + 176, 177, 178, 179, 180, 192, 196, 200, 204, 208, + 212, 216, 220, 224, 227, 229, 230, 236, 239, 240, + 242, 246, 247, 253 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 37, 0, -1, 38, -1, 39, -1, 41, 38, -1, + -1, 25, 24, 40, 9, 44, 10, 48, -1, -1, + 43, 34, 42, 9, 44, 10, 48, -1, 25, -1, + 25, 7, -1, -1, 45, 47, -1, 46, 34, -1, + 25, -1, 25, 7, -1, 16, 45, 47, -1, -1, + 11, 49, 79, 12, -1, 50, 49, -1, -1, 56, + -1, 58, -1, 67, -1, 78, -1, 51, -1, 73, + 15, -1, 53, 54, 52, 15, -1, 16, 54, 52, + -1, -1, 25, -1, 33, 25, -1, 25, 7, -1, + -1, 34, 55, 17, 57, -1, 34, -1, 34, 17, + 57, 15, -1, 7, 34, 17, 57, 15, -1, 3, + -1, 34, -1, 57, 5, 57, -1, 57, 7, 57, + -1, 57, 6, 57, -1, 57, 8, 57, -1, 6, + 57, -1, 73, -1, 9, 57, 10, -1, 14, 34, + -1, 7, 34, -1, -1, -1, -1, -1, -1, 30, + 9, 72, 10, 59, 11, 60, 49, 61, 12, 62, + 63, 64, -1, -1, -1, 31, 11, 65, 49, 12, + 66, -1, -1, 31, 58, -1, -1, -1, -1, -1, + 32, 9, 68, 72, 10, 69, 11, 70, 49, 12, + 71, -1, 57, 18, 57, -1, 57, 19, 57, -1, + 57, 20, 57, -1, 57, 21, 57, -1, 57, 23, + 57, -1, 57, 22, 57, -1, 57, 29, 57, -1, + 57, 28, 57, -1, 35, 72, -1, 57, -1, -1, + 34, 9, 74, 75, 10, -1, 76, 77, -1, -1, + 57, -1, 16, 76, 77, -1, -1, 26, 9, 57, + 10, 15, -1, 27, 57, 15, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 78, 78, 80, 81, 83, 86, 87, 90, 92, - 93, 95, 96, 97, 98, 99, 100, 102, 104, 105, - 107, 108, 110, 110, 111, 114, 117, 119, 121, 122, - 123, 124, 125, 126, 127, 130, 131, 133, 134, 136, - 143, 136, 149, 150, 151, 153, 155, 153, 169, 170, - 171, 172, 173, 174, 175, 176, 177, 178, 183, 186, - 189 + 0, 83, 83, 85, 86, 89, 89, 90, 90, 92, + 93, 95, 96, 98, 100, 101, 103, 104, 107, 109, + 110, 112, 113, 114, 115, 116, 117, 119, 121, 122, + 124, 125, 126, 128, 128, 129, 132, 133, 136, 137, + 138, 139, 140, 141, 142, 143, 149, 150, 151, 154, + 160, 160, 160, 161, 154, 167, 167, 167, 168, 169, + 171, 173, 179, 179, 171, 186, 187, 188, 189, 190, + 191, 192, 193, 194, 195, 197, 197, 204, 205, 206, + 207, 208, 210, 212 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "tENTIER", "tENTIEREXP", "tADD", "tSUB", - "tMUL", "tDIV", "tPO", "tPF", "tAO", "tAF", "tERROR", "tPV", "tVIRGULE", - "tAFFECTATION", "tEGAL", "tDIFF", "tLT", "tGT", "tGTE", "tLTE", "tMAIN", - "tINT", "tPRINT", "tRETURN", "tOR", "tAND", "tIF", "tELSE", "tWHILE", - "tCONST", "tVAR", "tNOT", "$accept", "Main", "Params", "Param", - "SuiteParams", "Body", "Instructions", "Instruction", "Decl", - "SuiteDecl", "Type", "Valeur", "$@1", "Aff", "E", "Args", "SuiteArgs", - "If", "$@2", "$@3", "Else", "While", "$@4", "$@5", "Cond", "Invocation", - "Print", "Return", YY_NULLPTR + "tMUL", "tDIV", "tPO", "tPF", "tAO", "tAF", "tERROR", "tAPPERSAND", + "tPV", "tVIRGULE", "tAFFECTATION", "tEGAL", "tDIFF", "tLT", "tGT", + "tGTE", "tLTE", "tMAIN", "tINT", "tPRINT", "tRETURN", "tOR", "tAND", + "tIF", "tELSE", "tWHILE", "tCONST", "tVAR", "tNOT", "$accept", "C", + "Fonctions", "Main", "@1", "Fonction", "@2", "Function_type", "Params", + "Param", "Param_type", "SuiteParams", "Body", "Instructions", + "Instruction", "Decl", "SuiteDecl", "Type", "Valeur", "@3", "Aff", "E", + "If", "@4", "@5", "@6", "@7", "@8", "Else", "@9", "@10", "While", "@11", + "@12", "@13", "@14", "Cond", "Invocation", "@15", "Args", "Arg", + "SuiteArgs", "Print", "Return", 0 }; #endif # ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289 + 285, 286, 287, 288, 289, 290 }; # endif -#define YYPACT_NINF -50 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-50))) - -#define YYTABLE_NINF -23 - -#define yytable_value_is_error(Yytable_value) \ - 0 - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int8 yypact[] = +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = { - -20, -16, 11, 10, -50, -8, -6, 25, 47, -50, - 30, -8, -50, 56, -50, 47, -50, 63, 65, 73, - 59, 55, 58, 56, -50, 72, -50, -50, -50, 84, - -50, 93, 19, 17, -50, -50, 75, 19, 19, 97, - -50, 94, 96, -50, -50, -50, 19, 19, 103, 53, - -50, 17, 48, 104, 17, 100, 106, 7, 26, -50, - 101, 72, 105, 22, 86, 19, 19, 19, 19, 107, - -50, 19, 19, 19, 19, 19, 19, 19, 19, -50, - 108, 87, -50, -50, -50, -50, 19, 96, -50, -50, - 71, 22, 114, -50, -50, 95, 95, 95, 95, 95, - 95, 95, 95, 112, -50, 100, 95, -50, 56, 113, - -50, 115, 56, -50, 116, 99, -50, -5, -50, 56, - 117, 118, 17, -50, 121, 122, 56, 120, 99, -50 + 0, 36, 37, 38, 38, 40, 39, 42, 41, 43, + 43, 44, 44, 45, 46, 46, 47, 47, 48, 49, + 49, 50, 50, 50, 50, 50, 50, 51, 52, 52, + 53, 53, 53, 55, 54, 54, 56, 56, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 59, + 60, 61, 62, 63, 58, 65, 66, 64, 64, 64, + 68, 69, 70, 71, 67, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 74, 73, 75, 75, 76, + 77, 77, 78, 79 }; - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 2, 0, 7, 0, 7, 1, + 2, 0, 2, 2, 1, 2, 3, 0, 4, 2, + 0, 1, 1, 1, 1, 1, 2, 4, 3, 0, + 1, 2, 2, 0, 4, 1, 4, 5, 1, 1, + 3, 3, 3, 3, 2, 1, 3, 2, 2, 0, + 0, 0, 0, 0, 13, 0, 0, 6, 0, 2, + 0, 0, 0, 0, 11, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 0, 5, 2, 0, 1, + 3, 0, 5, 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 0, 0, 0, 1, 3, 0, 0, 7, 5, - 0, 0, 4, 10, 2, 7, 20, 0, 0, 0, - 0, 0, 0, 10, 15, 0, 11, 12, 13, 0, - 14, 0, 0, 0, 45, 21, 36, 0, 0, 0, - 9, 24, 19, 16, 6, 26, 0, 0, 27, 0, - 33, 0, 57, 0, 0, 38, 0, 0, 0, 8, - 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, - 56, 0, 0, 0, 0, 0, 0, 0, 0, 39, - 0, 0, 35, 58, 25, 60, 0, 19, 17, 34, - 28, 30, 29, 31, 59, 48, 49, 50, 51, 53, - 52, 55, 54, 0, 46, 38, 23, 18, 10, 0, - 37, 0, 10, 40, 0, 43, 47, 0, 41, 10, - 0, 0, 0, 42, 0, 0, 10, 0, 43, 44 + 0, 9, 0, 2, 3, 0, 0, 10, 5, 1, + 4, 7, 0, 0, 11, 11, 14, 0, 17, 0, + 0, 15, 0, 0, 12, 13, 0, 20, 6, 17, + 8, 0, 30, 0, 0, 0, 0, 0, 0, 20, + 25, 0, 21, 22, 23, 0, 24, 16, 0, 32, + 0, 0, 60, 31, 75, 0, 0, 0, 19, 35, + 29, 26, 0, 38, 0, 0, 0, 0, 39, 0, + 45, 0, 74, 0, 0, 78, 0, 0, 18, 0, + 0, 0, 0, 44, 48, 0, 47, 0, 0, 0, + 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, + 0, 49, 0, 79, 0, 81, 36, 83, 0, 29, + 27, 37, 46, 40, 42, 41, 43, 82, 65, 66, + 67, 68, 70, 69, 72, 71, 0, 61, 76, 0, + 77, 34, 28, 50, 0, 81, 20, 62, 80, 51, + 20, 0, 0, 52, 63, 53, 64, 58, 0, 54, + 55, 59, 20, 0, 56, 57 }; - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = { - -50, -50, -50, 123, 110, -50, -22, -50, -50, 49, - -50, 74, -50, -50, -29, -50, 32, -50, -50, -50, - 12, -50, -50, -50, -49, -13, -50, -50 + -1, 2, 3, 4, 12, 5, 13, 6, 17, 18, + 19, 24, 28, 38, 39, 40, 81, 41, 60, 79, + 42, 72, 43, 126, 136, 141, 145, 147, 149, 152, + 155, 44, 74, 134, 140, 146, 73, 70, 75, 104, + 105, 130, 46, 57 }; - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -62 +static const yytype_int16 yypact[] = { - -1, 2, 7, 8, 12, 14, 22, 23, 24, 62, - 25, 42, 60, 26, 52, 56, 82, 27, 103, 115, - 118, 28, 54, 109, 53, 50, 30, 39 + -14, -4, 15, -62, -62, -14, -15, -62, -62, -62, + -62, -62, 12, 25, -1, -1, 30, 34, 39, 22, + 48, -62, 51, -1, -62, -62, 51, 50, -62, 39, + -62, 27, 52, 64, 68, 70, 47, 0, 66, 50, + -62, 62, -62, -62, -62, 82, -62, -62, 83, -62, + 29, 19, -62, -62, -62, 29, 29, 87, -62, 90, + 85, -62, 29, -62, 29, 74, 29, 76, 102, 84, + -62, 19, 98, 105, 19, 29, 59, 63, -62, 95, + 62, 107, 80, -2, -62, 123, -62, 29, 29, 29, + 29, 108, -62, 29, 29, 29, 29, 29, 29, 29, + 29, -62, 114, 129, 122, 124, -62, -62, 29, 85, + -62, -62, -62, 23, -2, 130, -62, -62, 129, 129, + 129, 129, 129, 129, 129, 129, 128, -62, -62, 29, + -62, 129, -62, -62, 131, 124, 50, -62, -62, -62, + 50, 132, 133, -62, -62, -62, -62, 110, -7, -62, + -62, -62, 50, 134, -62, -62 }; - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -62, -62, 138, -62, -62, -62, -62, -62, 135, 125, + -62, 118, 126, -38, -62, -62, 40, -62, 71, -62, + -62, -48, 5, -62, -62, -62, -62, -62, -62, -62, + -62, -62, -62, -62, -62, -62, -61, -27, -62, -62, + 26, 21, -62, -62 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -34 static const yytype_int16 yytable[] = { - 29, 40, 70, 49, 1, 80, 119, 3, 57, 58, - 29, 4, 65, 66, 67, 68, 6, 63, 64, 5, - 45, 84, 45, 46, 120, 46, 47, 9, 47, 67, - 68, 65, 66, 67, 68, 10, 90, 91, 92, 93, - 85, 13, 95, 96, 97, 98, 99, 100, 101, 102, - 48, 51, 48, 65, 66, 67, 68, 106, 65, 66, - 67, 68, 11, 69, 36, 71, 72, 73, 74, 75, - 76, 37, 32, 124, 33, 77, 78, 66, 67, 68, - 16, 17, 34, 35, 38, 18, 111, 19, 20, 21, - 114, 65, 66, 67, 68, 29, 89, 121, 43, 29, - 65, 66, 67, 68, 127, 41, 29, 44, 55, 59, - -22, 61, 36, 29, 79, 81, 83, 86, 104, 88, - 105, 94, 68, 108, 112, 31, 122, 113, 116, 117, - 123, 125, 128, 126, 15, 87, 107, 110, 0, 0, - 129 + 45, 58, 69, 7, 150, 89, 90, 76, 77, 54, + 92, 1, 45, 102, 82, 9, 83, 55, 85, 11, + 8, 14, 63, 34, 16, 64, 65, 103, 66, 88, + 89, 90, 63, 67, 15, 64, 65, 21, 66, 113, + 114, 115, 116, 67, 22, 118, 119, 120, 121, 122, + 123, 124, 125, 68, 71, 23, 25, 31, 26, 49, + 131, 48, 27, 68, 87, 88, 89, 90, 87, 88, + 89, 90, 53, 50, 106, 32, 33, 51, 107, 52, + 34, 103, 35, 36, 37, 87, 88, 89, 90, 87, + 88, 89, 90, 56, 91, 111, 59, 61, 139, 78, + 62, 80, 142, 87, 88, 89, 90, -33, 84, 45, + 86, 54, 108, 45, 153, 101, 93, 94, 95, 96, + 97, 98, 110, 117, 127, 45, 99, 100, 87, 88, + 89, 90, 128, 112, 87, 88, 89, 90, 90, 133, + 129, 148, 137, 10, 143, 144, 154, 47, 29, 132, + 20, 109, 30, 151, 0, 135, 138 }; static const yytype_int16 yycheck[] = { - 13, 23, 51, 32, 24, 54, 11, 23, 37, 38, - 23, 0, 5, 6, 7, 8, 24, 46, 47, 9, - 3, 14, 3, 6, 29, 6, 9, 33, 9, 7, - 8, 5, 6, 7, 8, 10, 65, 66, 67, 68, - 14, 11, 71, 72, 73, 74, 75, 76, 77, 78, - 33, 34, 33, 5, 6, 7, 8, 86, 5, 6, - 7, 8, 15, 10, 9, 17, 18, 19, 20, 21, - 22, 16, 9, 122, 9, 27, 28, 6, 7, 8, - 24, 25, 9, 24, 26, 29, 108, 31, 32, 33, - 112, 5, 6, 7, 8, 108, 10, 119, 14, 112, - 5, 6, 7, 8, 126, 33, 119, 14, 33, 12, - 16, 15, 9, 126, 10, 15, 10, 16, 10, 14, - 33, 14, 8, 11, 11, 15, 9, 12, 12, 30, - 12, 10, 12, 11, 11, 61, 87, 105, -1, -1, - 128 + 27, 39, 50, 7, 11, 7, 8, 55, 56, 9, + 71, 25, 39, 74, 62, 0, 64, 17, 66, 34, + 24, 9, 3, 30, 25, 6, 7, 75, 9, 6, + 7, 8, 3, 14, 9, 6, 7, 7, 9, 87, + 88, 89, 90, 14, 10, 93, 94, 95, 96, 97, + 98, 99, 100, 34, 35, 16, 34, 7, 10, 7, + 108, 34, 11, 34, 5, 6, 7, 8, 5, 6, + 7, 8, 25, 9, 15, 25, 26, 9, 15, 9, + 30, 129, 32, 33, 34, 5, 6, 7, 8, 5, + 6, 7, 8, 27, 10, 15, 34, 15, 136, 12, + 17, 16, 140, 5, 6, 7, 8, 17, 34, 136, + 34, 9, 17, 140, 152, 10, 18, 19, 20, 21, + 22, 23, 15, 15, 10, 152, 28, 29, 5, 6, + 7, 8, 10, 10, 5, 6, 7, 8, 8, 11, + 16, 31, 11, 5, 12, 12, 12, 29, 23, 109, + 15, 80, 26, 148, -1, 129, 135 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 24, 36, 23, 0, 9, 24, 37, 38, 33, - 10, 15, 39, 11, 40, 38, 24, 25, 29, 31, - 32, 33, 41, 42, 43, 45, 48, 52, 56, 60, - 61, 39, 9, 9, 9, 24, 9, 16, 26, 62, - 41, 33, 46, 14, 14, 3, 6, 9, 33, 49, - 60, 34, 49, 59, 57, 33, 50, 49, 49, 12, - 47, 15, 44, 49, 49, 5, 6, 7, 8, 10, - 59, 17, 18, 19, 20, 21, 22, 27, 28, 10, - 59, 15, 51, 10, 14, 14, 16, 46, 14, 10, - 49, 49, 49, 49, 14, 49, 49, 49, 49, 49, - 49, 49, 49, 53, 10, 33, 49, 44, 11, 58, - 51, 41, 11, 12, 41, 54, 12, 30, 55, 11, - 29, 41, 9, 12, 59, 10, 11, 41, 12, 55 + 0, 25, 37, 38, 39, 41, 43, 7, 24, 0, + 38, 34, 40, 42, 9, 9, 25, 44, 45, 46, + 44, 7, 10, 16, 47, 34, 10, 11, 48, 45, + 48, 7, 25, 26, 30, 32, 33, 34, 49, 50, + 51, 53, 56, 58, 67, 73, 78, 47, 34, 7, + 9, 9, 9, 25, 9, 17, 27, 79, 49, 34, + 54, 15, 17, 3, 6, 7, 9, 14, 34, 57, + 73, 35, 57, 72, 68, 74, 57, 57, 12, 55, + 16, 52, 57, 57, 34, 57, 34, 5, 6, 7, + 8, 10, 72, 18, 19, 20, 21, 22, 23, 28, + 29, 10, 72, 57, 75, 76, 15, 15, 17, 54, + 15, 15, 10, 57, 57, 57, 57, 15, 57, 57, + 57, 57, 57, 57, 57, 57, 59, 10, 10, 16, + 77, 57, 52, 11, 69, 76, 60, 11, 77, 49, + 70, 61, 49, 12, 12, 62, 71, 63, 31, 64, + 11, 58, 65, 49, 12, 66 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 35, 36, 37, 37, 38, 39, 39, 40, 41, - 41, 42, 42, 42, 42, 42, 42, 43, 44, 44, - 45, 45, 47, 46, 46, 48, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 50, 50, 51, 51, 53, - 54, 52, 55, 55, 55, 57, 58, 56, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 60, 61, - 62 -}; +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 6, 0, 2, 2, 4, 0, 4, 2, - 0, 1, 1, 1, 1, 1, 2, 4, 3, 0, - 1, 2, 0, 4, 1, 4, 1, 1, 3, 3, - 3, 3, 2, 1, 3, 2, 0, 3, 0, 0, - 0, 10, 4, 0, 9, 0, 0, 9, 3, 3, - 3, 3, 3, 3, 3, 3, 2, 1, 4, 5, - 3 -}; +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 + YYERROR; \ + } \ +while (YYID (0)) +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -703,46 +816,54 @@ while (0) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - - -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { - FILE *yyo = yyoutput; - YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); # endif - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -750,11 +871,22 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue | Print this symbol on YYOUTPUT. | `--------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); @@ -765,54 +897,66 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif { YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif { - unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; + unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ -} while (0) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -826,7 +970,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -841,6 +985,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -849,8 +994,15 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -866,8 +1018,16 @@ yystrlen (const char *yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -897,27 +1057,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -928,209 +1088,211 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; + int yyn = yypact[yystate]; - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif { YYUSE (yyvaluep); + if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END + switch (yytype) + { + + default: + break; + } } + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ - -/* The lookahead symbol. */ +/* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; + /* Number of syntax errors so far. */ int yynerrs; + /*----------. | yyparse. | `----------*/ +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) +#else +int +yyparse () + +#endif +#endif { - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - + + int yystate; int yyn; int yyresult; - /* Lookahead token as an internal (translated) token number. */ + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1138,22 +1300,54 @@ yyparse (void) YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + goto yysetstate; /*------------------------------------------------------------. @@ -1174,23 +1368,25 @@ yyparse (void) #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - yyss = yyss1; - yyvs = yyvs1; + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1198,22 +1394,23 @@ yyparse (void) # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1221,18 +1418,16 @@ yyparse (void) yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; + YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) - YYACCEPT; - goto yybackup; /*-----------. @@ -1241,20 +1436,20 @@ yyparse (void) yybackup: /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ + look-ahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (); + yychar = YYLEX; } if (yychar <= YYEOF) @@ -1276,27 +1471,29 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yytable_value_is_error (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; yyn = -yyn; goto yyreduce; } + if (yyn == YYFINAL) + YYACCEPT; + /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the lookahead token. */ + /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token. */ - yychar = YYEMPTY; + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1319,7 +1516,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. + `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1332,281 +1529,355 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 78 "analyse_syntaxique.y" /* yacc.c:1646 */ - {} -#line 1339 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + case 5: +#line 89 "analyse_syntaxique.y" + {add_function(&table_fonctions, "Main", RET_INT, array.index); table.depth++;;} break; - case 3: -#line 80 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Sans params\n");} -#line 1345 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + case 6: +#line 89 "analyse_syntaxique.y" + {print_table(&table);remove_symboles(&table); table.depth--;;} break; - case 5: -#line 83 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Parametre : %s\n", (yyvsp[0].id));} -#line 1351 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + case 7: +#line 90 "analyse_syntaxique.y" + {{add_function(&table_fonctions, (yyvsp[(2) - (2)].id), return_type, array.index); table.depth++;};} break; case 8: -#line 90 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans body\n");} -#line 1357 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 90 "analyse_syntaxique.y" + {generate_instruction_0(&array, RET_FUN); print_table(&table);remove_symboles(&table); table.depth--;;} + break; + + case 9: +#line 92 "analyse_syntaxique.y" + {type = TYPE_INT;;} + break; + + case 10: +#line 93 "analyse_syntaxique.y" + {type = TYPE_INT_PTR;;} + break; + + case 11: +#line 95 "analyse_syntaxique.y" + {;} + break; + + case 13: +#line 98 "analyse_syntaxique.y" + {add_symbole_top(&table, (yyvsp[(2) - (2)].id), type, INITIALISED, table.depth);;} + break; + + case 14: +#line 100 "analyse_syntaxique.y" + {type = TYPE_INT;;} + break; + + case 15: +#line 101 "analyse_syntaxique.y" + {type = TYPE_INT_PTR;;} + break; + + case 18: +#line 107 "analyse_syntaxique.y" + {;} + break; + + case 19: +#line 109 "analyse_syntaxique.y" + {(yyval.nombre) = array.index;;} break; case 20: -#line 107 "analyse_syntaxique.y" /* yacc.c:1646 */ - {type = TYPE_INT;} -#line 1363 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 21: -#line 108 "analyse_syntaxique.y" /* yacc.c:1646 */ - {type = TYPE_CONST_INT;} -#line 1369 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 22: -#line 110 "analyse_syntaxique.y" /* yacc.c:1646 */ - {add_symbole_top(&table, (yyvsp[0].id), type, INITIALISED, table.depth);} -#line 1375 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 23: -#line 110 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int varAddr = variable_exists(&table, (yyvsp[-3].id)); generate_instruction_2(&array, COP, (yyvsp[0].nombre), varAddr); free_temp(&table);} -#line 1381 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 24: -#line 111 "analyse_syntaxique.y" /* yacc.c:1646 */ - {add_symbole_top(&table, (yyvsp[0].id), type, NOT_INITIALISED, table.depth);} -#line 1387 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 25: -#line 114 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int varAddr = variable_exists(&table, (yyvsp[-3].id)); generate_instruction_2(&array, COP, (yyvsp[-1].nombre), varAddr); free_temp(&table);} -#line 1393 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 26: -#line 117 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, (yyvsp[0].nombre)); (yyval.nombre) = vt;} -#line 1399 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 27: -#line 119 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[0].id)); generate_instruction_2(&array, COP, varAddr, vt); (yyval.nombre) = vt;} -#line 1405 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 28: -#line 121 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, ADD, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1411 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ - break; - - case 29: -#line 122 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, MUL, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1417 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 110 "analyse_syntaxique.y" + {(yyval.nombre) = array.index;;} break; case 30: -#line 123 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, SOU, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1423 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 124 "analyse_syntaxique.y" + {type = TYPE_INT;;} break; case 31: -#line 124 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, DIV, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1429 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 125 "analyse_syntaxique.y" + {type = TYPE_CONST_INT;;} break; case 32: -#line 125 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Variable negative\n");} -#line 1435 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 126 "analyse_syntaxique.y" + {type = TYPE_INT_PTR;;} break; case 33: -#line 126 "analyse_syntaxique.y" /* yacc.c:1646 */ - {(yyval.nombre) = 1234;} -#line 1441 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 128 "analyse_syntaxique.y" + {add_symbole_top(&table, (yyvsp[(1) - (1)].id), type, INITIALISED, table.depth);;} break; case 34: -#line 127 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Parenthèse\n"); (yyval.nombre) = (yyvsp[-1].nombre); } -#line 1447 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 128 "analyse_syntaxique.y" + {int varAddr = variable_exists(&table, (yyvsp[(1) - (4)].id)); generate_instruction_2(&array, COP, varAddr, (yyvsp[(4) - (4)].nombre)); free_temp(&table);;} + break; + + case 35: +#line 129 "analyse_syntaxique.y" + {add_symbole_top(&table, (yyvsp[(1) - (1)].id), type, NOT_INITIALISED, table.depth);;} + break; + + case 36: +#line 132 "analyse_syntaxique.y" + {int varAddr = variable_exists(&table, (yyvsp[(1) - (4)].id)); generate_instruction_2(&array, COP, varAddr, (yyvsp[(3) - (4)].nombre)); free_temp(&table);;} + break; + + case 37: +#line 133 "analyse_syntaxique.y" + {int varAddr = variable_exists(&table, (yyvsp[(2) - (5)].id)); generate_instruction_2(&array, COP_STR, varAddr, (yyvsp[(4) - (5)].nombre)); free_temp(&table);;} + break; + + case 38: +#line 136 "analyse_syntaxique.y" + {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, (yyvsp[(1) - (1)].nombre)); (yyval.nombre) = vt;;} break; case 39: -#line 136 "analyse_syntaxique.y" /* yacc.c:1646 */ - { - //gen_jmpf(&table, &array, $3, -1); - generate_instruction_2(&array, JMF, (yyvsp[-1].nombre), -1); - free_temp(&table); - (yyvsp[-3].nombre) = array.index; -} -#line 1458 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 137 "analyse_syntaxique.y" + {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[(1) - (1)].id)); generate_instruction_2(&array, COP, vt, varAddr); (yyval.nombre) = vt;;} break; case 40: -#line 143 "analyse_syntaxique.y" /* yacc.c:1646 */ - { - int adr_jmp = array.index; - update_jmf(&array, (yyvsp[-7].nombre), adr_jmp); -} -#line 1467 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 138 "analyse_syntaxique.y" + {generate_instruction_3(&array, ADD, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(1) - (3)].nombre);;} break; case 41: -#line 147 "analyse_syntaxique.y" /* yacc.c:1646 */ - {} -#line 1473 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 139 "analyse_syntaxique.y" + {generate_instruction_3(&array, MUL, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(1) - (3)].nombre);;} break; case 42: -#line 149 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("else\n");} -#line 1479 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 140 "analyse_syntaxique.y" + {generate_instruction_3(&array, SOU, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(1) - (3)].nombre);;} + break; + + case 43: +#line 141 "analyse_syntaxique.y" + {generate_instruction_3(&array, DIV, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(1) - (3)].nombre);;} break; case 44: -#line 151 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("elsif\n");} -#line 1485 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 142 "analyse_syntaxique.y" + {printf("Variable negative\n");;} break; case 45: -#line 153 "analyse_syntaxique.y" /* yacc.c:1646 */ +#line 143 "analyse_syntaxique.y" { - (yyvsp[0].nombre) = array.index ; -} -#line 1493 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + int vt = new_temp(&table); + generate_instruction_2(&array, COP, vt, (yyvsp[(1) - (1)].nombre)); + remove_symboles(&table); + table.depth--; + (yyval.nombre) = vt;;} break; case 46: -#line 155 "analyse_syntaxique.y" /* yacc.c:1646 */ - { - //gen_jmpf(&table, &array, $4, -1); - generate_instruction_2(&array, JMF, (yyvsp[-1].nombre), -1); - free_temp(&table); - (yyvsp[-4].nombre) = array.index; -} -#line 1504 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 149 "analyse_syntaxique.y" + {printf("Parenthèse\n"); (yyval.nombre) = (yyvsp[(2) - (3)].nombre); ;} break; case 47: -#line 161 "analyse_syntaxique.y" /* yacc.c:1646 */ - { - int adr_jmp = array.index; - update_jmf(&array, (yyvsp[-8].nombre), adr_jmp); - //gen_jmpf(&table, &array, $1, $2); - generate_instruction_1(&array, JMP, (yyvsp[-7].nombre)); -} -#line 1515 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 150 "analyse_syntaxique.y" + {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[(2) - (2)].id)); generate_instruction_2(&array, LEA, vt, varAddr); (yyval.nombre) = vt;;} break; case 48: -#line 169 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, EQ, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1521 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 151 "analyse_syntaxique.y" + {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[(2) - (2)].id)); generate_instruction_2(&array, COP, vt, varAddr); generate_instruction_2(&array, COP_LD, vt, vt); (yyval.nombre) = vt;;} break; case 49: -#line 170 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, NEQ, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1527 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 154 "analyse_syntaxique.y" + { + //gen_jmpf(&table, &array, $3, -1); + generate_instruction_2(&array, JMF, (yyvsp[(3) - (4)].nombre), -1); + free_temp(&table); + (yyvsp[(1) - (4)].nombre) = array.index; +;} break; case 50: -#line 171 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, LT, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1533 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 160 "analyse_syntaxique.y" + {table.depth++;;} break; case 51: -#line 172 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, GT, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1539 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 160 "analyse_syntaxique.y" + {generate_instruction_1(&array, JMP, -1);} break; case 52: -#line 173 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, LTE, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1545 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 160 "analyse_syntaxique.y" + {remove_symboles(&table); table.depth--;;} break; case 53: -#line 174 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, GTE, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1551 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 161 "analyse_syntaxique.y" + { + int adr_jmp = array.index; + update_jmf(&array, (yyvsp[(1) - (11)].nombre), adr_jmp); +;} break; case 54: -#line 175 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, AND, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1557 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 165 "analyse_syntaxique.y" + {printf("updating jump\n"); update_jmp(&array, (yyvsp[(8) - (13)].nombre), (yyvsp[(13) - (13)].nombre));;} break; case 55: -#line 176 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_3(&array, OR, (yyvsp[-2].nombre), (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1563 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 167 "analyse_syntaxique.y" + {table.depth++;;} break; case 56: -#line 177 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_2(&array, NOT, (yyvsp[0].nombre), (yyvsp[0].nombre)); (yyval.nombre) = (yyvsp[0].nombre);} -#line 1569 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 167 "analyse_syntaxique.y" + {remove_symboles(&table); table.depth--;;} break; case 57: -#line 178 "analyse_syntaxique.y" /* yacc.c:1646 */ - {(yyval.nombre) = (yyvsp[0].nombre); } -#line 1575 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 167 "analyse_syntaxique.y" + {(yyval.nombre) = array.index;;} break; case 58: -#line 183 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans invocation\n");} -#line 1581 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 168 "analyse_syntaxique.y" + {(yyval.nombre) = array.index;;} break; case 59: -#line 186 "analyse_syntaxique.y" /* yacc.c:1646 */ - {generate_instruction_1(&array, PRI, (yyvsp[-2].nombre)); free_temp(&table);} -#line 1587 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 169 "analyse_syntaxique.y" + {(yyval.nombre) = array.index;;} break; case 60: -#line 189 "analyse_syntaxique.y" /* yacc.c:1646 */ - {(yyval.nombre) = generate_instruction_1(&array, RET, (yyvsp[-1].nombre)); free_temp(&table);} -#line 1593 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 171 "analyse_syntaxique.y" + { + (yyvsp[(2) - (2)].nombre) = array.index ; +;} + break; + + case 61: +#line 173 "analyse_syntaxique.y" + { + //gen_jmpf(&table, &array, $4, -1); + generate_instruction_2(&array, JMF, (yyvsp[(4) - (5)].nombre), -1); + free_temp(&table); + (yyvsp[(1) - (5)].nombre) = array.index; +;} + break; + + case 62: +#line 179 "analyse_syntaxique.y" + {table.depth++;;} + break; + + case 63: +#line 179 "analyse_syntaxique.y" + {remove_symboles(&table); table.depth--;;} + break; + + case 64: +#line 179 "analyse_syntaxique.y" + { + int adr_jmp = array.index; + update_jmf(&array, (yyvsp[(1) - (11)].nombre), adr_jmp); + //gen_jmpf(&table, &array, $1, $2); + generate_instruction_1(&array, JMP, (yyvsp[(2) - (11)].nombre)); +;} + break; + + case 65: +#line 186 "analyse_syntaxique.y" + {generate_instruction_3(&array, EQ, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 66: +#line 187 "analyse_syntaxique.y" + {generate_instruction_3(&array, NEQ, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 67: +#line 188 "analyse_syntaxique.y" + {generate_instruction_3(&array, LT, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 68: +#line 189 "analyse_syntaxique.y" + {generate_instruction_3(&array, GT, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 69: +#line 190 "analyse_syntaxique.y" + {generate_instruction_3(&array, LTE, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 70: +#line 191 "analyse_syntaxique.y" + {generate_instruction_3(&array, GTE, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 71: +#line 192 "analyse_syntaxique.y" + {generate_instruction_3(&array, AND, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 72: +#line 193 "analyse_syntaxique.y" + {generate_instruction_3(&array, OR, (yyvsp[(1) - (3)].nombre), (yyvsp[(1) - (3)].nombre), (yyvsp[(3) - (3)].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[(3) - (3)].nombre);;} + break; + + case 73: +#line 194 "analyse_syntaxique.y" + {generate_instruction_2(&array, NOT, (yyvsp[(2) - (2)].nombre), (yyvsp[(2) - (2)].nombre)); (yyval.nombre) = (yyvsp[(2) - (2)].nombre);;} + break; + + case 74: +#line 195 "analyse_syntaxique.y" + {(yyval.nombre) = (yyvsp[(1) - (1)].nombre); ;} + break; + + case 75: +#line 197 "analyse_syntaxique.y" + {table.depth++; prepare_function_call(&table); return_value = (table.indexAvailableTop - 1);;} + break; + + case 76: +#line 198 "analyse_syntaxique.y" + {int function_index = function_exists(&table_fonctions, (yyvsp[(1) - (5)].id)); + int jmp_addr = (table_fonctions.array[function_index]).start_addr; + generate_instruction_2(&array, CALL, jmp_addr, (array.index + 1)); + (yyval.nombre) = return_value; + ;} + break; + + case 79: +#line 206 "analyse_syntaxique.y" + {int arg_addr = prepare_argument_push(&table); generate_instruction_2(&array, COP, arg_addr, (yyvsp[(1) - (1)].nombre)); free_temp(&table);} + break; + + case 82: +#line 210 "analyse_syntaxique.y" + {generate_instruction_1(&array, PRI, (yyvsp[(3) - (5)].nombre)); free_temp(&table);;} + break; + + case 83: +#line 212 "analyse_syntaxique.y" + {(yyval.nombre) = generate_instruction_1(&array, RET, (yyvsp[(2) - (3)].nombre)); free_temp(&table);;} break; -#line 1597 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +/* Line 1267 of yacc.c. */ +#line 1879 "analyse_syntaxique.tab.c" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -1615,7 +1886,8 @@ yyreduce: *++yyvsp = yyval; - /* Now 'shift' the result of the reduction. Determine what state + + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1630,14 +1902,10 @@ yyreduce: goto yynewstate; -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -1645,36 +1913,37 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } } -# undef YYSYNTAX_ERROR #endif } @@ -1682,24 +1951,24 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -1715,7 +1984,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -1728,37 +1997,38 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + if (yyn == YYFINAL) + YYACCEPT; + *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -1782,7 +2052,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE +#ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1793,22 +2063,17 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule whose action triggered + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1819,19 +2084,27 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 191 "analyse_syntaxique.y" /* yacc.c:1906 */ + + +#line 214 "analyse_syntaxique.y" #include void main(void){ //TODO: rajouter gestion des erreurs initialise_table(&table); + initialise_function_table(&table_fonctions); initialise_asm(&array); yyparse(); print_table(&table); + printf("\n"); + print_fonction_table(&table_fonctions); + //remove_symboles(&table, 0); //print_table(&table); exportInstructions(&array); } + diff --git a/analyse_syntaxique.tab.h b/analyse_syntaxique.tab.h index dd14b4a..5f12a7d 100644 --- a/analyse_syntaxique.tab.h +++ b/analyse_syntaxique.tab.h @@ -1,13 +1,14 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Bison interface for Yacc-like parsers in C +/* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. - This program is free software: you can redistribute it and/or modify + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 2, or (at your option) + any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -30,77 +33,99 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED -# define YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - tENTIER = 258, - tENTIEREXP = 259, - tADD = 260, - tSUB = 261, - tMUL = 262, - tDIV = 263, - tPO = 264, - tPF = 265, - tAO = 266, - tAF = 267, - tERROR = 268, - tPV = 269, - tVIRGULE = 270, - tAFFECTATION = 271, - tEGAL = 272, - tDIFF = 273, - tLT = 274, - tGT = 275, - tGTE = 276, - tLTE = 277, - tMAIN = 278, - tINT = 279, - tPRINT = 280, - tRETURN = 281, - tOR = 282, - tAND = 283, - tIF = 284, - tELSE = 285, - tWHILE = 286, - tCONST = 287, - tVAR = 288, - tNOT = 289 - }; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + tENTIER = 258, + tENTIEREXP = 259, + tADD = 260, + tSUB = 261, + tMUL = 262, + tDIV = 263, + tPO = 264, + tPF = 265, + tAO = 266, + tAF = 267, + tERROR = 268, + tAPPERSAND = 269, + tPV = 270, + tVIRGULE = 271, + tAFFECTATION = 272, + tEGAL = 273, + tDIFF = 274, + tLT = 275, + tGT = 276, + tGTE = 277, + tLTE = 278, + tMAIN = 279, + tINT = 280, + tPRINT = 281, + tRETURN = 282, + tOR = 283, + tAND = 284, + tIF = 285, + tELSE = 286, + tWHILE = 287, + tCONST = 288, + tVAR = 289, + tNOT = 290 + }; #endif +/* Tokens. */ +#define tENTIER 258 +#define tENTIEREXP 259 +#define tADD 260 +#define tSUB 261 +#define tMUL 262 +#define tDIV 263 +#define tPO 264 +#define tPF 265 +#define tAO 266 +#define tAF 267 +#define tERROR 268 +#define tAPPERSAND 269 +#define tPV 270 +#define tVIRGULE 271 +#define tAFFECTATION 272 +#define tEGAL 273 +#define tDIFF 274 +#define tLT 275 +#define tGT 276 +#define tGTE 277 +#define tLTE 278 +#define tMAIN 279 +#define tINT 280 +#define tPRINT 281 +#define tRETURN 282 +#define tOR 283 +#define tAND 284 +#define tIF 285 +#define tELSE 286 +#define tWHILE 287 +#define tCONST 288 +#define tVAR 289 +#define tNOT 290 + + + -/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE +typedef union YYSTYPE +#line 1 "analyse_syntaxique.y" { -#line 1 "analyse_syntaxique.y" /* yacc.c:1909 */ - int nombre; char id[30]; - -#line 94 "analyse_syntaxique.tab.h" /* yacc.c:1909 */ -}; - -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 +} +/* Line 1529 of yacc.c. */ +#line 124 "analyse_syntaxique.tab.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif - extern YYSTYPE yylval; -int yyparse (void); - -#endif /* !YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED */ diff --git a/analyse_syntaxique.y b/analyse_syntaxique.y index 4473a35..71f4f67 100644 --- a/analyse_syntaxique.y +++ b/analyse_syntaxique.y @@ -6,13 +6,17 @@ char id[30]; %{ #include #include "table_symboles.h" +#include "table_fonctions.h" #include "gen_assembleur.h" enum Initialised_Variable init; enum Symbole_Type type; +enum Return_Type return_type; Table_Symboles table; +Table_Fonctions table_fonctions; instructions_array array; int whileCondition; +int return_value; %} @@ -20,10 +24,9 @@ int whileCondition; %token tENTIEREXP %type E -%type Return +%type Return Instructions %type Cond -%type While - +%type While Else Invocation %token tADD @@ -38,6 +41,7 @@ int whileCondition; %token tERROR +%token tAPPERSAND %token tPV %token tVIRGULE %token tAFFECTATION @@ -69,28 +73,41 @@ int whileCondition; %% -//C : Fonctions Main ; +/*C : Fonctions Main ; -//Fonctions : Fonction Fonctions | ; -//Fonction : tINT tVAR tPO Params tPF Body; +Fonctions : ; +Fonctions : Fonction Fonctions ; + +Fonction : tINT tVAR tPO Params tPF Body;*/ + +C : Fonctions; + +Fonctions: Main; +Fonctions: Fonction Fonctions; -Main : tINT tMAIN tPO Params tPF Body {}; +Main : tINT tMAIN {add_function(&table_fonctions, "Main", RET_INT, array.index); table.depth++;} tPO Params tPF Body {print_table(&table);remove_symboles(&table); table.depth--;}; +Fonction : Function_type tVAR {{add_function(&table_fonctions, $2, return_type, array.index); table.depth++;}} tPO Params tPF Body {generate_instruction_0(&array, RET_FUN); print_table(&table);remove_symboles(&table); table.depth--;}; -Params : {printf("Sans params\n");} ; +Function_type: tINT {type = TYPE_INT;} ; +Function_type: tINT tMUL {type = TYPE_INT_PTR;}; + +Params : {} ; Params : Param SuiteParams ; -Param : tINT tVAR {printf("Parametre : %s\n", $2);} ; +Param : Param_type tVAR {add_symbole_top(&table, $2, type, INITIALISED, table.depth);} ; +Param_type: tINT {type = TYPE_INT;} ; +Param_type: tINT tMUL {type = TYPE_INT_PTR;}; -SuiteParams : tVIRGULE Param SuiteParams tPV ; +SuiteParams : tVIRGULE Param SuiteParams ; SuiteParams : ; -Body : tAO Instructions Return tAF {printf("Dans body\n");} ; +Body : tAO Instructions Return tAF {} ; -Instructions : Instruction Instructions ; -Instructions : ; +Instructions : Instruction Instructions {$$ = array.index;}; +Instructions : {$$ = array.index;}; Instruction : Aff ; Instruction : If ; @@ -104,51 +121,52 @@ Decl : Type Valeur SuiteDecl tPV ; SuiteDecl: tVIRGULE Valeur SuiteDecl ; SuiteDecl: ; -Type : tINT {type = TYPE_INT;} ; +Type : tINT {type = TYPE_INT;} ; Type : tCONST tINT {type = TYPE_CONST_INT;} ; +Type : tINT tMUL {type = TYPE_INT_PTR;}; -Valeur : tVAR {add_symbole_top(&table, $1, type, INITIALISED, table.depth);} tAFFECTATION E {int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, $4, varAddr); free_temp(&table);}; +Valeur : tVAR {add_symbole_top(&table, $1, type, INITIALISED, table.depth);} tAFFECTATION E {int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, varAddr, $4); free_temp(&table);}; Valeur : tVAR {add_symbole_top(&table, $1, type, NOT_INITIALISED, table.depth);}; -Aff : tVAR tAFFECTATION E tPV {int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, $3, varAddr); free_temp(&table);}; +Aff : tVAR tAFFECTATION E tPV {int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, varAddr, $3); free_temp(&table);}; +Aff : tMUL tVAR tAFFECTATION E tPV {int varAddr = variable_exists(&table, $2); generate_instruction_2(&array, COP_STR, varAddr, $4); free_temp(&table);}; + -//E : tENTIER {int vt = gen_entier(&table, &array, $1); $$ = vt;}; E : tENTIER {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, $1); $$ = vt;}; -//E : tVAR {int vt = gen_var(&table, &array, $1); $$ = vt;}; -E : tVAR {int vt = new_temp(&table); int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, varAddr, vt); $$ = vt;}; -//E : E tADD E {gen_arithmetique(&array, ADD, $1, $3); free_temp(&table); $$ = $1;} ; +E : tVAR {int vt = new_temp(&table); int varAddr = variable_exists(&table, $1); generate_instruction_2(&array, COP, vt, varAddr); $$ = vt;}; E : E tADD E {generate_instruction_3(&array, ADD, $1, $1, $3); free_temp(&table); $$ = $1;} ; E : E tMUL E {generate_instruction_3(&array, MUL, $1, $1, $3); free_temp(&table); $$ = $1;} ; E : E tSUB E {generate_instruction_3(&array, SOU, $1, $1, $3); free_temp(&table); $$ = $1;} ; E : E tDIV E {generate_instruction_3(&array, DIV, $1, $1, $3); free_temp(&table); $$ = $1;} ; E : tSUB E {printf("Variable negative\n");} ; -E : Invocation {$$ = 1234;}; +E : Invocation { + int vt = new_temp(&table); + generate_instruction_2(&array, COP, vt, $1); + remove_symboles(&table); + table.depth--; + $$ = vt;}; E : tPO E tPF {printf("Parenthèse\n"); $$ = $2; } ; +E : tAPPERSAND tVAR {int vt = new_temp(&table); int varAddr = variable_exists(&table, $2); generate_instruction_2(&array, LEA, vt, varAddr); $$ = vt;}; +E : tMUL tVAR {int vt = new_temp(&table); int varAddr = variable_exists(&table, $2); generate_instruction_2(&array, COP, vt, varAddr); generate_instruction_2(&array, COP_LD, vt, vt); $$ = vt;}; -Args : tVAR SuiteArgs ; -Args : ; - -SuiteArgs : tVIRGULE tVAR SuiteArgs ; -SuiteArgs : ; - If : tIF tPO Cond tPF { //gen_jmpf(&table, &array, $3, -1); generate_instruction_2(&array, JMF, $3, -1); free_temp(&table); $1 = array.index; } -tAO Instructions tAF +tAO {table.depth++;} Instructions {generate_instruction_1(&array, JMP, -1)} tAF {remove_symboles(&table); table.depth--;} { int adr_jmp = array.index; update_jmf(&array, $1, adr_jmp); } -Else {}; +Else {printf("updating jump\n"); update_jmp(&array, $8, $13);}; -Else : tELSE tAO Instructions tAF {printf("else\n");} ; -Else : ; -Else : tELSE tIF tPO Cond tPF tAO Instructions tAF Else {printf("elsif\n");} ; +Else : tELSE tAO {table.depth++;} Instructions tAF {remove_symboles(&table); table.depth--;} {$$ = array.index;} ; +Else : {$$ = array.index;}; +Else : tELSE If {$$ = array.index;} ; While : tWHILE tPO { $2 = array.index ; @@ -158,14 +176,13 @@ While : tWHILE tPO { free_temp(&table); $1 = array.index; } -tAO Instructions tAF { +tAO {table.depth++;} Instructions tAF {remove_symboles(&table); table.depth--;} { int adr_jmp = array.index; update_jmf(&array, $1, adr_jmp); //gen_jmpf(&table, &array, $1, $2); generate_instruction_1(&array, JMP, $2); }; -//Cond : E tEGAL E {int vt = gen_condition(&table, &array, EQ, $1, $3); $$ = vt;} ; Cond : E tEGAL E {generate_instruction_3(&array, EQ, $1, $1, $3); free_temp(&table); $$ = $3;}; Cond : E tDIFF E {generate_instruction_3(&array, NEQ, $1, $1, $3); free_temp(&table); $$ = $3;} ; Cond : E tLT E {generate_instruction_3(&array, LT, $1, $1, $3); free_temp(&table); $$ = $3;} ; @@ -177,15 +194,21 @@ Cond : E tOR E {generate_instruction_3(&array, OR, $1, $1, $3); free_temp(&table Cond : tNOT Cond {generate_instruction_2(&array, NOT, $2, $2); $$ = $2;} ; Cond : E {$$ = $1; }; +Invocation : tVAR tPO {table.depth++; prepare_function_call(&table); return_value = (table.indexAvailableTop - 1);} Args tPF + {int function_index = function_exists(&table_fonctions, $1); + int jmp_addr = (table_fonctions.array[function_index]).start_addr; + generate_instruction_2(&array, CALL, jmp_addr, (array.index + 1)); + $$ = return_value; + }; +Args : Arg SuiteArgs ; +Args : +Arg : E {int arg_addr = prepare_argument_push(&table); generate_instruction_2(&array, COP, arg_addr, $1); free_temp(&table)}; +SuiteArgs : tVIRGULE Arg SuiteArgs ; +SuiteArgs : ; - -Invocation : tVAR tPO Args tPF {printf("Dans invocation\n");}; - -//Print : tPRINT tPO E tPF tPV {gen_print(&table, &array, $3);}; Print : tPRINT tPO E tPF tPV {generate_instruction_1(&array, PRI, $3); free_temp(&table);}; -//Return : tRETURN E tPV {$$ = gen_return(&table, &array, $2);}; Return : tRETURN E tPV {$$ = generate_instruction_1(&array, RET, $2); free_temp(&table);}; %% @@ -193,9 +216,13 @@ Return : tRETURN E tPV {$$ = generate_instruction_1(&array, RET, $2); free_temp( void main(void){ //TODO: rajouter gestion des erreurs initialise_table(&table); + initialise_function_table(&table_fonctions); initialise_asm(&array); yyparse(); print_table(&table); + printf("\n"); + print_fonction_table(&table_fonctions); + //remove_symboles(&table, 0); //print_table(&table); exportInstructions(&array); diff --git a/gen_assembleur.c b/gen_assembleur.c index de1e83e..7d32bff 100644 --- a/gen_assembleur.c +++ b/gen_assembleur.c @@ -33,7 +33,7 @@ char * operationName(enum operation op){ case JMF: return "JPF"; case JMP: - return "JPM"; + return "JMP"; case AND: return "AND"; case OR: @@ -42,6 +42,16 @@ char * operationName(enum operation op){ return "NOT"; case PRI: return "PRI"; + case LEA: + return "LEA"; + case COP_LD: + return "COP_LD"; + case COP_STR: + return "COP_STR"; + case RET_FUN: + return "RET_FUN"; + case CALL: + return "CALL"; default: break; } @@ -71,6 +81,22 @@ int new_temp(Table_Symboles * table){ return ret_addr; } +int generate_instruction_0(instructions_array * array, enum operation op){ + instruction instru; + char * opName = operationName(op); + + instru.operation = op; + + printf("%d\t %s\n", array->index, opName); + + if (add_instruction(array, &instru) != 0){ + //TODO: Error handling + exit(1); + } + + return 0; +} + int generate_instruction_1(instructions_array * array, enum operation op, int arg1){ instruction instru; char * opName = operationName(op); @@ -130,6 +156,11 @@ void update_jmf(instructions_array * array, int instru_index, int adr_jmp){ printf("%d\t JMP %d %d\n", (instru_index - 1), array->array[instru_index].reg1, array->array[instru_index].reg2); } +void update_jmp(instructions_array * array, int instru_index, int adr_jmp){ + array->array[instru_index].reg1 = adr_jmp; + printf("%d\t JMP %d\n", (instru_index - 1), array->array[instru_index].reg1); +} + void exportInstructions(instructions_array * array){ FILE *file; file = fopen("instructions.txt", "w"); @@ -140,6 +171,10 @@ void exportInstructions(instructions_array * array){ instru = array->array[i]; op = instru.operation; switch (op) { + //0 parameters + case RET_FUN: + fprintf(file, "%d\t %s\n", i, operationName(op)); + break; //1 parameter case JMP: case PRI: @@ -151,8 +186,16 @@ void exportInstructions(instructions_array * array){ case NOT: case AFC: case COP: + case LEA: + case CALL: fprintf(file, "%d\t %s %d %d\n", i, operationName(op), instru.reg1, instru.reg2); break; + case COP_LD: + fprintf(file, "%d\t %s %d [%d]\n", i, operationName(op), instru.reg1, instru.reg2); + break; + case COP_STR: + fprintf(file, "%d\t %s [%d] %d\n", i, operationName(op), instru.reg1, instru.reg2); + break; //3 parameters case ADD: case SOU: diff --git a/gen_assembleur.h b/gen_assembleur.h index 7a1172f..8028c89 100644 --- a/gen_assembleur.h +++ b/gen_assembleur.h @@ -5,7 +5,8 @@ #include "table_symboles.h" -enum operation{ADD, SOU, MUL, DIV, COP, AFC, RET, JMF, JMP, EQ, NEQ, LT, GT, LTE, GTE, AND, OR, NOT, PRI}; +enum operation{ADD, SOU, MUL, DIV, COP, AFC, RET, JMF, JMP, EQ, NEQ, LT, GT, LTE, + GTE, AND, OR, NOT, PRI, LEA, COP_LD, COP_STR, CALL, RET_FUN}; typedef struct instruction{ enum operation operation; @@ -49,6 +50,14 @@ int new_temp(Table_Symboles * table); */ int add_instruction(instructions_array * array, instruction * intru); +/** + * Generates intruction with no parameter + * @param array + * @param op + * @return + */ +int generate_instruction_0(instructions_array * array, enum operation op); + /** * Generates intruction with one parameter * @param array @@ -87,6 +96,7 @@ int generate_instruction_3(instructions_array * array, enum operation op, int ar */ void update_jmf(instructions_array * array, int instru_index, int adr_jmp); +void update_jmp(instructions_array * array, int instru_index, int adr_jmp); diff --git a/instructions.txt b/instructions.txt index 2716664..ce1db7c 100644 --- a/instructions.txt +++ b/instructions.txt @@ -1,22 +1,11 @@ -0 AFC 49 1 -1 COP 49 0 -2 AFC 49 2 -3 COP 49 1 +0 AFC 49 2 +1 COP 0 49 +2 LEA 49 0 +3 COP 1 49 4 AFC 49 2 -5 AFC 48 3 -6 ADD 49 49 48 -7 COP 49 1 -8 COP 1 49 -9 NOT 49 49 -10 JPF 49 15 -11 AFC 49 1 -12 COP 49 1 -13 AFC 49 4 -14 COP 49 2 -15 AFC 49 4 -16 AFC 48 2 -17 COP 48 0 -18 COP 1 48 -19 PRI 48 -20 AFC 48 5 -21 RET 48 +5 COP_STR [1] 49 +6 COP 49 1 +7 COP_LD 49 [49] +8 COP 2 49 +9 AFC 49 0 +10 RET 49 diff --git a/lex.yy.c b/lex.yy.c index e880035..1beb0b1 100644 --- a/lex.yy.c +++ b/lex.yy.c @@ -7,8 +7,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -46,6 +46,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -53,6 +54,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -83,61 +85,63 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ -/* begin standard C++ headers. */ +#ifdef __cplusplus -/* TODO: this is always defined, so inline it */ +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST #define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) #else -#define yynoreturn +#define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * + /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START + /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) +#define YY_NEW_FILE yyrestart(yyin ) + #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -154,16 +158,15 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern int yyleng; +extern yy_size_t yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@ -178,6 +181,7 @@ extern FILE *yyin, *yyout; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) + #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -192,12 +196,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - int yy_buf_size; + yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -220,7 +224,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -248,7 +252,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -259,6 +263,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) + /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -266,11 +271,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -279,80 +284,84 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart ( FILE *input_file ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); -void yy_delete_buffer ( YY_BUFFER_STATE b ); -void yy_flush_buffer ( YY_BUFFER_STATE b ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state ( void ); +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); -static void yyensure_buffer_stack ( void ); -static void yy_load_buffer_state ( void ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -void *yyalloc ( yy_size_t ); -void *yyrealloc ( void *, yy_size_t ); -void yyfree ( void * ); +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); #define yy_new_buffer yy_create_buffer + #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } + #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } + #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ -typedef flex_uint8_t YY_CHAR; -FILE *yyin = NULL, *yyout = NULL; +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; + int yylineno = 1; extern char *yytext; -#ifdef yytext_ptr -#undef yytext_ptr -#endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state ( void ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); -static int yy_get_next_buffer ( void ); -static void yynoreturn yy_fatal_error ( const char* msg ); +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 34 -#define YY_END_OF_BUFFER 35 + +#define YY_NUM_RULES 35 +#define YY_END_OF_BUFFER 36 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -360,18 +369,18 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[70] = +static yyconst flex_int16_t yy_accept[70] = { 0, - 0, 0, 35, 34, 10, 11, 20, 34, 5, 6, - 3, 1, 12, 2, 4, 31, 9, 16, 13, 17, - 33, 33, 33, 33, 33, 33, 33, 33, 7, 34, - 8, 15, 26, 31, 33, 33, 18, 14, 19, 33, - 33, 27, 33, 33, 33, 33, 33, 25, 32, 33, - 33, 22, 33, 33, 33, 33, 33, 28, 21, 33, - 33, 33, 30, 33, 33, 29, 23, 24, 0 + 0, 0, 36, 35, 10, 11, 20, 30, 5, 6, + 3, 1, 12, 2, 4, 32, 9, 16, 13, 17, + 34, 34, 34, 34, 34, 34, 34, 34, 7, 35, + 8, 15, 26, 32, 34, 34, 18, 14, 19, 34, + 34, 27, 34, 34, 34, 34, 34, 25, 33, 34, + 34, 22, 34, 34, 34, 34, 34, 28, 21, 34, + 34, 34, 31, 34, 34, 29, 23, 24, 0 } ; -static const YY_CHAR yy_ec[256] = +static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -403,7 +412,7 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[39] = +static yyconst flex_int32_t yy_meta[39] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, @@ -411,7 +420,7 @@ static const YY_CHAR yy_meta[39] = 2, 2, 2, 2, 2, 1, 1, 1 } ; -static const flex_int16_t yy_base[71] = +static yyconst flex_int16_t yy_base[71] = { 0, 0, 0, 79, 80, 80, 80, 61, 71, 80, 80, 80, 80, 80, 80, 80, 25, 80, 59, 58, 57, @@ -422,7 +431,7 @@ static const flex_int16_t yy_base[71] = 17, 24, 0, 21, 15, 0, 0, 0, 80, 40 } ; -static const flex_int16_t yy_def[71] = +static yyconst flex_int16_t yy_def[71] = { 0, 69, 1, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 70, 69, 69, 69, 69, @@ -433,7 +442,7 @@ static const flex_int16_t yy_def[71] = 70, 70, 70, 70, 70, 70, 70, 70, 0, 69 } ; -static const flex_int16_t yy_nxt[119] = +static yyconst flex_int16_t yy_nxt[119] = { 0, 4, 5, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, @@ -450,7 +459,7 @@ static const flex_int16_t yy_nxt[119] = 69, 69, 69, 69, 69, 69, 69, 69 } ; -static const flex_int16_t yy_chk[119] = +static yyconst flex_int16_t yy_chk[119] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -488,8 +497,7 @@ int yywrap(void){ return 1; } -#line 492 "lex.yy.c" -#line 493 "lex.yy.c" +#line 501 "lex.yy.c" #define INITIAL 0 @@ -505,36 +513,36 @@ int yywrap(void){ #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals ( void ); +static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy ( void ); +int yylex_destroy (void ); -int yyget_debug ( void ); +int yyget_debug (void ); -void yyset_debug ( int debug_flag ); +void yyset_debug (int debug_flag ); -YY_EXTRA_TYPE yyget_extra ( void ); +YY_EXTRA_TYPE yyget_extra (void ); -void yyset_extra ( YY_EXTRA_TYPE user_defined ); +void yyset_extra (YY_EXTRA_TYPE user_defined ); -FILE *yyget_in ( void ); +FILE *yyget_in (void ); -void yyset_in ( FILE * _in_str ); +void yyset_in (FILE * in_str ); -FILE *yyget_out ( void ); +FILE *yyget_out (void ); -void yyset_out ( FILE * _out_str ); +void yyset_out (FILE * out_str ); - int yyget_leng ( void ); +yy_size_t yyget_leng (void ); -char *yyget_text ( void ); +char *yyget_text (void ); -int yyget_lineno ( void ); +int yyget_lineno (void ); -void yyset_lineno ( int _line_number ); +void yyset_lineno (int line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -542,43 +550,35 @@ void yyset_lineno ( int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap ( void ); +extern "C" int yywrap (void ); #else -extern int yywrap ( void ); +extern int yywrap (void ); #endif #endif -#ifndef YY_NO_UNPUT + static void yyunput (int c,char *buf_ptr ); - static void yyunput ( int c, char *buf_ptr ); - -#endif - #ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int ); +static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * ); +static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT + #ifdef __cplusplus -static int yyinput ( void ); +static int yyinput (void ); #else -static int input ( void ); +static int input (void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -586,7 +586,7 @@ static int input ( void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -597,7 +597,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -610,7 +610,7 @@ static int input ( void ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -665,7 +665,7 @@ extern int yylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; +#define YY_BREAK break; #endif #define YY_RULE_SETUP \ @@ -675,10 +675,15 @@ extern int yylex (void); */ YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; +#line 54 "analyse_lexicale.lex" + + +#line 686 "lex.yy.c" + if ( !(yy_init) ) { (yy_init) = 1; @@ -699,19 +704,13 @@ YY_DECL if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); + yy_create_buffer(yyin,YY_BUF_SIZE ); } - yy_load_buffer_state( ); + yy_load_buffer_state( ); } - { -#line 53 "analyse_lexicale.lex" - - -#line 713 "lex.yy.c" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -727,7 +726,7 @@ YY_DECL yy_match: do { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -737,9 +736,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 80 ); @@ -768,176 +767,181 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 55 "analyse_lexicale.lex" +#line 56 "analyse_lexicale.lex" {return tADD ;} YY_BREAK case 2: YY_RULE_SETUP -#line 56 "analyse_lexicale.lex" +#line 57 "analyse_lexicale.lex" {return tSUB ;} YY_BREAK case 3: YY_RULE_SETUP -#line 57 "analyse_lexicale.lex" +#line 58 "analyse_lexicale.lex" {return tMUL ;} YY_BREAK case 4: YY_RULE_SETUP -#line 58 "analyse_lexicale.lex" +#line 59 "analyse_lexicale.lex" {return tDIV ;} YY_BREAK case 5: YY_RULE_SETUP -#line 60 "analyse_lexicale.lex" +#line 61 "analyse_lexicale.lex" {return tPO ;} YY_BREAK case 6: YY_RULE_SETUP -#line 61 "analyse_lexicale.lex" +#line 62 "analyse_lexicale.lex" {return tPF ;} YY_BREAK case 7: YY_RULE_SETUP -#line 62 "analyse_lexicale.lex" +#line 63 "analyse_lexicale.lex" {return tAO ;} YY_BREAK case 8: YY_RULE_SETUP -#line 63 "analyse_lexicale.lex" +#line 64 "analyse_lexicale.lex" {return tAF ;} YY_BREAK case 9: YY_RULE_SETUP -#line 65 "analyse_lexicale.lex" +#line 66 "analyse_lexicale.lex" {return tPV ;} YY_BREAK case 10: YY_RULE_SETUP -#line 66 "analyse_lexicale.lex" +#line 67 "analyse_lexicale.lex" {} YY_BREAK case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 67 "analyse_lexicale.lex" +#line 68 "analyse_lexicale.lex" {} YY_BREAK case 12: YY_RULE_SETUP -#line 68 "analyse_lexicale.lex" +#line 69 "analyse_lexicale.lex" {return tVIRGULE ;} YY_BREAK case 13: YY_RULE_SETUP -#line 70 "analyse_lexicale.lex" +#line 71 "analyse_lexicale.lex" {return tAFFECTATION ;} YY_BREAK case 14: YY_RULE_SETUP -#line 72 "analyse_lexicale.lex" +#line 73 "analyse_lexicale.lex" {return tEGAL ;} YY_BREAK case 15: YY_RULE_SETUP -#line 73 "analyse_lexicale.lex" +#line 74 "analyse_lexicale.lex" {return tDIFF ;} YY_BREAK case 16: YY_RULE_SETUP -#line 74 "analyse_lexicale.lex" +#line 75 "analyse_lexicale.lex" {return tLT ;} YY_BREAK case 17: YY_RULE_SETUP -#line 75 "analyse_lexicale.lex" +#line 76 "analyse_lexicale.lex" {return tGT ;} YY_BREAK case 18: YY_RULE_SETUP -#line 76 "analyse_lexicale.lex" +#line 77 "analyse_lexicale.lex" {return tLTE ;} YY_BREAK case 19: YY_RULE_SETUP -#line 77 "analyse_lexicale.lex" +#line 78 "analyse_lexicale.lex" {return tGTE ;} YY_BREAK case 20: YY_RULE_SETUP -#line 78 "analyse_lexicale.lex" +#line 79 "analyse_lexicale.lex" {return tNOT ;} YY_BREAK case 21: YY_RULE_SETUP -#line 81 "analyse_lexicale.lex" +#line 82 "analyse_lexicale.lex" {return tMAIN ;} YY_BREAK case 22: YY_RULE_SETUP -#line 82 "analyse_lexicale.lex" +#line 83 "analyse_lexicale.lex" {return tINT ;} YY_BREAK case 23: YY_RULE_SETUP -#line 83 "analyse_lexicale.lex" +#line 84 "analyse_lexicale.lex" {return tPRINT ;} YY_BREAK case 24: YY_RULE_SETUP -#line 84 "analyse_lexicale.lex" +#line 85 "analyse_lexicale.lex" {return tRETURN ;} YY_BREAK case 25: YY_RULE_SETUP -#line 86 "analyse_lexicale.lex" +#line 87 "analyse_lexicale.lex" {return tOR ;} YY_BREAK case 26: YY_RULE_SETUP -#line 87 "analyse_lexicale.lex" +#line 88 "analyse_lexicale.lex" {return tAND ;} YY_BREAK case 27: YY_RULE_SETUP -#line 89 "analyse_lexicale.lex" +#line 90 "analyse_lexicale.lex" {return tIF ;} YY_BREAK case 28: YY_RULE_SETUP -#line 90 "analyse_lexicale.lex" +#line 91 "analyse_lexicale.lex" {return tELSE ;} YY_BREAK case 29: YY_RULE_SETUP -#line 91 "analyse_lexicale.lex" +#line 92 "analyse_lexicale.lex" {return tWHILE ;} YY_BREAK case 30: YY_RULE_SETUP -#line 93 "analyse_lexicale.lex" -{return tCONST ;} +#line 94 "analyse_lexicale.lex" +{return tAPPERSAND;} YY_BREAK case 31: YY_RULE_SETUP -#line 94 "analyse_lexicale.lex" -{yylval.nombre = atoi(yytext); return tENTIER ;} +#line 95 "analyse_lexicale.lex" +{return tCONST ;} YY_BREAK case 32: YY_RULE_SETUP -#line 95 "analyse_lexicale.lex" -{yylval.nombre = -1; return tENTIEREXP;} +#line 96 "analyse_lexicale.lex" +{yylval.nombre = atoi(yytext); return tENTIER ;} YY_BREAK case 33: YY_RULE_SETUP -#line 96 "analyse_lexicale.lex" -{strcpy(yylval.id, yytext); return tVAR ;} +#line 97 "analyse_lexicale.lex" +{yylval.nombre = -1; return tENTIEREXP;} YY_BREAK case 34: YY_RULE_SETUP #line 98 "analyse_lexicale.lex" +{strcpy(yylval.id, yytext); return tVAR ;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 100 "analyse_lexicale.lex" ECHO; YY_BREAK -#line 941 "lex.yy.c" +#line 945 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1015,7 +1019,7 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1068,7 +1072,6 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ - } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer @@ -1080,9 +1083,9 @@ case YY_STATE_EOF(INITIAL): */ static int yy_get_next_buffer (void) { - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - int number_to_move, i; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1111,7 +1114,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1124,21 +1127,21 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1147,12 +1150,11 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) ); + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; + b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1180,7 +1182,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); + yyrestart(yyin ); } else @@ -1194,15 +1196,12 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1218,14 +1217,14 @@ static int yy_get_next_buffer (void) static yy_state_type yy_get_previous_state (void) { - yy_state_type yy_current_state; - char *yy_cp; + register yy_state_type yy_current_state; + register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1235,9 +1234,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; @@ -1250,10 +1249,10 @@ static int yy_get_next_buffer (void) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); - YY_CHAR yy_c = 1; + register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1263,19 +1262,17 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 69); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } -#ifndef YY_NO_UNPUT - - static void yyunput (int c, char * yy_bp ) + static void yyunput (int c, register char * yy_bp ) { - char *yy_cp; + register char *yy_cp; yy_cp = (yy_c_buf_p); @@ -1285,10 +1282,10 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = + register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -1297,7 +1294,7 @@ static int yy_get_next_buffer (void) yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1310,8 +1307,6 @@ static int yy_get_next_buffer (void) (yy_c_buf_p) = yy_cp; } -#endif - #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1336,7 +1331,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1353,13 +1348,13 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - yyrestart( yyin ); + yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) + if ( yywrap( ) ) return 0; if ( ! (yy_did_buffer_switch_on_eof) ) @@ -1397,11 +1392,11 @@ static int yy_get_next_buffer (void) if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); + yy_create_buffer(yyin,YY_BUF_SIZE ); } - yy_init_buffer( YY_CURRENT_BUFFER, input_file ); - yy_load_buffer_state( ); + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. @@ -1429,7 +1424,7 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1457,7 +1452,7 @@ static void yy_load_buffer_state (void) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1466,13 +1461,13 @@ static void yy_load_buffer_state (void) /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer( b, file ); + yy_init_buffer(b,file ); return b; } @@ -1491,11 +1486,15 @@ static void yy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf ); + yyfree((void *) b->yy_ch_buf ); - yyfree( (void *) b ); + yyfree((void *) b ); } +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. @@ -1505,7 +1504,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - yy_flush_buffer( b ); + yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1548,7 +1547,7 @@ static void yy_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -1579,7 +1578,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -1598,7 +1597,7 @@ void yypop_buffer_state (void) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1616,15 +1615,15 @@ static void yyensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1633,7 +1632,7 @@ static void yyensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; + int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc @@ -1653,7 +1652,7 @@ static void yyensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { @@ -1663,23 +1662,23 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return NULL; + return 0; - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; + b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer( b ); + yy_switch_to_buffer(b ); return b; } @@ -1692,29 +1691,28 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (const char * yystr ) +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { - return yy_scan_bytes( yystr, (int) strlen(yystr) ); + return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; - yy_size_t n; - int i; + yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n ); + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); @@ -1723,7 +1721,7 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n ); + b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1739,9 +1737,9 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (const char* msg ) +static void yy_fatal_error (yyconst char* msg ) { - fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1769,7 +1767,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) */ int yyget_lineno (void) { - + return yylineno; } @@ -1792,7 +1790,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -int yyget_leng (void) +yy_size_t yyget_leng (void) { return yyleng; } @@ -1807,29 +1805,29 @@ char *yyget_text (void) } /** Set the current line number. - * @param _line_number line number + * @param line_number * */ -void yyset_lineno (int _line_number ) +void yyset_lineno (int line_number ) { - yylineno = _line_number; + yylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param _in_str A readable stream. + * @param in_str A readable stream. * * @see yy_switch_to_buffer */ -void yyset_in (FILE * _in_str ) +void yyset_in (FILE * in_str ) { - yyin = _in_str ; + yyin = in_str ; } -void yyset_out (FILE * _out_str ) +void yyset_out (FILE * out_str ) { - yyout = _out_str ; + yyout = out_str ; } int yyget_debug (void) @@ -1837,9 +1835,9 @@ int yyget_debug (void) return yy_flex_debug; } -void yyset_debug (int _bdebug ) +void yyset_debug (int bdebug ) { - yy_flex_debug = _bdebug ; + yy_flex_debug = bdebug ; } static int yy_init_globals (void) @@ -1848,10 +1846,10 @@ static int yy_init_globals (void) * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = NULL; + (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = NULL; + (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; @@ -1860,8 +1858,8 @@ static int yy_init_globals (void) yyin = stdin; yyout = stdout; #else - yyin = NULL; - yyout = NULL; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by @@ -1876,7 +1874,7 @@ int yylex_destroy (void) /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1897,19 +1895,18 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n ) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - - int i; + register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s ) +static int yy_flex_strlen (yyconst char * s ) { - int n; + register int n; for ( n = 0; s[n]; ++n ) ; @@ -1919,12 +1916,11 @@ static int yy_flex_strlen (const char * s ) void *yyalloc (yy_size_t size ) { - return malloc(size); + return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) { - /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -1932,17 +1928,18 @@ void *yyrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return realloc(ptr, size); + return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr ) { - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 98 "analyse_lexicale.lex" +#line 100 "analyse_lexicale.lex" + //int main(void){ diff --git a/script.sh b/script.sh index 2c0b6eb..9071497 100755 --- a/script.sh +++ b/script.sh @@ -3,17 +3,12 @@ flex analyse_lexicale.lex gcc -w *.c -ly echo " int main(){ - int var1 = 1; - int var2 = 2; - var2 = 2 + 3; - int var3; - if (!var2){ - var2 = 1; - var3 = 4; - } else { - var1 = 2; - } - printf(var2); - return 5; + int c = 2; + int * p; + p = &c; + *p = 2; + int b = *p; + + return 0; } " | ./a.out \ No newline at end of file diff --git a/table_fonctions.c b/table_fonctions.c new file mode 100644 index 0000000..1671275 --- /dev/null +++ b/table_fonctions.c @@ -0,0 +1,59 @@ +#include "table_fonctions.h" +#include +#include + +void initialise_function_table(Table_Fonctions * table){ + table->depth = 1; +} + +void add_function(Table_Fonctions * table, char * function_name, enum Return_Type return_type, int start_addr){ + Fonction fonction; + strcpy(fonction.function_name,function_name); + fonction.start_addr = start_addr; + fonction.type = return_type; + fonction.function_depth = table->depth; + table->array[table->depth] = fonction; + table->depth++; +} + +void print_function(Fonction * fonction){ + char * function_name = fonction->function_name; + int start_addr = fonction->start_addr; + int depth = fonction->function_depth; + int return_type = fonction->type; + char typeStr[20]; + if (return_type == RET_INT){ + strcpy(typeStr, "INT"); + } else if (return_type == RET_INT_PTR){ + strcpy(typeStr, "INT_PTR"); + } + printf("%-20s\t\t %-12s\t\t %-12d\t %-12d\n", function_name, typeStr, start_addr, depth); +} + +void print_fonction_table(Table_Fonctions * table) { + printf("%-20s\t\t %-12s\t\t %-12s\t %-20s\n", "Function Name", "Return Type", "Start Address", "Depth"); + Fonction fonction; + for (int i = 1; i < table->depth; i++) { + fonction = table->array[i]; + print_function(&fonction); + } +} + +int function_exists(Table_Fonctions * table, char * func_name){ + for (int i = 0; i < table->depth; i++){ + if (strcmp(table->array[i].function_name, func_name) == 0){ + return i; + } + } + return -1; +} + +/* +int main(){ + Table_Fonctions table; + initialise_function_table(&table); + add_function(&table, "Fonction1", 0, 7); + add_function(&table, "Fonction2", 1, 23); + print_fonction_table(&table); + return 1; +}*/ diff --git a/table_fonctions.h b/table_fonctions.h new file mode 100644 index 0000000..2c77e2c --- /dev/null +++ b/table_fonctions.h @@ -0,0 +1,35 @@ +// +// Created by Nahom Belay on 29/04/2021. +// + +#ifndef PROJET_SYSTEME_TABLE_FONCTIONS_H +#define PROJET_SYSTEME_TABLE_FONCTIONS_H + +#define FUNCTION_TABLE_SIZE 50 +#define FUNCTION_NAME_SIZE 30 + +enum Return_Type {RET_INT , RET_INT_PTR}; + +typedef struct Fonction { + char function_name[FUNCTION_NAME_SIZE]; + int start_addr ; + enum Return_Type type; + int function_depth; +} Fonction; + +typedef struct Table_Fonctions { + Fonction array[FUNCTION_TABLE_SIZE]; + int depth; +} Table_Fonctions; + +void initialise_function_table(Table_Fonctions * table); + +void add_function(Table_Fonctions * table, char * function_name, enum Return_Type return_type, int start_addr); + +void print_fonction_table(Table_Fonctions * table); + +int function_exists(Table_Fonctions * table, char * func_name); + + + +#endif //PROJET_SYSTEME_TABLE_FONCTIONS_H diff --git a/table_symboles.c b/table_symboles.c index 88fb82f..b9e58e5 100644 --- a/table_symboles.c +++ b/table_symboles.c @@ -54,25 +54,47 @@ int add_symbole_bottom(Table_Symboles * table){ return 0; } -int remove_symboles(Table_Symboles * table, int depth){ - int index; - if (depth < table->depth){ - return -1; - } else { - index = table->indexAvailableTop; - while(table->array[index].symbole_depth == depth && index >=0){ - //remove - table->indexAvailableTop--; - index--; +int remove_symboles(Table_Symboles * table){ + if (table->indexAvailableTop > 0){ + while(table->indexAvailableTop > 0){ + if (table->array[table->indexAvailableTop-1].symbole_depth == table->depth){ + table->indexAvailableTop--; + } else { + break; + } + } + } + //TODO: vérifier qu'il n'y a pas de varaibles temporarires au moment de changement de profondeur - } return 0; } void free_temp(Table_Symboles * table){ table->indexAvailableBottom++; + if (table->indexAvailableBottom >= TABLE_SIZE){ + printf("Huge error\n"); + table->indexAvailableBottom--; + } +} + +int prepare_function_call(Table_Symboles * table){ + prepare_argument_push(table); + prepare_argument_push(table); + prepare_argument_push(table); +} + +int prepare_argument_push(Table_Symboles * table){ + Symbole symbole; + symbole.addr = table->indexAvailableTop; + symbole.symbole_depth = table->depth; + if (table->indexAvailableTop < table->indexAvailableBottom){ + table->array[table->indexAvailableTop] = symbole; + table->indexAvailableTop++; + return (table->indexAvailableTop) - 1 ; + } + } int initialise_symbole(Table_Symboles * table, char * varName){ @@ -91,8 +113,12 @@ void print_symbole(Symbole * symbole){ char typeStr[20]; if (type == TYPE_INT){ strcpy(typeStr, "INT"); - } else{ + } else if (type == TYPE_CONST_INT){ strcpy(typeStr, "CONST_INT"); + } else if (type == TYPE_INT_PTR) { + strcpy(typeStr, "INT_PTR"); + } else { + strcpy(typeStr, "Error type"); } enum Initialised_Variable init = symbole->init; char initStr[20]; diff --git a/table_symboles.h b/table_symboles.h index acdc1fc..e03b52a 100644 --- a/table_symboles.h +++ b/table_symboles.h @@ -4,7 +4,7 @@ #define TABLE_SIZE 50 #define VARIABLE_SIZE 30 -enum Symbole_Type {TYPE_INT , TYPE_CONST_INT}; +enum Symbole_Type {TYPE_INT , TYPE_CONST_INT, TYPE_INT_PTR}; enum Initialised_Variable{INITIALISED , NOT_INITIALISED}; typedef struct Symboles { @@ -58,14 +58,18 @@ int variable_exists(Table_Symboles * table, char * varName); /** * Removes symbole from table having certain depth * @param table - * @param depth * @return -1 if the symbole isn't in the table, 0 otherwise */ -int remove_symboles(Table_Symboles * table, int depth); +int remove_symboles(Table_Symboles * table); void free_temp(Table_Symboles * table); +int prepare_function_call(Table_Symboles * table); + +int prepare_argument_push(Table_Symboles * table); + + /** * Initialises an already exisiting symbole * @param table