diff --git a/.DS_Store b/.DS_Store index 306d866..d4d7cab 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce09c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.tab.c +*.tab.h +*.yy.c +a.out +poubelle/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bedf918 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..284d410 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/projet_systeme.iml b/.idea/projet_systeme.iml new file mode 100644 index 0000000..771e54c --- /dev/null +++ b/.idea/projet_systeme.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/a.out b/a.out index 1475c63..7e82ec9 100755 Binary files a/a.out and b/a.out differ diff --git a/analyse_syntaxique.output b/analyse_syntaxique.output index 4a0e4ea..aab98ff 100644 --- a/analyse_syntaxique.output +++ b/analyse_syntaxique.output @@ -1,27 +1,27 @@ -Terminaux inutilisés dans la grammaire +Terminals which are not used tENTIEREXP tERROR -Grammaire +Grammar 0 $accept: Main $end 1 Main: tINT tMAIN tPO Params tPF Body - 2 Params: %empty + 2 Params: /* empty */ 3 | Param SuiteParams 4 Param: tINT tVAR 5 SuiteParams: tVIRGULE Param SuiteParams tPV - 6 | %empty + 6 | /* empty */ 7 Body: tAO Instructions Return tAF 8 Instructions: Instruction Instructions - 9 | %empty + 9 | /* empty */ 10 Instruction: Aff 11 | If @@ -33,7 +33,7 @@ Grammaire 16 Decl: Type Valeur SuiteDecl tPV 17 SuiteDecl: tVIRGULE Valeur SuiteDecl - 18 | %empty + 18 | /* empty */ 19 Type: tINT 20 | tCONST tINT @@ -54,42 +54,44 @@ Grammaire 32 | tPO E tPF 33 Args: tVAR SuiteArgs - 34 | %empty + 34 | /* empty */ 35 SuiteArgs: tVIRGULE tVAR SuiteArgs - 36 | %empty + 36 | /* empty */ - 37 $@1: %empty + 37 @1: /* empty */ - 38 $@2: %empty + 38 @2: /* empty */ - 39 If: tIF tPO Cond tPF $@1 tAO Instructions tAF $@2 Else + 39 If: tIF tPO Cond tPF @1 tAO Instructions tAF @2 Else 40 Else: tELSE tAO Instructions tAF - 41 | %empty + 41 | /* empty */ 42 | tELSE tIF tPO Cond tPF tAO Instructions tAF Else - 43 While: tWHILE tPO Cond tPF tAO Instructions tAF + 43 @3: /* empty */ - 44 Cond: E tEGAL E - 45 | E tDIFF E - 46 | E tLT E - 47 | E tGT E - 48 | E tLTE E - 49 | E tGTE E - 50 | E tAND Cond - 51 | E tOR Cond - 52 | tNOT Cond - 53 | E + 44 While: tWHILE tPO Cond tPF @3 tAO Instructions tAF - 54 Invocation: tVAR tPO Args tPF + 45 Cond: E tEGAL E + 46 | E tDIFF E + 47 | E tLT E + 48 | E tGT E + 49 | E tLTE E + 50 | E tGTE E + 51 | E tAND E + 52 | E tOR E + 53 | tNOT Cond + 54 | E - 55 Print: tPRINT tPO tVAR tPF tPV + 55 Invocation: tVAR tPO Args tPF - 56 Return: tRETURN E tPV + 56 Print: tPRINT tPO E tPF tPV + + 57 Return: tRETURN E tPV -Terminaux, suivis des règles où ils apparaissent +Terminals, with rules where they appear $end (0) 0 error (256) @@ -99,640 +101,655 @@ tADD (260) 26 tSUB (261) 28 30 tMUL (262) 27 tDIV (263) 29 -tPO (264) 1 32 39 42 43 54 55 -tPF (265) 1 32 39 42 43 54 55 -tAO (266) 7 39 40 42 43 -tAF (267) 7 39 40 42 43 +tPO (264) 1 32 39 42 44 55 56 +tPF (265) 1 32 39 42 44 55 56 +tAO (266) 7 39 40 42 44 +tAF (267) 7 39 40 42 44 tERROR (268) -tPV (269) 5 15 16 23 55 56 +tPV (269) 5 15 16 23 56 57 tVIRGULE (270) 5 17 35 tAFFECTATION (271) 21 23 -tEGAL (272) 44 -tDIFF (273) 45 -tLT (274) 46 -tGT (275) 47 -tGTE (276) 49 -tLTE (277) 48 +tEGAL (272) 45 +tDIFF (273) 46 +tLT (274) 47 +tGT (275) 48 +tGTE (276) 50 +tLTE (277) 49 tMAIN (278) 1 tINT (279) 1 4 19 20 -tPRINT (280) 55 -tRETURN (281) 56 -tOR (282) 51 -tAND (283) 50 +tPRINT (280) 56 +tRETURN (281) 57 +tOR (282) 52 +tAND (283) 51 tIF (284) 39 42 tELSE (285) 40 42 -tWHILE (286) 43 +tWHILE (286) 44 tCONST (287) 20 -tVAR (288) 4 21 22 23 25 33 35 54 55 -tNOT (289) 52 +tVAR (288) 4 21 22 23 25 33 35 55 +tNOT (289) 53 -Non-terminaux, suivis des règles où ils apparaissent +Nonterminals, with rules where they appear $accept (35) - à gauche: 0 + on left: 0 Main (36) - à gauche: 1, à droite: 0 + on left: 1, on right: 0 Params (37) - à gauche: 2 3, à droite: 1 + on left: 2 3, on right: 1 Param (38) - à gauche: 4, à droite: 3 5 + on left: 4, on right: 3 5 SuiteParams (39) - à gauche: 5 6, à droite: 3 5 + on left: 5 6, on right: 3 5 Body (40) - à gauche: 7, à droite: 1 + on left: 7, on right: 1 Instructions (41) - à gauche: 8 9, à droite: 7 8 39 40 42 43 + on left: 8 9, on right: 7 8 39 40 42 44 Instruction (42) - à gauche: 10 11 12 13 14 15, à droite: 8 + on left: 10 11 12 13 14 15, on right: 8 Decl (43) - à gauche: 16, à droite: 14 + on left: 16, on right: 14 SuiteDecl (44) - à gauche: 17 18, à droite: 16 17 + on left: 17 18, on right: 16 17 Type (45) - à gauche: 19 20, à droite: 16 + on left: 19 20, on right: 16 Valeur (46) - à gauche: 21 22, à droite: 16 17 + on left: 21 22, on right: 16 17 Aff (47) - à gauche: 23, à droite: 10 + on left: 23, on right: 10 E (48) - à gauche: 24 25 26 27 28 29 30 31 32, à droite: 21 23 26 27 28 - 29 30 32 44 45 46 47 48 49 50 51 53 56 + on left: 24 25 26 27 28 29 30 31 32, on right: 21 23 26 27 28 29 + 30 32 45 46 47 48 49 50 51 52 54 56 57 Args (49) - à gauche: 33 34, à droite: 54 + on left: 33 34, on right: 55 SuiteArgs (50) - à gauche: 35 36, à droite: 33 35 + on left: 35 36, on right: 33 35 If (51) - à gauche: 39, à droite: 11 -$@1 (52) - à gauche: 37, à droite: 39 -$@2 (53) - à gauche: 38, à droite: 39 + on left: 39, on right: 11 +@1 (52) + on left: 37, on right: 39 +@2 (53) + on left: 38, on right: 39 Else (54) - à gauche: 40 41 42, à droite: 39 42 + on left: 40 41 42, on right: 39 42 While (55) - à gauche: 43, à droite: 12 -Cond (56) - à gauche: 44 45 46 47 48 49 50 51 52 53, à droite: 39 42 43 50 - 51 52 -Invocation (57) - à gauche: 54, à droite: 15 31 -Print (58) - à gauche: 55, à droite: 13 -Return (59) - à gauche: 56, à droite: 7 + on left: 44, on right: 12 +@3 (56) + on left: 43, on right: 44 +Cond (57) + on left: 45 46 47 48 49 50 51 52 53 54, on right: 39 42 44 53 +Invocation (58) + on left: 55, on right: 15 31 +Print (59) + on left: 56, on right: 13 +Return (60) + on left: 57, on right: 7 -État 0 +state 0 0 $accept: . Main $end - tINT décalage et aller à l'état 1 + tINT shift, and go to state 1 - Main aller à l'état 2 + Main go to state 2 -État 1 +state 1 1 Main: tINT . tMAIN tPO Params tPF Body - tMAIN décalage et aller à l'état 3 + tMAIN shift, and go to state 3 -État 2 +state 2 0 $accept: Main . $end - $end décalage et aller à l'état 4 + $end shift, and go to state 4 -État 3 +state 3 1 Main: tINT tMAIN . tPO Params tPF Body - tPO décalage et aller à l'état 5 + tPO shift, and go to state 5 -État 4 +state 4 0 $accept: Main $end . - $défaut accepter + $default accept -État 5 +state 5 1 Main: tINT tMAIN tPO . Params tPF Body - tINT décalage et aller à l'état 6 + tINT shift, and go to state 6 - $défaut réduction par utilisation de la règle 2 (Params) + $default reduce using rule 2 (Params) - Params aller à l'état 7 - Param aller à l'état 8 + Params go to state 7 + Param go to state 8 -État 6 +state 6 4 Param: tINT . tVAR - tVAR décalage et aller à l'état 9 + tVAR shift, and go to state 9 -État 7 +state 7 1 Main: tINT tMAIN tPO Params . tPF Body - tPF décalage et aller à l'état 10 + tPF shift, and go to state 10 -État 8 +state 8 3 Params: Param . SuiteParams - tVIRGULE décalage et aller à l'état 11 + tVIRGULE shift, and go to state 11 - $défaut réduction par utilisation de la règle 6 (SuiteParams) + $default reduce using rule 6 (SuiteParams) - SuiteParams aller à l'état 12 + SuiteParams go to state 12 -État 9 +state 9 4 Param: tINT tVAR . - $défaut réduction par utilisation de la règle 4 (Param) + $default reduce using rule 4 (Param) -État 10 +state 10 1 Main: tINT tMAIN tPO Params tPF . Body - tAO décalage et aller à l'état 13 + tAO shift, and go to state 13 - Body aller à l'état 14 + Body go to state 14 -État 11 +state 11 5 SuiteParams: tVIRGULE . Param SuiteParams tPV - tINT décalage et aller à l'état 6 + tINT shift, and go to state 6 - Param aller à l'état 15 + Param go to state 15 -État 12 +state 12 3 Params: Param SuiteParams . - $défaut réduction par utilisation de la règle 3 (Params) + $default reduce using rule 3 (Params) -État 13 +state 13 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 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 - $défaut réduction par utilisation de la règle 9 (Instructions) + $default reduce using rule 9 (Instructions) - 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 + Instructions go to state 22 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 14 +state 14 1 Main: tINT tMAIN tPO Params tPF Body . - $défaut réduction par utilisation de la règle 1 (Main) + $default reduce using rule 1 (Main) -État 15 +state 15 5 SuiteParams: tVIRGULE Param . SuiteParams tPV - tVIRGULE décalage et aller à l'état 11 + tVIRGULE shift, and go to state 11 - $défaut réduction par utilisation de la règle 6 (SuiteParams) + $default reduce using rule 6 (SuiteParams) - SuiteParams aller à l'état 31 + SuiteParams go to state 31 -État 16 +state 16 19 Type: tINT . - $défaut réduction par utilisation de la règle 19 (Type) + $default reduce using rule 19 (Type) -État 17 +state 17 - 55 Print: tPRINT . tPO tVAR tPF tPV + 56 Print: tPRINT . tPO E tPF tPV - tPO décalage et aller à l'état 32 + tPO shift, and go to state 32 -État 18 +state 18 - 39 If: tIF . tPO Cond tPF $@1 tAO Instructions tAF $@2 Else + 39 If: tIF . tPO Cond tPF @1 tAO Instructions tAF @2 Else - tPO décalage et aller à l'état 33 + tPO shift, and go to state 33 -État 19 +state 19 - 43 While: tWHILE . tPO Cond tPF tAO Instructions tAF + 44 While: tWHILE . tPO Cond tPF @3 tAO Instructions tAF - tPO décalage et aller à l'état 34 + tPO shift, and go to state 34 -État 20 +state 20 20 Type: tCONST . tINT - tINT décalage et aller à l'état 35 + tINT shift, and go to state 35 -État 21 +state 21 23 Aff: tVAR . tAFFECTATION E tPV - 54 Invocation: tVAR . tPO Args tPF + 55 Invocation: tVAR . tPO Args tPF - tPO décalage et aller à l'état 36 - tAFFECTATION décalage et aller à l'état 37 + tPO shift, and go to state 36 + tAFFECTATION shift, and go to state 37 -État 22 +state 22 7 Body: tAO Instructions . Return tAF - tRETURN décalage et aller à l'état 38 + tRETURN shift, and go to state 38 - Return aller à l'état 39 + Return go to state 39 -État 23 +state 23 8 Instructions: Instruction . Instructions - 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 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 - $défaut réduction par utilisation de la règle 9 (Instructions) + $default reduce using rule 9 (Instructions) - 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 + Instructions go to state 40 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 24 +state 24 14 Instruction: Decl . - $défaut réduction par utilisation de la règle 14 (Instruction) + $default reduce using rule 14 (Instruction) -État 25 +state 25 16 Decl: Type . Valeur SuiteDecl tPV - tVAR décalage et aller à l'état 41 + tVAR shift, and go to state 41 - Valeur aller à l'état 42 + Valeur go to state 42 -État 26 +state 26 10 Instruction: Aff . - $défaut réduction par utilisation de la règle 10 (Instruction) + $default reduce using rule 10 (Instruction) -État 27 +state 27 11 Instruction: If . - $défaut réduction par utilisation de la règle 11 (Instruction) + $default reduce using rule 11 (Instruction) -État 28 +state 28 12 Instruction: While . - $défaut réduction par utilisation de la règle 12 (Instruction) + $default reduce using rule 12 (Instruction) -État 29 +state 29 15 Instruction: Invocation . tPV - tPV décalage et aller à l'état 43 + tPV shift, and go to state 43 -État 30 +state 30 13 Instruction: Print . - $défaut réduction par utilisation de la règle 13 (Instruction) + $default reduce using rule 13 (Instruction) -État 31 +state 31 5 SuiteParams: tVIRGULE Param SuiteParams . tPV - tPV décalage et aller à l'état 44 + tPV shift, and go to state 44 -État 32 +state 32 - 55 Print: tPRINT tPO . tVAR tPF tPV + 56 Print: tPRINT tPO . E tPF tPV - tVAR décalage et aller à l'état 45 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + + E go to state 49 + Invocation go to state 50 -État 33 +state 33 - 39 If: tIF tPO . Cond tPF $@1 tAO Instructions tAF $@2 Else + 39 If: tIF tPO . Cond tPF @1 tAO Instructions tAF @2 Else - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + tNOT shift, and go to state 51 - E aller à l'état 51 - Cond aller à l'état 52 - Invocation aller à l'état 53 + E go to state 52 + Cond go to state 53 + Invocation go to state 50 -État 34 +state 34 - 43 While: tWHILE tPO . Cond tPF tAO Instructions tAF + 44 While: tWHILE tPO . Cond tPF @3 tAO Instructions tAF - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + tNOT shift, and go to state 51 - E aller à l'état 51 - Cond aller à l'état 54 - Invocation aller à l'état 53 + E go to state 52 + Cond go to state 54 + Invocation go to state 50 -État 35 +state 35 20 Type: tCONST tINT . - $défaut réduction par utilisation de la règle 20 (Type) + $default reduce using rule 20 (Type) -État 36 +state 36 - 54 Invocation: tVAR tPO . Args tPF + 55 Invocation: tVAR tPO . Args tPF - tVAR décalage et aller à l'état 55 + tVAR shift, and go to state 55 - $défaut réduction par utilisation de la règle 34 (Args) + $default reduce using rule 34 (Args) - Args aller à l'état 56 + Args go to state 56 -État 37 +state 37 23 Aff: tVAR tAFFECTATION . E tPV - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 57 - Invocation aller à l'état 53 + E go to state 57 + Invocation go to state 50 -État 38 +state 38 - 56 Return: tRETURN . E tPV + 57 Return: tRETURN . E tPV - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 58 - Invocation aller à l'état 53 + E go to state 58 + Invocation go to state 50 -État 39 +state 39 7 Body: tAO Instructions Return . tAF - tAF décalage et aller à l'état 59 + tAF shift, and go to state 59 -État 40 +state 40 8 Instructions: Instruction Instructions . - $défaut réduction par utilisation de la règle 8 (Instructions) + $default reduce using rule 8 (Instructions) -État 41 +state 41 21 Valeur: tVAR . tAFFECTATION E 22 | tVAR . - tAFFECTATION décalage et aller à l'état 60 + tAFFECTATION shift, and go to state 60 - $défaut réduction par utilisation de la règle 22 (Valeur) + $default reduce using rule 22 (Valeur) -État 42 +state 42 16 Decl: Type Valeur . SuiteDecl tPV - tVIRGULE décalage et aller à l'état 61 + tVIRGULE shift, and go to state 61 - $défaut réduction par utilisation de la règle 18 (SuiteDecl) + $default reduce using rule 18 (SuiteDecl) - SuiteDecl aller à l'état 62 + SuiteDecl go to state 62 -État 43 +state 43 15 Instruction: Invocation tPV . - $défaut réduction par utilisation de la règle 15 (Instruction) + $default reduce using rule 15 (Instruction) -État 44 +state 44 5 SuiteParams: tVIRGULE Param SuiteParams tPV . - $défaut réduction par utilisation de la règle 5 (SuiteParams) + $default reduce using rule 5 (SuiteParams) -État 45 - - 55 Print: tPRINT tPO tVAR . tPF tPV - - tPF décalage et aller à l'état 63 - - -État 46 +state 45 24 E: tENTIER . - $défaut réduction par utilisation de la règle 24 (E) + $default reduce using rule 24 (E) -État 47 +state 46 30 E: tSUB . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 64 - Invocation aller à l'état 53 + E go to state 63 + Invocation go to state 50 -État 48 +state 47 32 E: tPO . E tPF - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 65 - Invocation aller à l'état 53 + E go to state 64 + Invocation go to state 50 -État 49 +state 48 25 E: tVAR . - 54 Invocation: tVAR . tPO Args tPF + 55 Invocation: tVAR . tPO Args tPF - tPO décalage et aller à l'état 36 + tPO shift, and go to state 36 - $défaut réduction par utilisation de la règle 25 (E) + $default reduce using rule 25 (E) -État 50 - - 52 Cond: tNOT . Cond - - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 - - E aller à l'état 51 - Cond aller à l'état 66 - Invocation aller à l'état 53 - - -État 51 +state 49 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 44 Cond: E . tEGAL E - 45 | E . tDIFF E - 46 | E . tLT E - 47 | E . tGT E - 48 | E . tLTE E - 49 | E . tGTE E - 50 | E . tAND Cond - 51 | E . tOR Cond - 53 | E . + 56 Print: tPRINT tPO E . tPF tPV - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 - 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 - - $défaut réduction par utilisation de la règle 53 (Cond) + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + tPF shift, and go to state 69 -État 52 - - 39 If: tIF tPO Cond . tPF $@1 tAO Instructions tAF $@2 Else - - tPF décalage et aller à l'état 79 - - -État 53 +state 50 31 E: Invocation . - $défaut réduction par utilisation de la règle 31 (E) + $default reduce using rule 31 (E) -État 54 +state 51 - 43 While: tWHILE tPO Cond . tPF tAO Instructions tAF + 53 Cond: tNOT . Cond - tPF décalage et aller à l'état 80 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + tNOT shift, and go to state 51 + + E go to state 52 + Cond go to state 70 + Invocation go to state 50 -État 55 +state 52 + + 26 E: E . tADD E + 27 | E . tMUL E + 28 | E . tSUB E + 29 | E . tDIV E + 45 Cond: E . tEGAL E + 46 | E . tDIFF E + 47 | E . tLT E + 48 | E . tGT E + 49 | E . tLTE E + 50 | E . tGTE E + 51 | E . tAND E + 52 | E . tOR E + 54 | E . + + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + tEGAL shift, and go to state 71 + tDIFF shift, and go to state 72 + tLT shift, and go to state 73 + tGT shift, and go to state 74 + tGTE shift, and go to state 75 + tLTE shift, and go to state 76 + tOR shift, and go to state 77 + tAND shift, and go to state 78 + + $default reduce using rule 54 (Cond) + + +state 53 + + 39 If: tIF tPO Cond . tPF @1 tAO Instructions tAF @2 Else + + tPF shift, and go to state 79 + + +state 54 + + 44 While: tWHILE tPO Cond . tPF @3 tAO Instructions tAF + + tPF shift, and go to state 80 + + +state 55 33 Args: tVAR . SuiteArgs - tVIRGULE décalage et aller à l'état 81 + tVIRGULE shift, and go to state 81 - $défaut réduction par utilisation de la règle 36 (SuiteArgs) + $default reduce using rule 36 (SuiteArgs) - SuiteArgs aller à l'état 82 + SuiteArgs go to state 82 -État 56 +state 56 - 54 Invocation: tVAR tPO Args . tPF + 55 Invocation: tVAR tPO Args . tPF - tPF décalage et aller à l'état 83 + tPF shift, and go to state 83 -État 57 +state 57 23 Aff: tVAR tAFFECTATION E . tPV 26 E: E . tADD E @@ -740,72 +757,65 @@ Return (59) 28 | E . tSUB E 29 | E . tDIV E - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 - tPV décalage et aller à l'état 84 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + tPV shift, and go to state 84 -État 58 +state 58 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 56 Return: tRETURN E . tPV + 57 Return: tRETURN E . tPV - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 - tPV décalage et aller à l'état 85 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + tPV shift, and go to state 85 -État 59 +state 59 7 Body: tAO Instructions Return tAF . - $défaut réduction par utilisation de la règle 7 (Body) + $default reduce using rule 7 (Body) -État 60 +state 60 21 Valeur: tVAR tAFFECTATION . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 86 - Invocation aller à l'état 53 + E go to state 86 + Invocation go to state 50 -État 61 +state 61 17 SuiteDecl: tVIRGULE . Valeur SuiteDecl - tVAR décalage et aller à l'état 41 + tVAR shift, and go to state 41 - Valeur aller à l'état 87 + Valeur go to state 87 -État 62 +state 62 16 Decl: Type Valeur SuiteDecl . tPV - tPV décalage et aller à l'état 88 + tPV shift, and go to state 88 -État 63 - - 55 Print: tPRINT tPO tVAR tPF . tPV - - tPV décalage et aller à l'état 89 - - -État 64 +state 63 26 E: E . tADD E 27 | E . tMUL E @@ -813,13 +823,13 @@ Return (59) 29 | E . tDIV E 30 | tSUB E . - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 30 (E) + $default reduce using rule 30 (E) -État 65 +state 64 26 E: E . tADD E 27 | E . tMUL E @@ -827,232 +837,237 @@ Return (59) 29 | E . tDIV E 32 | tPO E . tPF - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 - tPF décalage et aller à l'état 90 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + tPF shift, and go to state 89 -État 66 - - 52 Cond: tNOT Cond . - - $défaut réduction par utilisation de la règle 52 (Cond) - - -État 67 +state 65 26 E: E tADD . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 91 - Invocation aller à l'état 53 + E go to state 90 + Invocation go to state 50 -État 68 +state 66 28 E: E tSUB . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 92 - Invocation aller à l'état 53 + E go to state 91 + Invocation go to state 50 -État 69 +state 67 27 E: E tMUL . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 93 - Invocation aller à l'état 53 + E go to state 92 + Invocation go to state 50 -État 70 +state 68 29 E: E tDIV . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 94 - Invocation aller à l'état 53 + E go to state 93 + Invocation go to state 50 -État 71 +state 69 - 44 Cond: E tEGAL . E + 56 Print: tPRINT tPO E tPF . tPV - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - - E aller à l'état 95 - Invocation aller à l'état 53 + tPV shift, and go to state 94 -État 72 +state 70 - 45 Cond: E tDIFF . E + 53 Cond: tNOT Cond . - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - - E aller à l'état 96 - Invocation aller à l'état 53 + $default reduce using rule 53 (Cond) -État 73 +state 71 - 46 Cond: E tLT . E + 45 Cond: E tEGAL . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 97 - Invocation aller à l'état 53 + E go to state 95 + Invocation go to state 50 -État 74 +state 72 - 47 Cond: E tGT . E + 46 Cond: E tDIFF . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 98 - Invocation aller à l'état 53 + E go to state 96 + Invocation go to state 50 -État 75 +state 73 - 49 Cond: E tGTE . E + 47 Cond: E tLT . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 99 - Invocation aller à l'état 53 + E go to state 97 + Invocation go to state 50 -État 76 +state 74 - 48 Cond: E tLTE . E + 48 Cond: E tGT . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 100 - Invocation aller à l'état 53 + E go to state 98 + Invocation go to state 50 -État 77 +state 75 - 51 Cond: E tOR . Cond + 50 Cond: E tGTE . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 51 - Cond aller à l'état 101 - Invocation aller à l'état 53 + E go to state 99 + Invocation go to state 50 -État 78 +state 76 - 50 Cond: E tAND . Cond + 49 Cond: E tLTE . E - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - E aller à l'état 51 - Cond aller à l'état 102 - Invocation aller à l'état 53 + E go to state 100 + Invocation go to state 50 -État 79 +state 77 - 39 If: tIF tPO Cond tPF . $@1 tAO Instructions tAF $@2 Else + 52 Cond: E tOR . E - $défaut réduction par utilisation de la règle 37 ($@1) + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 - $@1 aller à l'état 103 + E go to state 101 + Invocation go to state 50 -État 80 +state 78 - 43 While: tWHILE tPO Cond tPF . tAO Instructions tAF + 51 Cond: E tAND . E - tAO décalage et aller à l'état 104 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + + E go to state 102 + Invocation go to state 50 -État 81 +state 79 + + 39 If: tIF tPO Cond tPF . @1 tAO Instructions tAF @2 Else + + $default reduce using rule 37 (@1) + + @1 go to state 103 + + +state 80 + + 44 While: tWHILE tPO Cond tPF . @3 tAO Instructions tAF + + $default reduce using rule 43 (@3) + + @3 go to state 104 + + +state 81 35 SuiteArgs: tVIRGULE . tVAR SuiteArgs - tVAR décalage et aller à l'état 105 + tVAR shift, and go to state 105 -État 82 +state 82 33 Args: tVAR SuiteArgs . - $défaut réduction par utilisation de la règle 33 (Args) + $default reduce using rule 33 (Args) -État 83 +state 83 - 54 Invocation: tVAR tPO Args tPF . + 55 Invocation: tVAR tPO Args tPF . - $défaut réduction par utilisation de la règle 54 (Invocation) + $default reduce using rule 55 (Invocation) -État 84 +state 84 23 Aff: tVAR tAFFECTATION E tPV . - $défaut réduction par utilisation de la règle 23 (Aff) + $default reduce using rule 23 (Aff) -État 85 +state 85 - 56 Return: tRETURN E tPV . + 57 Return: tRETURN E tPV . - $défaut réduction par utilisation de la règle 56 (Return) + $default reduce using rule 57 (Return) -État 86 +state 86 21 Valeur: tVAR tAFFECTATION E . 26 E: E . tADD E @@ -1060,47 +1075,40 @@ Return (59) 28 | E . tSUB E 29 | E . tDIV E - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 21 (Valeur) + $default reduce using rule 21 (Valeur) -État 87 +state 87 17 SuiteDecl: tVIRGULE Valeur . SuiteDecl - tVIRGULE décalage et aller à l'état 61 + tVIRGULE shift, and go to state 61 - $défaut réduction par utilisation de la règle 18 (SuiteDecl) + $default reduce using rule 18 (SuiteDecl) - SuiteDecl aller à l'état 106 + SuiteDecl go to state 106 -État 88 +state 88 16 Decl: Type Valeur SuiteDecl tPV . - $défaut réduction par utilisation de la règle 16 (Decl) + $default reduce using rule 16 (Decl) -État 89 - - 55 Print: tPRINT tPO tVAR tPF tPV . - - $défaut réduction par utilisation de la règle 55 (Print) - - -État 90 +state 89 32 E: tPO E tPF . - $défaut réduction par utilisation de la règle 32 (E) + $default reduce using rule 32 (E) -État 91 +state 90 26 E: E . tADD E 26 | E tADD E . @@ -1108,14 +1116,14 @@ Return (59) 28 | E . tSUB E 29 | E . tDIV E - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 26 (E) + $default reduce using rule 26 (E) -État 92 +state 91 26 E: E . tADD E 27 | E . tMUL E @@ -1123,13 +1131,13 @@ Return (59) 28 | E tSUB E . 29 | E . tDIV E - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 28 (E) + $default reduce using rule 28 (E) -État 93 +state 92 26 E: E . tADD E 27 | E . tMUL E @@ -1137,12 +1145,12 @@ Return (59) 28 | E . tSUB E 29 | E . tDIV E - tDIV décalage et aller à l'état 70 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 27 (E) + $default reduce using rule 27 (E) -État 94 +state 93 26 E: E . tADD E 27 | E . tMUL E @@ -1150,374 +1158,406 @@ Return (59) 29 | E . tDIV E 29 | E tDIV E . - $défaut réduction par utilisation de la règle 29 (E) + $default reduce using rule 29 (E) -État 95 +state 94 + + 56 Print: tPRINT tPO E tPF tPV . + + $default reduce using rule 56 (Print) + + +state 95 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 44 Cond: E tEGAL E . + 45 Cond: E tEGAL E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 44 (Cond) + $default reduce using rule 45 (Cond) -État 96 +state 96 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 45 Cond: E tDIFF E . + 46 Cond: E tDIFF E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 45 (Cond) + $default reduce using rule 46 (Cond) -État 97 +state 97 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 46 Cond: E tLT E . + 47 Cond: E tLT E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 46 (Cond) + $default reduce using rule 47 (Cond) -État 98 +state 98 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 47 Cond: E tGT E . + 48 Cond: E tGT E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 47 (Cond) + $default reduce using rule 48 (Cond) -État 99 +state 99 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 49 Cond: E tGTE E . + 50 Cond: E tGTE E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 49 (Cond) + $default reduce using rule 50 (Cond) -État 100 +state 100 26 E: E . tADD E 27 | E . tMUL E 28 | E . tSUB E 29 | E . tDIV E - 48 Cond: E tLTE E . + 49 Cond: E tLTE E . - tADD décalage et aller à l'état 67 - tSUB décalage et aller à l'état 68 - tMUL décalage et aller à l'état 69 - tDIV décalage et aller à l'état 70 + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 - $défaut réduction par utilisation de la règle 48 (Cond) + $default reduce using rule 49 (Cond) -État 101 +state 101 - 51 Cond: E tOR Cond . + 26 E: E . tADD E + 27 | E . tMUL E + 28 | E . tSUB E + 29 | E . tDIV E + 52 Cond: E tOR E . - $défaut réduction par utilisation de la règle 51 (Cond) + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + + $default reduce using rule 52 (Cond) -État 102 +state 102 - 50 Cond: E tAND Cond . + 26 E: E . tADD E + 27 | E . tMUL E + 28 | E . tSUB E + 29 | E . tDIV E + 51 Cond: E tAND E . - $défaut réduction par utilisation de la règle 50 (Cond) + tADD shift, and go to state 65 + tSUB shift, and go to state 66 + tMUL shift, and go to state 67 + tDIV shift, and go to state 68 + + $default reduce using rule 51 (Cond) -État 103 +state 103 - 39 If: tIF tPO Cond tPF $@1 . tAO Instructions tAF $@2 Else + 39 If: tIF tPO Cond tPF @1 . tAO Instructions tAF @2 Else - tAO décalage et aller à l'état 107 + tAO shift, and go to state 107 -État 104 +state 104 - 43 While: tWHILE tPO Cond tPF tAO . Instructions tAF + 44 While: tWHILE tPO Cond tPF @3 . tAO Instructions 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 - - $défaut réduction par utilisation de la règle 9 (Instructions) - - Instructions aller à l'état 108 - 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 + tAO shift, and go to state 108 -État 105 +state 105 35 SuiteArgs: tVIRGULE tVAR . SuiteArgs - tVIRGULE décalage et aller à l'état 81 + tVIRGULE shift, and go to state 81 - $défaut réduction par utilisation de la règle 36 (SuiteArgs) + $default reduce using rule 36 (SuiteArgs) - SuiteArgs aller à l'état 109 + SuiteArgs go to state 109 -État 106 +state 106 17 SuiteDecl: tVIRGULE Valeur SuiteDecl . - $défaut réduction par utilisation de la règle 17 (SuiteDecl) + $default reduce using rule 17 (SuiteDecl) -État 107 +state 107 - 39 If: tIF tPO Cond tPF $@1 tAO . Instructions tAF $@2 Else + 39 If: tIF tPO Cond tPF @1 tAO . Instructions tAF @2 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 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 - $défaut réduction par utilisation de la règle 9 (Instructions) + $default reduce using rule 9 (Instructions) - Instructions aller à l'état 110 - 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 + Instructions go to state 110 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 108 +state 108 - 43 While: tWHILE tPO Cond tPF tAO Instructions . tAF + 44 While: tWHILE tPO Cond tPF @3 tAO . Instructions tAF - tAF décalage et aller à l'état 111 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 + + $default reduce using rule 9 (Instructions) + + Instructions go to state 111 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 109 +state 109 35 SuiteArgs: tVIRGULE tVAR SuiteArgs . - $défaut réduction par utilisation de la règle 35 (SuiteArgs) + $default reduce using rule 35 (SuiteArgs) -État 110 +state 110 - 39 If: tIF tPO Cond tPF $@1 tAO Instructions . tAF $@2 Else + 39 If: tIF tPO Cond tPF @1 tAO Instructions . tAF @2 Else - tAF décalage et aller à l'état 112 + tAF shift, and go to state 112 -État 111 +state 111 - 43 While: tWHILE tPO Cond tPF tAO Instructions tAF . + 44 While: tWHILE tPO Cond tPF @3 tAO Instructions . tAF - $défaut réduction par utilisation de la règle 43 (While) + tAF shift, and go to state 113 -État 112 +state 112 - 39 If: tIF tPO Cond tPF $@1 tAO Instructions tAF . $@2 Else + 39 If: tIF tPO Cond tPF @1 tAO Instructions tAF . @2 Else - $défaut réduction par utilisation de la règle 38 ($@2) + $default reduce using rule 38 (@2) - $@2 aller à l'état 113 + @2 go to state 114 -État 113 +state 113 - 39 If: tIF tPO Cond tPF $@1 tAO Instructions tAF $@2 . Else + 44 While: tWHILE tPO Cond tPF @3 tAO Instructions tAF . - tELSE décalage et aller à l'état 114 - - $défaut réduction par utilisation de la règle 41 (Else) - - Else aller à l'état 115 + $default reduce using rule 44 (While) -État 114 +state 114 + + 39 If: tIF tPO Cond tPF @1 tAO Instructions tAF @2 . Else + + tELSE shift, and go to state 115 + + $default reduce using rule 41 (Else) + + Else go to state 116 + + +state 115 40 Else: tELSE . tAO Instructions tAF 42 | tELSE . tIF tPO Cond tPF tAO Instructions tAF Else - tAO décalage et aller à l'état 116 - tIF décalage et aller à l'état 117 + tAO shift, and go to state 117 + tIF shift, and go to state 118 -État 115 +state 116 - 39 If: tIF tPO Cond tPF $@1 tAO Instructions tAF $@2 Else . + 39 If: tIF tPO Cond tPF @1 tAO Instructions tAF @2 Else . - $défaut réduction par utilisation de la règle 39 (If) + $default reduce using rule 39 (If) -État 116 +state 117 40 Else: tELSE tAO . Instructions 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 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 - $défaut réduction par utilisation de la règle 9 (Instructions) + $default reduce using rule 9 (Instructions) - Instructions aller à l'état 118 - 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 + Instructions go to state 119 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 117 +state 118 42 Else: tELSE tIF . tPO Cond tPF tAO Instructions tAF Else - tPO décalage et aller à l'état 119 + tPO shift, and go to state 120 -État 118 +state 119 40 Else: tELSE tAO Instructions . tAF - tAF décalage et aller à l'état 120 + tAF shift, and go to state 121 -État 119 +state 120 42 Else: tELSE tIF tPO . Cond tPF tAO Instructions tAF Else - tENTIER décalage et aller à l'état 46 - tSUB décalage et aller à l'état 47 - tPO décalage et aller à l'état 48 - tVAR décalage et aller à l'état 49 - tNOT décalage et aller à l'état 50 + tENTIER shift, and go to state 45 + tSUB shift, and go to state 46 + tPO shift, and go to state 47 + tVAR shift, and go to state 48 + tNOT shift, and go to state 51 - E aller à l'état 51 - Cond aller à l'état 121 - Invocation aller à l'état 53 + E go to state 52 + Cond go to state 122 + Invocation go to state 50 -État 120 +state 121 40 Else: tELSE tAO Instructions tAF . - $défaut réduction par utilisation de la règle 40 (Else) + $default reduce using rule 40 (Else) -État 121 +state 122 42 Else: tELSE tIF tPO Cond . tPF tAO Instructions tAF Else - tPF décalage et aller à l'état 122 + tPF shift, and go to state 123 -État 122 +state 123 42 Else: tELSE tIF tPO Cond tPF . tAO Instructions tAF Else - tAO décalage et aller à l'état 123 + tAO shift, and go to state 124 -État 123 +state 124 42 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 + tINT shift, and go to state 16 + tPRINT shift, and go to state 17 + tIF shift, and go to state 18 + tWHILE shift, and go to state 19 + tCONST shift, and go to state 20 + tVAR shift, and go to state 21 - $défaut réduction par utilisation de la règle 9 (Instructions) + $default reduce using rule 9 (Instructions) - Instructions aller à l'état 124 - 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 + Instructions go to state 125 + Instruction go to state 23 + Decl go to state 24 + Type go to state 25 + Aff go to state 26 + If go to state 27 + While go to state 28 + Invocation go to state 29 + Print go to state 30 -État 124 +state 125 42 Else: tELSE tIF tPO Cond tPF tAO Instructions . tAF Else - tAF décalage et aller à l'état 125 + tAF shift, and go to state 126 -État 125 +state 126 42 Else: tELSE tIF tPO Cond tPF tAO Instructions tAF . Else - tELSE décalage et aller à l'état 114 + tELSE shift, and go to state 115 - $défaut réduction par utilisation de la règle 41 (Else) + $default reduce using rule 41 (Else) - Else aller à l'état 126 + Else go to state 127 -État 126 +state 127 42 Else: tELSE tIF tPO Cond tPF tAO Instructions tAF Else . - $défaut réduction par utilisation de la règle 42 (Else) + $default reduce using rule 42 (Else) diff --git a/analyse_syntaxique.tab.c b/analyse_syntaxique.tab.c index 8d2a56d..03b3db8 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,95 @@ /* 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, + 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 +/* 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 tPV 269 +#define tVIRGULE 270 +#define tAFFECTATION 271 +#define tEGAL 272 +#define tDIFF 273 +#define tLT 274 +#define tGT 275 +#define tGTE 276 +#define tLTE 277 +#define tMAIN 278 +#define tINT 279 +#define tPRINT 280 +#define tRETURN 281 +#define tOR 282 +#define tAND 283 +#define tIF 284 +#define tELSE 285 +#define tWHILE 286 +#define tCONST 287 +#define tVAR 288 +#define tNOT 289 /* 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,85 +153,30 @@ # 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 170 "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" @@ -169,8 +186,11 @@ enum Initialised_Variable init; enum Symbole_Type type; Table_Symboles table; instructions_array array; +int whileCondition; -#line 174 "analyse_syntaxique.tab.c" /* yacc.c:358 */ + +/* Line 216 of yacc.c. */ +#line 194 "analyse_syntaxique.tab.c" #ifdef short # undef short @@ -184,8 +204,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 @@ -205,7 +228,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 @@ -219,67 +243,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 @@ -298,11 +293,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 @@ -310,8 +305,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 @@ -325,23 +320,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 @@ -351,14 +348,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) @@ -369,70 +366,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 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 134 +#define YYLAST 137 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 35 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 25 +#define YYNNTS 26 /* YYNRULES -- Number of rules. */ -#define YYNRULES 57 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 127 +#define YYNRULES 58 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 128 -/* 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 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, @@ -467,19 +458,56 @@ static const yytype_uint8 yytranslate[] = }; #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, 10, 11, 14, 17, 22, 23, 28, + 31, 32, 34, 36, 38, 40, 42, 45, 50, 54, + 55, 57, 60, 64, 66, 71, 73, 75, 79, 83, + 87, 91, 94, 96, 100, 103, 104, 108, 109, 110, + 111, 122, 127, 128, 138, 139, 148, 152, 156, 160, + 164, 168, 172, 176, 180, 183, 185, 190, 196 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 36, 0, -1, 24, 23, 9, 37, 10, 40, -1, + -1, 38, 39, -1, 24, 33, -1, 15, 38, 39, + 14, -1, -1, 11, 41, 60, 12, -1, 42, 41, + -1, -1, 47, -1, 51, -1, 55, -1, 59, -1, + 43, -1, 58, 14, -1, 45, 46, 44, 14, -1, + 15, 46, 44, -1, -1, 24, -1, 32, 24, -1, + 33, 16, 48, -1, 33, -1, 33, 16, 48, 14, + -1, 3, -1, 33, -1, 48, 5, 48, -1, 48, + 7, 48, -1, 48, 6, 48, -1, 48, 8, 48, + -1, 6, 48, -1, 58, -1, 9, 48, 10, -1, + 33, 50, -1, -1, 15, 33, 50, -1, -1, -1, + -1, 29, 9, 57, 10, 52, 11, 41, 12, 53, + 54, -1, 30, 11, 41, 12, -1, -1, 30, 29, + 9, 57, 10, 11, 41, 12, 54, -1, -1, 31, + 9, 57, 10, 56, 11, 41, 12, -1, 48, 17, + 48, -1, 48, 18, 48, -1, 48, 19, 48, -1, + 48, 20, 48, -1, 48, 22, 48, -1, 48, 21, + 48, -1, 48, 28, 48, -1, 48, 27, 48, -1, + 34, 57, -1, 48, -1, 33, 9, 49, 10, -1, + 25, 9, 48, 10, 14, -1, 26, 48, 14, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 75, 75, 77, 78, 80, 83, 84, 87, 89, - 90, 92, 93, 94, 95, 96, 97, 99, 101, 102, - 104, 105, 107, 108, 111, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 124, 125, 127, 128, 130, 135, - 130, 141, 142, 143, 145, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 158, 160, 162 + 0, 77, 77, 79, 80, 82, 85, 86, 89, 91, + 92, 94, 95, 96, 97, 98, 99, 101, 103, 104, + 106, 107, 109, 110, 113, 116, 118, 120, 121, 122, + 123, 124, 125, 126, 129, 130, 132, 133, 135, 142, + 135, 148, 149, 150, 155, 155, 169, 170, 171, 172, + 173, 174, 175, 176, 177, 178, 182, 185, 188 }; #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[] = @@ -491,13 +519,14 @@ static const char *const yytname[] = "tCONST", "tVAR", "tNOT", "$accept", "Main", "Params", "Param", "SuiteParams", "Body", "Instructions", "Instruction", "Decl", "SuiteDecl", "Type", "Valeur", "Aff", "E", "Args", "SuiteArgs", "If", - "$@1", "$@2", "Else", "While", "Cond", "Invocation", "Print", "Return", YY_NULLPTR + "@1", "@2", "Else", "While", "@3", "Cond", "Invocation", "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, @@ -507,186 +536,233 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -34 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-34))) - -#define YYTABLE_NINF -1 - -#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[] = -{ - -18, -14, 22, 35, -34, 8, 12, 49, 45, -34, - 51, 8, -34, 47, -34, 45, -34, 52, 60, 61, - 53, -8, 55, 47, -34, 42, -34, -34, -34, 68, - -34, 70, 54, 15, 15, -34, 56, 17, 17, 73, - -34, 74, 77, -34, -34, 83, -34, 17, 17, 92, - 15, 46, 90, -34, 94, 96, 102, 91, 101, -34, - 17, 42, 99, 100, 9, 23, -34, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 15, 15, -34, - 105, 84, -34, -34, -34, -34, 50, 77, -34, -34, - -34, 5, 9, 110, -34, 50, 50, 50, 50, 50, - 50, -34, -34, 108, 47, 96, -34, 47, 109, -34, - 111, -34, -34, 95, -4, -34, 47, 113, 112, 15, - -34, 116, 117, 47, 115, 95, -34 -}; - - /* 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. */ -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, 0, 21, 35, 0, 0, 0, - 9, 23, 19, 16, 6, 0, 25, 0, 0, 26, - 0, 54, 0, 32, 0, 37, 0, 0, 0, 8, - 0, 0, 0, 0, 31, 0, 53, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, - 0, 0, 34, 55, 24, 57, 22, 19, 17, 56, - 33, 27, 29, 28, 30, 45, 46, 47, 48, 50, - 49, 52, 51, 0, 10, 37, 18, 10, 0, 36, - 0, 44, 39, 42, 0, 40, 10, 0, 0, 0, - 41, 0, 0, 10, 0, 42, 43 -}; - - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -34, -34, -34, 118, 119, -34, -21, -34, -34, 33, - -34, 69, -34, -33, -34, 26, -34, -34, -34, 7, - -34, -31, -13, -34, -34 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 2, 7, 8, 12, 14, 22, 23, 24, 62, - 25, 42, 26, 51, 56, 82, 27, 103, 113, 115, - 28, 52, 53, 30, 39 -}; - - /* 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. */ -static const yytype_uint8 yytable[] = -{ - 29, 36, 40, 54, 57, 58, 1, 116, 37, 3, - 29, 68, 69, 70, 64, 65, 69, 70, 46, 66, - 46, 47, 4, 47, 48, 117, 48, 86, 67, 68, - 69, 70, 6, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 5, 9, 101, 102, 49, 50, - 49, 67, 68, 69, 70, 67, 68, 69, 70, 10, - 11, 32, 13, 71, 72, 73, 74, 75, 76, 33, - 34, 16, 17, 77, 78, 41, 18, 35, 19, 20, - 21, 38, 43, 108, 44, 59, 110, 45, 121, 55, - 60, 29, 61, 63, 29, 118, 67, 68, 69, 70, - 79, 36, 124, 29, 80, 84, 67, 68, 69, 70, - 29, 81, 83, 88, 89, 85, 104, 105, 70, 107, - 106, 111, 119, 112, 120, 114, 122, 125, 123, 15, - 87, 109, 126, 0, 31 -}; - -static const yytype_int8 yycheck[] = -{ - 13, 9, 23, 34, 37, 38, 24, 11, 16, 23, - 23, 6, 7, 8, 47, 48, 7, 8, 3, 50, - 3, 6, 0, 6, 9, 29, 9, 60, 5, 6, - 7, 8, 24, 10, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 9, 33, 77, 78, 33, 34, - 33, 5, 6, 7, 8, 5, 6, 7, 8, 10, - 15, 9, 11, 17, 18, 19, 20, 21, 22, 9, - 9, 24, 25, 27, 28, 33, 29, 24, 31, 32, - 33, 26, 14, 104, 14, 12, 107, 33, 119, 33, - 16, 104, 15, 10, 107, 116, 5, 6, 7, 8, - 10, 9, 123, 116, 10, 14, 5, 6, 7, 8, - 123, 15, 10, 14, 14, 14, 11, 33, 8, 11, - 87, 12, 9, 12, 12, 30, 10, 12, 11, 11, - 61, 105, 125, -1, 15 -}; - - /* 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, 47, 51, 55, 57, - 58, 39, 9, 9, 9, 24, 9, 16, 26, 59, - 41, 33, 46, 14, 14, 33, 3, 6, 9, 33, - 34, 48, 56, 57, 56, 33, 49, 48, 48, 12, - 16, 15, 44, 10, 48, 48, 56, 5, 6, 7, - 8, 17, 18, 19, 20, 21, 22, 27, 28, 10, - 10, 15, 50, 10, 14, 14, 48, 46, 14, 14, - 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 56, 56, 52, 11, 33, 44, 11, 41, 50, - 41, 12, 12, 53, 30, 54, 11, 29, 41, 9, - 12, 56, 10, 11, 41, 12, 54 -}; - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +/* 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, 46, 46, 47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 50, 50, 52, 53, - 51, 54, 54, 54, 55, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 57, 58, 59 + 51, 54, 54, 54, 56, 55, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 58, 59, 60 }; - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +/* YYR2[YYN] -- Number of symbols composing 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, 3, 1, 4, 1, 1, 3, 3, 3, 3, 2, 1, 3, 2, 0, 3, 0, 0, 0, - 10, 4, 0, 9, 7, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 4, 5, 3 + 10, 4, 0, 9, 0, 8, 3, 3, 3, 3, + 3, 3, 3, 3, 2, 1, 4, 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, 0, 21, 35, 0, 0, 0, + 9, 23, 19, 16, 6, 25, 0, 0, 26, 0, + 32, 0, 55, 0, 0, 37, 0, 0, 0, 8, + 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, + 54, 0, 0, 0, 0, 0, 0, 0, 0, 38, + 44, 0, 34, 56, 24, 58, 22, 19, 17, 33, + 27, 29, 28, 30, 57, 46, 47, 48, 49, 51, + 50, 53, 52, 0, 0, 37, 18, 10, 10, 36, + 0, 0, 39, 45, 42, 0, 40, 10, 0, 0, + 0, 41, 0, 0, 10, 0, 42, 43 +}; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 7, 8, 12, 14, 22, 23, 24, 62, + 25, 42, 26, 52, 56, 82, 27, 103, 114, 116, + 28, 104, 53, 50, 30, 39 +}; -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -32 +static const yytype_int8 yypact[] = +{ + -9, 2, 23, 17, -32, 4, -4, 27, 29, -32, + 34, 4, -32, 51, -32, 29, -32, 56, 57, 64, + 39, 0, 48, 51, -32, 46, -32, -32, -32, 67, + -32, 71, 21, 5, 5, -32, 55, 21, 21, 86, + -32, 81, 87, -32, -32, -32, 21, 21, 91, 26, + -32, 5, 50, 99, 102, 95, 103, 85, 100, -32, + 21, 46, 105, 10, 54, 21, 21, 21, 21, 106, + -32, 21, 21, 21, 21, 21, 21, 21, 21, -32, + -32, 68, -32, -32, -32, -32, 110, 87, -32, -32, + -2, 10, 113, -32, -32, 110, 110, 110, 110, 110, + 110, 110, 110, 111, 112, 95, -32, 51, 51, -32, + 114, 115, -32, -32, 94, -10, -32, 51, 116, 117, + 5, -32, 118, 119, 51, 120, 94, -32 +}; +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -32, -32, -32, 122, 121, -32, -21, -32, -32, 44, + -32, 73, -32, -25, -32, 30, -32, -32, -32, 11, + -32, -32, -31, -13, -32, -32 +}; + +/* 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 -1 +static const yytype_uint8 yytable[] = +{ + 29, 117, 40, 54, 66, 67, 68, 49, 45, 36, + 29, 46, 57, 58, 47, 1, 37, 67, 68, 118, + 70, 63, 64, 4, 45, 3, 5, 46, 6, 9, + 47, 65, 66, 67, 68, 86, 69, 10, 48, 51, + 90, 91, 92, 93, 11, 13, 95, 96, 97, 98, + 99, 100, 101, 102, 48, 65, 66, 67, 68, 65, + 66, 67, 68, 35, 89, 32, 33, 71, 72, 73, + 74, 75, 76, 34, 38, 16, 17, 77, 78, 41, + 18, 43, 19, 20, 21, 44, 110, 111, 55, 122, + 65, 66, 67, 68, 29, 29, 119, 60, 59, 84, + 36, 105, 61, 125, 29, 65, 66, 67, 68, 79, + 81, 29, 80, 83, 85, 65, 66, 67, 68, 88, + 94, 68, 107, 108, 115, 120, 112, 113, 123, 121, + 124, 106, 126, 15, 87, 109, 31, 127 +}; + +static const yytype_uint8 yycheck[] = +{ + 13, 11, 23, 34, 6, 7, 8, 32, 3, 9, + 23, 6, 37, 38, 9, 24, 16, 7, 8, 29, + 51, 46, 47, 0, 3, 23, 9, 6, 24, 33, + 9, 5, 6, 7, 8, 60, 10, 10, 33, 34, + 65, 66, 67, 68, 15, 11, 71, 72, 73, 74, + 75, 76, 77, 78, 33, 5, 6, 7, 8, 5, + 6, 7, 8, 24, 10, 9, 9, 17, 18, 19, + 20, 21, 22, 9, 26, 24, 25, 27, 28, 33, + 29, 14, 31, 32, 33, 14, 107, 108, 33, 120, + 5, 6, 7, 8, 107, 108, 117, 16, 12, 14, + 9, 33, 15, 124, 117, 5, 6, 7, 8, 10, + 15, 124, 10, 10, 14, 5, 6, 7, 8, 14, + 14, 8, 11, 11, 30, 9, 12, 12, 10, 12, + 11, 87, 12, 11, 61, 105, 15, 126 +}; + +/* 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, 47, 51, 55, 58, + 59, 39, 9, 9, 9, 24, 9, 16, 26, 60, + 41, 33, 46, 14, 14, 3, 6, 9, 33, 48, + 58, 34, 48, 57, 57, 33, 49, 48, 48, 12, + 16, 15, 44, 48, 48, 5, 6, 7, 8, 10, + 57, 17, 18, 19, 20, 21, 22, 27, 28, 10, + 10, 15, 50, 10, 14, 14, 48, 46, 14, 10, + 48, 48, 48, 48, 14, 48, 48, 48, 48, 48, + 48, 48, 48, 52, 56, 33, 44, 11, 11, 50, + 41, 41, 12, 12, 53, 30, 54, 11, 29, 41, + 9, 12, 57, 10, 11, 41, 12, 54 +}; + +#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 @@ -696,46 +772,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; + } } @@ -743,11 +827,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, ")"); @@ -758,54 +853,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. */ @@ -819,7 +926,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -834,6 +941,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -842,8 +950,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++) @@ -859,8 +974,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; @@ -890,27 +1013,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: ; } @@ -921,209 +1044,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]; @@ -1131,22 +1256,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; /*------------------------------------------------------------. @@ -1167,23 +1324,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 @@ -1191,22 +1350,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 */ @@ -1214,18 +1374,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; /*-----------. @@ -1234,20 +1392,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) @@ -1269,27 +1427,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; @@ -1312,7 +1472,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 @@ -1326,242 +1486,218 @@ yyreduce: switch (yyn) { case 2: -#line 75 "analyse_syntaxique.y" /* yacc.c:1646 */ - {} -#line 1332 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 77 "analyse_syntaxique.y" + {;} break; case 3: -#line 77 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Sans params\n");} -#line 1338 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 79 "analyse_syntaxique.y" + {printf("Sans params\n");;} break; case 5: -#line 80 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Parametre : %s\n", (yyvsp[0].id));} -#line 1344 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 82 "analyse_syntaxique.y" + {printf("Parametre : %s\n", (yyvsp[(2) - (2)].id));;} break; case 8: -#line 87 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans body\n");} -#line 1350 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 89 "analyse_syntaxique.y" + {printf("Dans body\n");;} break; case 20: -#line 104 "analyse_syntaxique.y" /* yacc.c:1646 */ - {type = TYPE_INT;} -#line 1356 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 106 "analyse_syntaxique.y" + {type = TYPE_INT;;} break; case 21: -#line 105 "analyse_syntaxique.y" /* yacc.c:1646 */ - {type = TYPE_CONST_INT;} -#line 1362 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 107 "analyse_syntaxique.y" + {type = TYPE_CONST_INT;;} break; case 22: -#line 107 "analyse_syntaxique.y" /* yacc.c:1646 */ - {add_symbole_top(&table, (yyvsp[-2].id), type, INITIALISED, table.depth); free_temp(&table);} -#line 1368 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 109 "analyse_syntaxique.y" + {add_symbole_top(&table, (yyvsp[(1) - (3)].id), type, INITIALISED, table.depth); free_temp(&table);;} break; case 23: -#line 108 "analyse_syntaxique.y" /* yacc.c:1646 */ - {add_symbole_top(&table, (yyvsp[0].id), type, NOT_INITIALISED, table.depth);} -#line 1374 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 110 "analyse_syntaxique.y" + {add_symbole_top(&table, (yyvsp[(1) - (1)].id), type, NOT_INITIALISED, table.depth);;} break; case 24: -#line 111 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Affectation : %s\n", (yyvsp[-3].id)); free_temp(&table);} -#line 1380 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 113 "analyse_syntaxique.y" + {printf("Affectation : %s\n", (yyvsp[(1) - (4)].id)); free_temp(&table);;} break; case 25: -#line 113 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int vt = gen_entier(&table, &array, (yyvsp[0].nombre)); (yyval.nombre) = vt;} -#line 1386 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 116 "analyse_syntaxique.y" + {int vt = new_temp(&table); generate_instruction_2(&array, AFC, vt, (yyvsp[(1) - (1)].nombre)); (yyval.nombre) = vt;;} break; case 26: -#line 114 "analyse_syntaxique.y" /* yacc.c:1646 */ - {int vt = gen_var(&table, &array, (yyvsp[0].id)); (yyval.nombre) = vt;} -#line 1392 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 118 "analyse_syntaxique.y" + {int vt = new_temp(&table); int varAddr = variable_exists(&table, (yyvsp[(1) - (1)].id)); generate_instruction_2(&array, CPY, vt, varAddr); (yyval.nombre) = vt;;} break; case 27: -#line 115 "analyse_syntaxique.y" /* yacc.c:1646 */ - {gen_arithmetique(&array, ADD, (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1398 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 120 "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 28: -#line 116 "analyse_syntaxique.y" /* yacc.c:1646 */ - {gen_arithmetique(&array, MUL, (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1404 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 121 "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 29: -#line 117 "analyse_syntaxique.y" /* yacc.c:1646 */ - {gen_arithmetique(&array, SOU, (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1410 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 122 "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 30: -#line 118 "analyse_syntaxique.y" /* yacc.c:1646 */ - {gen_arithmetique(&array, DIV, (yyvsp[-2].nombre), (yyvsp[0].nombre)); free_temp(&table); (yyval.nombre) = (yyvsp[-2].nombre);} -#line 1416 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 123 "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 31: -#line 119 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Variable negative\n");} -#line 1422 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 124 "analyse_syntaxique.y" + {printf("Variable negative\n");;} break; case 32: -#line 120 "analyse_syntaxique.y" /* yacc.c:1646 */ - {(yyval.nombre) = 1234;} -#line 1428 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 125 "analyse_syntaxique.y" + {(yyval.nombre) = 1234;;} break; case 33: -#line 121 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Parenthèse\n"); (yyval.nombre) = (yyvsp[-1].nombre); } -#line 1434 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 126 "analyse_syntaxique.y" + {printf("Parenthèse\n"); (yyval.nombre) = (yyvsp[(2) - (3)].nombre); ;} break; case 38: -#line 130 "analyse_syntaxique.y" /* yacc.c:1646 */ +#line 135 "analyse_syntaxique.y" { - gen_jmpf(&table, &array, (yyvsp[-1].nombre)); - (yyvsp[-3].nombre) = array.index; -} -#line 1443 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + //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 39: -#line 135 "analyse_syntaxique.y" /* yacc.c:1646 */ +#line 142 "analyse_syntaxique.y" { int adr_jmp = array.index; - update_jump(&array, (yyvsp[-7].nombre), adr_jmp); -} -#line 1452 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ + update_jmf(&array, (yyvsp[(1) - (8)].nombre), adr_jmp); +;} break; case 40: -#line 139 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans if\n");} -#line 1458 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 146 "analyse_syntaxique.y" + {;} break; case 41: -#line 141 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("else\n");} -#line 1464 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 148 "analyse_syntaxique.y" + {printf("else\n");;} break; case 43: -#line 143 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("elsif\n");} -#line 1470 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 150 "analyse_syntaxique.y" + {printf("elsif\n");;} break; case 44: -#line 145 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans while\n");} -#line 1476 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 155 "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 45: -#line 147 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond ==\n");} -#line 1482 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 161 "analyse_syntaxique.y" + { + int adr_jmp = array.index; + update_jmf(&array, (yyvsp[(1) - (8)].nombre), adr_jmp); + //gen_jmpf(&table, &array, $1, $2); + generate_instruction_1(&array, JMP, (yyvsp[(2) - (8)].nombre)); +;} break; case 46: -#line 148 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond !=\n");} -#line 1488 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 169 "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 47: -#line 149 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond <\n");} -#line 1494 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 170 "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 48: -#line 150 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond >\n");} -#line 1500 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 171 "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 49: -#line 151 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond <=\n");} -#line 1506 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 172 "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 50: -#line 152 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond >=\n");} -#line 1512 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 173 "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 51: -#line 153 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond &&\n");} -#line 1518 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 174 "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 52: -#line 154 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond ||\n");} -#line 1524 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 175 "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 53: -#line 155 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Cond !\n");} -#line 1530 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 176 "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 54: +#line 177 "analyse_syntaxique.y" + {generate_instruction_2(&array, NOT, (yyvsp[(2) - (2)].nombre), (yyvsp[(2) - (2)].nombre)); (yyval.nombre) = (yyvsp[(2) - (2)].nombre);;} break; case 55: -#line 158 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("Dans invocation\n");} -#line 1536 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 178 "analyse_syntaxique.y" + {(yyval.nombre) = (yyvsp[(1) - (1)].nombre); ;} break; case 56: -#line 160 "analyse_syntaxique.y" /* yacc.c:1646 */ - {printf("printf de %s\n", (yyvsp[-2].id));} -#line 1542 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 182 "analyse_syntaxique.y" + {printf("Dans invocation\n");;} break; case 57: -#line 162 "analyse_syntaxique.y" /* yacc.c:1646 */ - {(yyval.nombre)= gen_return(&table, &array, (yyvsp[-1].nombre));} -#line 1548 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +#line 185 "analyse_syntaxique.y" + {generate_instruction_1(&array, PRI, (yyvsp[(3) - (5)].nombre)); free_temp(&table);;} + break; + + case 58: +#line 188 "analyse_syntaxique.y" + {(yyval.nombre) = generate_instruction_1(&array, RET, (yyvsp[(2) - (3)].nombre)); free_temp(&table);;} break; -#line 1552 "analyse_syntaxique.tab.c" /* yacc.c:1646 */ +/* Line 1267 of yacc.c. */ +#line 1699 "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); @@ -1570,7 +1706,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. */ @@ -1585,14 +1722,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) { @@ -1600,36 +1733,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 } @@ -1637,24 +1771,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; @@ -1670,7 +1804,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; @@ -1683,37 +1817,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. */ @@ -1737,7 +1872,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE +#ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1748,22 +1883,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 @@ -1774,9 +1904,12 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 164 "analyse_syntaxique.y" /* yacc.c:1906 */ + + +#line 190 "analyse_syntaxique.y" #include void main(void){ @@ -1787,5 +1920,7 @@ void main(void){ print_table(&table); //remove_symboles(&table, 0); //print_table(&table); + exportInstructions(&array); } + diff --git a/analyse_syntaxique.tab.h b/analyse_syntaxique.tab.h index dd14b4a..a7b15a5 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,97 @@ 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, + 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 +/* 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 tPV 269 +#define tVIRGULE 270 +#define tAFFECTATION 271 +#define tEGAL 272 +#define tDIFF 273 +#define tLT 274 +#define tGT 275 +#define tGTE 276 +#define tLTE 277 +#define tMAIN 278 +#define tINT 279 +#define tPRINT 280 +#define tRETURN 281 +#define tOR 282 +#define tAND 283 +#define tIF 284 +#define tELSE 285 +#define tWHILE 286 +#define tCONST 287 +#define tVAR 288 +#define tNOT 289 + + + -/* 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 122 "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 ce89f36..21a9a90 100644 --- a/analyse_syntaxique.y +++ b/analyse_syntaxique.y @@ -12,6 +12,7 @@ enum Initialised_Variable init; enum Symbole_Type type; Table_Symboles table; instructions_array array; +int whileCondition; %} @@ -23,12 +24,13 @@ instructions_array array; %type Cond + %token tADD %token tSUB %token tMUL %token tDIV -%token tPO +%token tPO %token tPF %token tAO %token tAF @@ -52,7 +54,7 @@ instructions_array array; %token tAND %token tIF %token tELSE -%token tWHILE +%token tWHILE %token tCONST %token tVAR %token tNOT @@ -110,12 +112,15 @@ Valeur : tVAR {add_symbole_top(&table, $1, type, NOT_INITIALISED, table.depth);} Aff : tVAR tAFFECTATION E tPV {printf("Affectation : %s\n", $1); free_temp(&table);}; -E : tENTIER {int vt = gen_entier(&table, &array, $1); $$ = vt;}; -E : tVAR {int vt = gen_var(&table, &array, $1); $$ = vt;}; -E : E tADD E {gen_arithmetique(&array, ADD, $1, $3); free_temp(&table); $$ = $1;} ; -E : E tMUL E {gen_arithmetique(&array, MUL, $1, $3); free_temp(&table); $$ = $1;} ; -E : E tSUB E {gen_arithmetique(&array, SOU, $1, $3); free_temp(&table); $$ = $1;} ; -E : E tDIV E {gen_arithmetique(&array, DIV, $1, $3); free_temp(&table); $$ = $1;} ; +//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, CPY, vt, varAddr); $$ = vt;}; +//E : E tADD E {gen_arithmetique(&array, ADD, $1, $3); free_temp(&table); $$ = $1;} ; +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 : tPO E tPF {printf("Parenthèse\n"); $$ = $2; } ; @@ -128,38 +133,59 @@ SuiteArgs : tVIRGULE tVAR SuiteArgs ; SuiteArgs : ; If : tIF tPO Cond tPF { - gen_jmpf(&table, &array, $3); + //gen_jmpf(&table, &array, $3, -1); + generate_instruction_2(&array, JMF, $3, -1); + free_temp(&table); $1 = array.index; } -tAO Instructions tAF +tAO Instructions tAF { int adr_jmp = array.index; - update_jump(&array, $1, adr_jmp); + update_jmf(&array, $1, adr_jmp); } -Else {printf("Dans if\n");}; +Else {}; Else : tELSE tAO Instructions tAF {printf("else\n");} ; Else : ; Else : tELSE tIF tPO Cond tPF tAO Instructions tAF Else {printf("elsif\n");} ; -While : tWHILE tPO Cond tPF tAO Instructions tAF {printf("Dans while\n");}; +/*While : tWHILE tPO { + $2 = array.index + 1 ; +} Cond tPF {*/ +While : tWHILE 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 { + 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;} ; +Cond : E tGT E {generate_instruction_3(&array, GT, $1, $1, $3); free_temp(&table); $$ = $3;} ; +Cond : E tLTE E {generate_instruction_3(&array, LTE, $1, $1, $3); free_temp(&table); $$ = $3;} ; +Cond : E tGTE E {generate_instruction_3(&array, GTE, $1, $1, $3); free_temp(&table); $$ = $3;} ; +Cond : E tAND E {generate_instruction_3(&array, AND, $1, $1, $3); free_temp(&table); $$ = $3;} ; +Cond : E tOR E {generate_instruction_3(&array, OR, $1, $1, $3); free_temp(&table); $$ = $3;} ; +Cond : tNOT Cond {generate_instruction_2(&array, NOT, $2, $2); $$ = $2;} ; +Cond : E {$$ = $1; }; + -Cond : E tEGAL E {printf("Cond ==\n");} ; -Cond : E tDIFF E {printf("Cond !=\n");} ; -Cond : E tLT E {printf("Cond <\n");} ; -Cond : E tGT E {printf("Cond >\n");} ; -Cond : E tLTE E {printf("Cond <=\n");} ; -Cond : E tGTE E{printf("Cond >=\n");} ; -Cond : E tAND Cond {printf("Cond &&\n");} ; -Cond : E tOR Cond {printf("Cond ||\n");} ; -Cond : tNOT Cond {printf("Cond !\n");} ; -Cond : E; Invocation : tVAR tPO Args tPF {printf("Dans invocation\n");}; -Print : tPRINT tPO tVAR tPF tPV {printf("printf de %s\n", $3);}; +//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 {$$ = gen_return(&table, &array, $2);}; +Return : tRETURN E tPV {$$ = generate_instruction_1(&array, RET, $2); free_temp(&table);}; %% #include @@ -171,5 +197,6 @@ void main(void){ print_table(&table); //remove_symboles(&table, 0); //print_table(&table); + exportInstructions(&array); } diff --git a/gen_assembleur.c b/gen_assembleur.c index fb64c2c..ba21ee4 100644 --- a/gen_assembleur.c +++ b/gen_assembleur.c @@ -1,54 +1,210 @@ #include "gen_assembleur.h" +#include +#include +char * operationName(enum operation op){ + switch(op){ + case EQ: + return "EQ"; + case NEQ: + return "NEQ"; + case LT: + return "LT"; + case GT: + return "GT"; + case LTE: + return "LTE"; + case GTE: + return "GTE"; + case ADD: + return "ADD"; + case SOU: + return "SOU"; + case DIV: + return "DIV"; + case MUL: + return "MUL"; + case CPY: + return "CPY"; + case AFC: + return "AFC"; + case RET: + return "RET"; + case JMF: + return "JPF"; + case JMP: + return "JPM"; + case AND: + return "AND"; + case OR: + return "OR"; + case NOT: + return "NOT"; + case PRI: + return "PRI"; + default: + break; + } + return ""; +} + +void initialise_asm(instructions_array * array){ + array->index = 0; +} + +int add_instruction(instructions_array * array, instruction * instru){ + if (array->index >= INSTRUCTION_TABLE_SIZE){ + return 1; + } + array->array[array->index] = *instru; + array->index++; + + return 0; +} int new_temp(Table_Symboles * table){ int ret_addr ; if(add_symbole_bottom(table) == -1) { return -1; } - ret_addr = table->indexAvailableBottom +1; + ret_addr = table->indexAvailableBottom + 1; return ret_addr; } -void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2){ +int generate_instruction_1(instructions_array * array, enum operation op, int arg1){ instruction instru; - switch(op){ - case ADD: - instru.operation = ADD; - instru.reg1 = arg1; - instru.reg2 = arg1; - instru.reg3 = arg2; - printf("%d ADD %d %d %d\n", array->index, arg1, arg1, arg2); - break; - case DIV: - instru.operation = DIV; - instru.reg1 = arg1; - instru.reg2 = arg1; - instru.reg3 = arg2; - printf("%d DIV %d %d %d\n", array->index, arg1, arg1, arg2); - break; - case SOU: - instru.operation = SOU; - instru.reg1 = arg1; - instru.reg2 = arg1; - instru.reg3 = arg2; - printf("%d SOU %d %d %d\n", array->index, arg1, arg1, arg2); - break; - case MUL: - instru.operation = MUL; - instru.reg1 = arg1; - instru.reg2 = arg1; - instru.reg3 = arg2; - printf("%d MUL %d %d %d\n", array->index, arg1, arg1, arg2); - break; - default: - break; - } + char * opName = operationName(op); + + instru.operation = op; + instru.reg1 = arg1; + + printf("%d\t %s %d\n", array->index, opName, instru.reg1); + + if (add_instruction(array, &instru) != 0){ + //TODO: Error handling + exit(1); + } + + return 0; +} + +int generate_instruction_2(instructions_array * array, enum operation op, int arg1, int arg2){ + instruction instru; + char * opName = operationName(op); + + instru.operation = op; + instru.reg1 = arg1; + instru.reg2 = arg2; + + printf("%d\t %s %d %d\n", array->index, opName, instru.reg1, instru.reg2); + + if (add_instruction(array, &instru) != 0){ + //TODO: Error handling + exit(1); + } + + return 0; +} + +int generate_instruction_3(instructions_array * array, enum operation op, int arg1, int arg2, int arg3){ + instruction instru; + char * opName = operationName(op); + + instru.operation = op; + instru.reg1 = arg1; + instru.reg2 = arg2; + instru.reg3 = arg3; + + printf("%d\t %s %d %d %d\n", array->index, opName, instru.reg1, instru.reg2, instru.reg3); + + if (add_instruction(array, &instru) != 0){ + //TODO: Error handling + exit(1); + } + + return 0; +} + +void update_jmf(instructions_array * array, int instru_index, int adr_jmp){ + array->array[instru_index - 1].reg2 = adr_jmp; + printf("%d\t JMP %d %d\n", (instru_index - 1), array->array[instru_index].reg1, array->array[instru_index].reg2); +} + +void exportInstructions(instructions_array * array){ + FILE *file; + file = fopen("instructions.txt", "w"); + instruction instru; + enum operation op; + + for (int i = 0; i < array->index; i++){ + instru = array->array[i]; + op = instru.operation; + switch (op) { + //1 parameter + case JMP: + case PRI: + case RET: + fprintf(file, "%d\t %s %d\n", i, operationName(op), instru.reg1); + break; + //2 parameters + case JMF: + case NOT: + case AFC: + case CPY: + fprintf(file, "%d\t %s %d %d\n", i, operationName(op), instru.reg1, instru.reg2); + break; + //3 parameters + case ADD: + case SOU: + case DIV: + case MUL: + case AND: + case OR: + case EQ: + case NEQ: + case LT: + case LTE: + case GT: + case GTE: + fprintf(file, "%d\t %s %d %d %d\n", i, operationName(op), instru.reg1, instru.reg2, instru.reg3); + break; + default: + break; + } + } + + fclose(file); +} + +/*int gen_print(Table_Symboles * table, instructions_array * array, int arg1){ + instruction instru; + instru.operation = PRI; + instru.reg1 = arg1; + + printf("%d\t PRI %d\n", array->index, instru.reg1); + if (array->index < INSTRUCTION_TABLE_SIZE){ array->array[array->index] = instru; array->index++; } - + + free_temp(table); +}*/ + +/*void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2){ + instruction instru; + instru.reg1 = arg1; + instru.reg2 = arg1; + instru.reg3 = arg2; + + char * opName = operationName(op); + printf("%d\t %s %d %d %d\n", array->index, opName, arg1, arg1, arg2); + + if (array->index < INSTRUCTION_TABLE_SIZE){ + array->array[array->index] = instru; + array->index++; + } + } int gen_var(Table_Symboles * table, instructions_array * array, char * varName){ @@ -59,9 +215,9 @@ int gen_var(Table_Symboles * table, instructions_array * array, char * varName){ instruction instru; instru.operation = CPY; instru.reg1 = vt; - instru.reg2 = varAddr; + instru.reg2 = varAddr; - printf("%d CPY %d %d\n", array->index, vt, varAddr); + printf("%d\t CPY %d %d\n", array->index, vt, varAddr); if (array->index < INSTRUCTION_TABLE_SIZE){ array->array[array->index] = instru; @@ -79,9 +235,9 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier){ instruction instru; instru.operation = AFC; instru.reg1 = vt; - instru.reg2 = entier; + instru.reg2 = entier; - printf("%d AFC %d %d\n", array->index, vt, entier); + printf("%d\t AFC %d %d\n", array->index, vt, entier); if (array->index < INSTRUCTION_TABLE_SIZE){ array->array[array->index] = instru; @@ -91,6 +247,30 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier){ return vt; } +int gen_condition(Table_Symboles * table, instructions_array * array, enum operation op, int arg1, int arg2){ + + char * opName = operationName(op); + + instruction instru; + instru.operation = op; + instru.reg1 = arg1; + instru.reg2 = arg1; + if (op != NOT){ + instru.reg3 = arg2; + printf("%d\t %s %d %d %d\n", array->index, opName, instru.reg1, instru.reg2, instru.reg3); + free_temp(table); + } else { + printf("%d\t %s %d %d \n", array->index, opName, instru.reg1, instru.reg2); + } + + if (array->index < INSTRUCTION_TABLE_SIZE){ + array->array[array->index] = instru; + array->index++; + } + + return instru.reg1; +} + int gen_return(Table_Symboles * table, instructions_array * array, int adr){ //vérifier que non null @@ -98,42 +278,37 @@ int gen_return(Table_Symboles * table, instructions_array * array, int adr){ instru.operation = RET; instru.reg1 = adr; - printf("%d RET %d\n", array->index, adr); + printf("%d\t RET %d\n", array->index, adr); if (array->index < INSTRUCTION_TABLE_SIZE){ array->array[array->index] = instru; array->index++; } - free_temp(table); + //free_temp(table); return adr; } -int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond){ +int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond, int dest){ //vérifier que non null instruction instru; - instru.operation = JMPF; + instru.operation = JMF; instru.reg1 = cond; - instru.reg2 = -1; + instru.reg2 = dest; - printf("%d JMPF %d %d\n", array->index, cond, -1); + printf("%d\t JMPF %d %d\n", array->index, instru.reg1 , instru.reg2); if (array->index < INSTRUCTION_TABLE_SIZE){ array->array[array->index] = instru; array->index++; } - free_temp(table); + //free_temp(table); return cond; } -void update_jump(instructions_array * array, int if_value, int adr_jmp){ - array->array[if_value].reg2 = adr_jmp; - printf("%d JMPF %d %d\n", array->index, array->array[if_value].reg1, array->array[if_value].reg2); -} + */ + -void initialise_asm(instructions_array * array){ - array->index = 0; -} \ No newline at end of file diff --git a/gen_assembleur.h b/gen_assembleur.h index 83b642d..d7cd8cb 100644 --- a/gen_assembleur.h +++ b/gen_assembleur.h @@ -5,7 +5,7 @@ #include "table_symboles.h" -enum operation{ADD, SOU, MUL, DIV, CPY, AFC, RET, JMPF}; +enum operation{ADD, SOU, MUL, DIV, CPY, AFC, RET, JMF, JMP, EQ, NEQ, LT, GT, LTE, GTE, AND, OR, NOT, PRI}; typedef struct instruction{ enum operation operation; @@ -20,8 +20,80 @@ typedef struct instructions_array{ int index; } instructions_array; +/** + * + * @param op operation + * @return returns the string that corresponds to the enum operation op + */ +char * operationName(enum operation op); + +/** + * Initialises the instructions array + * @param array + */ +void initialise_asm(instructions_array * array); + +//renvoie l'index (ou valeur?) de la premiere @ dispo +/** + * Fetch address of a temporary variable + * @param table + * @return first available temp address + */ +int new_temp(Table_Symboles * table); + +/** + * Adds intruction to instruction array + * @param array + * @param intru + * @return 0 if instruction was added successfully, -1 if not + */ +int add_instruction(instructions_array * array, instruction * intru); + +/** + * Generates intruction with one parameter + * @param array + * @param op + * @param arg1 + * @return + */ +int generate_instruction_1(instructions_array * array, enum operation op, int arg1); + +/** + * Generates intruction with two parameters + * @param array + * @param op + * @param arg1 + * @param arg2 + * @return + */ +int generate_instruction_2(instructions_array * array, enum operation op, int arg1, int arg2); + +/** + * Generates intruction with three parameters + * @param array + * @param op + * @param arg1 + * @param arg2 + * @param arg3 + * @return + */ +int generate_instruction_3(instructions_array * array, enum operation op, int arg1, int arg2, int arg3); + +/** + * Updates the JMF instruction with the correct jump destination address + * @param array + * @param instru_index + * @param adr_jmp + */ +void update_jmf(instructions_array * array, int instru_index, int adr_jmp); + + + +void exportInstructions(instructions_array * array); + +/* void gen_arithmetique(instructions_array * array, enum operation op, int arg1, int arg2); int gen_var(Table_Symboles * table, instructions_array * array, char * varName); @@ -30,11 +102,10 @@ int gen_entier(Table_Symboles * table, instructions_array * array, int entier); int gen_return(Table_Symboles * table, instructions_array * array, int adr); -int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond); +int gen_jmpf(Table_Symboles * table, instructions_array * array, int cond, int dest); -void update_jump(instructions_array * array, int if_value, int adr_jmp); - -//renvoie l'index (ou valeur?) de la premiere @ dispo -int new_temp(Table_Symboles * table); +int gen_condition(Table_Symboles * table, instructions_array * array, enum operation op, int arg1, int arg2); +int gen_print(Table_Symboles * table, instructions_array * array, int arg1); + */ #endif \ No newline at end of file diff --git a/instructions.txt b/instructions.txt new file mode 100644 index 0000000..05cf9a1 --- /dev/null +++ b/instructions.txt @@ -0,0 +1,15 @@ +0 AFC 49 1 +1 AFC 49 2 +2 AFC 48 3 +3 ADD 49 49 48 +4 AFC 49 4 +5 CPY 49 1 +6 NOT 49 49 +7 JPF 49 10 +8 AFC 49 1 +9 AFC 49 4 +10 JPM 4 +11 CPY 49 1 +12 PRI 49 +13 AFC 49 5 +14 RET 49 diff --git a/lex.yy.c b/lex.yy.c index e880035..bdcb483 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,78 +284,82 @@ 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 /* This struct is not used in this scanner, @@ -360,7 +369,7 @@ 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, @@ -371,7 +380,7 @@ static const flex_int16_t yy_accept[70] = 33, 33, 30, 33, 33, 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 53 "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 ); @@ -937,7 +936,7 @@ YY_RULE_SETUP #line 98 "analyse_lexicale.lex" ECHO; YY_BREAK -#line 941 "lex.yy.c" +#line 940 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1015,7 +1014,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 +1067,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 +1078,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 +1109,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 +1122,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 +1145,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 +1177,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 +1191,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 +1212,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 +1229,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 +1244,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 +1257,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 +1277,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 +1289,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 +1302,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 +1326,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 +1343,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 +1387,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 +1419,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 +1447,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 +1456,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 +1481,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 +1499,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 +1542,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 +1573,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 +1592,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 +1610,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 +1627,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 +1647,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 +1657,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 +1686,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 +1716,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 +1732,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 +1762,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) */ int yyget_lineno (void) { - + return yylineno; } @@ -1792,7 +1785,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 +1800,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 +1830,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 +1841,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 +1853,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 +1869,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 +1890,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 +1911,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,12 +1923,12 @@ 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" @@ -1945,6 +1936,7 @@ void yyfree (void * ptr ) #line 98 "analyse_lexicale.lex" + //int main(void){ // yylex(); //} diff --git a/script.sh b/script.sh index d11fc0a..92f4a92 100755 --- a/script.sh +++ b/script.sh @@ -6,9 +6,11 @@ echo " const int var1 = 1, var2; int var2 = 2 + 3; int var3, var4 = 4; - if( 4){ - var2 = 6; + while (!var2){ + var2 = 1; + var3 = 4; } + printf(var2); return 5; } " | ./a.out \ No newline at end of file