Browse Source

Analyse grammaticale OK

Foussats Morgane 3 years ago
parent
commit
6ab787820b
14 changed files with 6733 additions and 1115 deletions
  1. BIN
      a.out
  2. 18
    7
      analyse_lexicale.lex
  3. 822
    788
      analyse_syntaxique.output
  4. 351
    140
      analyse_syntaxique.tab.c
  5. 33
    31
      analyse_syntaxique.tab.h
  6. 73
    34
      analyse_syntaxique.y
  7. 95
    93
      lex.yy.c
  8. 64
    0
      poubelle/as.y
  9. 1956
    0
      poubelle/lex.yy.c
  10. 0
    0
      poubelle/test
  11. 1474
    0
      poubelle/y.output
  12. 1705
    0
      poubelle/y.tab.c
  13. 137
    0
      poubelle/y.tab.h
  14. 5
    22
      script.sh

BIN
a.out View File


+ 18
- 7
analyse_lexicale.lex View File

@@ -1,3 +1,14 @@
1
+%{ 
2
+#include "analyse_syntaxique.tab.h" 
3
+int yywrap(void){
4
+    return 1;
5
+}
6
+
7
+%}
8
+
9
+
10
+
11
+
1 12
 ADD         "+"
2 13
 SUB         "-"
3 14
 MUL         "*"
@@ -32,8 +43,9 @@ DIGIT       [0-9]
32 43
 VARIABLE    [A-Za-z0-9_]+
33 44
 CONST       "const"
34 45
 DECIMAL     {DIGIT}+
35
-EXPONENTIEL {DIGIT}+"^"{DIGIT}+
36
-ENTIER      {DECIMAL}|{EXPONENTIEL}
46
+EXPONENTIEL {DIGIT}+"e"{DIGIT}+
47
+ENTIER      {DECIMAL}
48
+ENTIEREXP   {EXPONENTIEL}
37 49
 OPERATION   {ADD}|{SUB}|{MUL}|{DIV}
38 50
 COMPARATEUR {EGAL}|{LT}|{GT}
39 51
 SEPARATOR   {SPACE}|{TAB}
@@ -79,13 +91,12 @@ SEPARATOR   {SPACE}|{TAB}
79 91
 {tWHILE}        {return tWHILE ;}
80 92
 
81 93
 {CONST}         {return tCONST ;}
82
-{ENTIER}        {return tENTIER ;}
83
-{VARIABLE}      {return tVAR ;}
94
+{ENTIER}        {yylval.nombre = atoi(yytext); return tENTIER ;}
95
+{ENTIEREXP}     {yylval.nombre = -1; return tENTIEREXP;}
96
+{VARIABLE}      {strcpy(yylval.id, yytext); return tVAR  ;}
84 97
 
85 98
 %%
86
-int yywrap(void){
87
-    return 1;
88
-}
99
+
89 100
 //int main(void){
90 101
 //    yylex();
91 102
 //}

+ 822
- 788
analyse_syntaxique.output
File diff suppressed because it is too large
View File


+ 351
- 140
analyse_syntaxique.tab.c View File

@@ -99,36 +99,37 @@ extern int yydebug;
99 99
   enum yytokentype
100 100
   {
101 101
     tENTIER = 258,
102
-    tADD = 259,
103
-    tSUB = 260,
104
-    tMUL = 261,
105
-    tDIV = 262,
106
-    tPO = 263,
107
-    tPF = 264,
108
-    tAO = 265,
109
-    tAF = 266,
110
-    tERROR = 267,
111
-    tPV = 268,
112
-    tVIRGULE = 269,
113
-    tAFFECTATION = 270,
114
-    tEGAL = 271,
115
-    tDIFF = 272,
116
-    tLT = 273,
117
-    tGT = 274,
118
-    tGTE = 275,
119
-    tLTE = 276,
120
-    tMAIN = 277,
121
-    tINT = 278,
122
-    tPRINT = 279,
123
-    tRETURN = 280,
124
-    tOR = 281,
125
-    tAND = 282,
126
-    tIF = 283,
127
-    tELSE = 284,
128
-    tWHILE = 285,
129
-    tCONST = 286,
130
-    tVAR = 287,
131
-    tNOT = 288
102
+    tENTIEREXP = 259,
103
+    tADD = 260,
104
+    tSUB = 261,
105
+    tMUL = 262,
106
+    tDIV = 263,
107
+    tPO = 264,
108
+    tPF = 265,
109
+    tAO = 266,
110
+    tAF = 267,
111
+    tERROR = 268,
112
+    tPV = 269,
113
+    tVIRGULE = 270,
114
+    tAFFECTATION = 271,
115
+    tEGAL = 272,
116
+    tDIFF = 273,
117
+    tLT = 274,
118
+    tGT = 275,
119
+    tGTE = 276,
120
+    tLTE = 277,
121
+    tMAIN = 278,
122
+    tINT = 279,
123
+    tPRINT = 280,
124
+    tRETURN = 281,
125
+    tOR = 282,
126
+    tAND = 283,
127
+    tIF = 284,
128
+    tELSE = 285,
129
+    tWHILE = 286,
130
+    tCONST = 287,
131
+    tVAR = 288,
132
+    tNOT = 289
132 133
   };
133 134
 #endif
134 135
 
@@ -140,8 +141,9 @@ union YYSTYPE
140 141
 #line 1 "analyse_syntaxique.y" /* yacc.c:355  */
141 142
 
142 143
 int nombre;
144
+char id[30];
143 145
 
144
-#line 145 "analyse_syntaxique.tab.c" /* yacc.c:355  */
146
+#line 147 "analyse_syntaxique.tab.c" /* yacc.c:355  */
145 147
 };
146 148
 
147 149
 typedef union YYSTYPE YYSTYPE;
@@ -157,8 +159,11 @@ int yyparse (void);
157 159
 #endif /* !YY_YY_ANALYSE_SYNTAXIQUE_TAB_H_INCLUDED  */
158 160
 
159 161
 /* Copy the second part of user declarations.  */
162
+#line 6 "analyse_syntaxique.y" /* yacc.c:358  */
160 163
 
161
-#line 162 "analyse_syntaxique.tab.c" /* yacc.c:358  */
164
+#include <stdio.h>
165
+
166
+#line 167 "analyse_syntaxique.tab.c" /* yacc.c:358  */
162 167
 
163 168
 #ifdef short
164 169
 # undef short
@@ -398,23 +403,23 @@ union yyalloc
398 403
 #endif /* !YYCOPY_NEEDED */
399 404
 
400 405
 /* YYFINAL -- State number of the termination state.  */
401
-#define YYFINAL  6
406
+#define YYFINAL  4
402 407
 /* YYLAST -- Last index in YYTABLE.  */
403
-#define YYLAST   130
408
+#define YYLAST   132
404 409
 
405 410
 /* YYNTOKENS -- Number of terminals.  */
406
-#define YYNTOKENS  34
411
+#define YYNTOKENS  35
407 412
 /* YYNNTS -- Number of nonterminals.  */
408
-#define YYNNTS  25
413
+#define YYNNTS  24
409 414
 /* YYNRULES -- Number of rules.  */
410
-#define YYNRULES  57
415
+#define YYNRULES  54
411 416
 /* YYNSTATES -- Number of states.  */
412
-#define YYNSTATES  117
417
+#define YYNSTATES  125
413 418
 
414 419
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
415 420
    by yylex, with out-of-bounds checking.  */
416 421
 #define YYUNDEFTOK  2
417
-#define YYMAXUTOK   288
422
+#define YYMAXUTOK   289
418 423
 
419 424
 #define YYTRANSLATE(YYX)                                                \
420 425
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -451,19 +456,19 @@ static const yytype_uint8 yytranslate[] =
451 456
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
452 457
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
453 458
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
454
-      25,    26,    27,    28,    29,    30,    31,    32,    33
459
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34
455 460
 };
456 461
 
457 462
 #if YYDEBUG
458 463
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
459 464
 static const yytype_uint8 yyrline[] =
460 465
 {
461
-       0,    47,    47,    48,    48,    48,    50,    52,    54,    54,
462
-      55,    63,    63,    65,    67,    67,    69,    69,    69,    69,
463
-      69,    69,    69,    71,    73,    73,    75,    75,    77,    77,
464
-      79,    81,    83,    83,    83,    83,    83,    83,    83,    83,
465
-      83,    87,    89,    89,    89,    91,    93,    93,    93,    93,
466
-      93,    93,    93,    93,    93,    95,    97,    99
466
+       0,    63,    63,    65,    66,    68,    71,    72,    75,    77,
467
+      78,    80,    81,    82,    83,    84,    85,    87,    89,    90,
468
+      92,    93,    95,    96,    98,   100,   102,   103,   104,   105,
469
+     106,   107,   108,   109,   110,   112,   113,   115,   116,   118,
470
+     120,   121,   123,   125,   126,   127,   128,   129,   130,   131,
471
+     132,   133,   135,   137,   139
467 472
 };
468 473
 #endif
469 474
 
@@ -472,14 +477,14 @@ static const yytype_uint8 yyrline[] =
472 477
    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
473 478
 static const char *const yytname[] =
474 479
 {
475
-  "$end", "error", "$undefined", "tENTIER", "tADD", "tSUB", "tMUL",
476
-  "tDIV", "tPO", "tPF", "tAO", "tAF", "tERROR", "tPV", "tVIRGULE",
480
+  "$end", "error", "$undefined", "tENTIER", "tENTIEREXP", "tADD", "tSUB",
481
+  "tMUL", "tDIV", "tPO", "tPF", "tAO", "tAF", "tERROR", "tPV", "tVIRGULE",
477 482
   "tAFFECTATION", "tEGAL", "tDIFF", "tLT", "tGT", "tGTE", "tLTE", "tMAIN",
478 483
   "tINT", "tPRINT", "tRETURN", "tOR", "tAND", "tIF", "tELSE", "tWHILE",
479
-  "tCONST", "tVAR", "tNOT", "$accept", "C", "Fonctions", "Fonction",
480
-  "Main", "Params", "Param", "SuiteParams", "Body", "Instructions",
481
-  "Instruction", "Decl", "SuiteDecl", "Type", "Valeur", "Affbis", "Aff",
482
-  "E", "If", "Else", "While", "Cond", "Print", "Invocation", "Args", YY_NULLPTR
484
+  "tCONST", "tVAR", "tNOT", "$accept", "Main", "Params", "Param",
485
+  "SuiteParams", "Body", "Instructions", "Instruction", "Decl",
486
+  "SuiteDecl", "Type", "Valeur", "Affbis", "Aff", "E", "Args", "SuiteArgs",
487
+  "If", "Else", "While", "Cond", "Invocation", "Print", "Return", YY_NULLPTR
483 488
 };
484 489
 #endif
485 490
 
@@ -491,14 +496,14 @@ static const yytype_uint16 yytoknum[] =
491 496
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
492 497
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
493 498
      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
494
-     285,   286,   287,   288
499
+     285,   286,   287,   288,   289
495 500
 };
496 501
 # endif
497 502
 
498
-#define YYPACT_NINF -47
503
+#define YYPACT_NINF -36
499 504
 
500 505
 #define yypact_value_is_default(Yystate) \
501
-  (!!((Yystate) == (-47)))
506
+  (!!((Yystate) == (-36)))
502 507
 
503 508
 #define YYTABLE_NINF -1
504 509
 
@@ -509,18 +514,19 @@ static const yytype_uint16 yytoknum[] =
509 514
      STATE-NUM.  */
510 515
 static const yytype_int8 yypact[] =
511 516
 {
512
-     -17,   -24,    40,    23,   -17,    57,   -47,    47,   -47,   -47,
513
-      43,    71,    48,    73,    72,    78,   -47,    83,    43,   -47,
514
-      83,    53,   -47,    72,   -47,   -47,    87,   -47,    88,    89,
515
-      75,    37,    90,    53,   -47,    67,    91,   -47,   -47,   -47,
516
-     -47,    92,   -47,    68,    11,    11,   -47,   -47,    15,   -47,
517
-     -47,    93,    95,   -47,   -47,   -47,    94,   -47,    15,    15,
518
-      98,    11,    54,    -5,   -47,    -2,   101,    85,    67,    99,
519
-     100,     4,    44,    36,    15,    15,    15,    15,    15,    15,
520
-      15,    15,    15,    15,    83,    11,    11,    83,   -47,    95,
521
-     -47,   -47,   -47,    49,     4,    85,    85,    85,    85,    85,
522
-      85,    85,    85,    82,    36,    36,   -47,   -47,    29,   -47,
523
-     106,   -47,    11,     0,    83,    82,   -47
517
+      -7,    -4,    26,    18,   -36,     9,    12,    40,    36,   -36,
518
+      50,     9,   -36,    54,   -36,    36,   -36,    55,    68,    79,
519
+      39,    -2,    63,    54,   -36,    60,    80,   -36,   -36,   -36,
520
+      81,   -36,    82,    64,    15,    15,   -36,    65,    19,    19,
521
+      88,   -36,    86,    89,   -36,   -36,   -36,   -36,    93,   -36,
522
+      19,    19,    96,    15,    48,    97,   -36,    99,    91,   100,
523
+      24,    66,   -36,    60,    98,   101,     1,    52,   -36,    19,
524
+      19,    19,    19,    19,    19,    19,    19,    19,    19,    15,
525
+      15,   102,   103,    78,   -36,   -36,   -36,    89,   -36,   -36,
526
+     -36,     5,     1,   108,   -36,    24,    24,    24,    24,    24,
527
+      24,   -36,   -36,    54,    54,    91,   -36,   105,   106,   -36,
528
+      90,   -36,    -6,   -36,    54,   110,   109,    15,   -36,   112,
529
+     113,    54,   111,    90,   -36
524 530
 };
525 531
 
526 532
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -528,34 +534,35 @@ static const yytype_int8 yypact[] =
528 534
      means the default is an error.  */
529 535
 static const yytype_uint8 yydefact[] =
530 536
 {
531
-       0,     0,     0,     0,     0,     0,     1,     0,     2,     3,
532
-       8,     0,     0,     0,    12,     0,    10,     0,     0,     9,
533
-       0,    15,     6,    12,     7,    26,     0,    19,     0,     0,
534
-       0,     0,     0,    15,    21,     0,     0,    16,    17,    18,
535
-      20,     0,    11,     0,     0,     0,    27,    57,     0,    13,
536
-      14,    28,    25,    29,    31,    22,     0,    32,     0,     0,
537
-      33,     0,     0,     0,    38,     0,     0,    30,     0,     0,
538
-       0,    40,     0,    54,     0,     0,     0,     0,     0,     0,
539
-       0,     0,     0,     0,     0,     0,     0,     0,    56,    25,
540
-      23,    55,    39,    34,    36,    35,    37,    48,    49,    50,
541
-      51,    53,    52,    42,    47,    46,    45,    24,     0,    41,
542
-       0,    43,     0,     0,     0,    42,    44
537
+       0,     0,     0,     0,     1,     3,     0,     0,     7,     5,
538
+       0,     0,     4,    10,     2,     7,    20,     0,     0,     0,
539
+       0,     0,     0,    10,    15,     0,     0,    11,    12,    13,
540
+       0,    14,     0,     0,     0,     0,    21,    36,     0,     0,
541
+       0,     9,    22,    19,    23,    25,    16,     6,     0,    26,
542
+       0,     0,    27,     0,     0,     0,    32,     0,    38,     0,
543
+      24,     0,     8,     0,     0,     0,    34,     0,    51,     0,
544
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
545
+       0,     0,     0,     0,    35,    52,    54,    19,    17,    53,
546
+      33,    28,    30,    29,    31,    43,    44,    45,    46,    48,
547
+      47,    50,    49,    10,    10,    38,    18,     0,     0,    37,
548
+       0,    42,     0,    39,    10,     0,     0,     0,    40,     0,
549
+       0,    10,     0,     0,    41
543 550
 };
544 551
 
545 552
   /* YYPGOTO[NTERM-NUM].  */
546 553
 static const yytype_int8 yypgoto[] =
547 554
 {
548
-     -47,   -47,   103,   -47,   -47,   -47,    84,    96,   -20,    97,
549
-     -47,   -47,    26,   -47,    50,   -30,   -47,   -46,   -47,     1,
550
-     -47,   -44,   -47,   -18,   -47
555
+     -36,   -36,   -36,   114,   115,   -36,   -22,   -36,   -36,    41,
556
+     -36,    69,   -19,   -36,   -35,   -36,    21,   -36,     4,   -36,
557
+     -33,   -13,   -36,   -36
551 558
 };
552 559
 
553 560
   /* YYDEFGOTO[NTERM-NUM].  */
554 561
 static const yytype_int8 yydefgoto[] =
555 562
 {
556
-      -1,     2,     3,     4,     8,    13,    14,    19,    22,    32,
557
-      33,    34,    69,    35,    52,    36,    37,    62,    38,   109,
558
-      39,    63,    40,    64,    66
563
+      -1,     2,     7,     8,    12,    14,    22,    23,    24,    64,
564
+      25,    43,    26,    27,    54,    59,    84,    28,   113,    29,
565
+      55,    56,    31,    40
559 566
 };
560 567
 
561 568
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -563,78 +570,79 @@ static const yytype_int8 yydefgoto[] =
563 570
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
564 571
 static const yytype_uint8 yytable[] =
565 572
 {
566
-      24,    65,    67,    41,    84,    53,     1,    87,     5,   114,
567
-      76,    77,    71,    72,    57,    41,    58,    73,    57,    59,
568
-      58,    85,    86,    59,    85,    86,    85,    86,    93,    94,
569
-      95,    96,    97,    98,    99,   100,   101,   102,    53,    21,
570
-       6,   104,   105,    60,    61,    47,     7,    60,    74,    75,
571
-      76,    77,    48,    92,    75,    76,    77,   110,    74,    75,
572
-      76,    77,    85,    86,   103,    10,    12,   106,   113,    11,
573
-      78,    79,    80,    81,    82,    83,    25,    26,    27,    15,
574
-      16,    28,    17,    29,    30,    31,    18,    20,   111,    74,
575
-      75,    76,    77,    21,   115,    43,    44,    45,    46,    51,
576
-      56,    49,    23,    70,    54,    55,    47,     9,    48,    68,
577
-      88,   108,    90,    91,   112,   107,   116,     0,    89,    42,
578
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
579
-      50
573
+      30,    41,    57,    60,    61,   114,    44,    37,    71,    72,
574
+      30,    70,    71,    72,    38,    66,    67,     1,    49,     3,
575
+      68,    50,    49,   115,    51,    50,     4,     5,    51,    69,
576
+      70,    71,    72,     6,    91,    92,    93,    94,    95,    96,
577
+      97,    98,    99,   100,    44,     9,   101,   102,    52,    53,
578
+      10,    11,    52,    69,    70,    71,    72,    69,    70,    71,
579
+      72,    13,    90,    36,    33,    73,    74,    75,    76,    77,
580
+      78,    69,    70,    71,    72,    79,    80,    34,    16,    17,
581
+      86,   107,   108,    18,   119,    19,    20,    21,    35,    39,
582
+      30,    30,   116,    42,    45,    46,    47,    48,    58,   122,
583
+      62,    30,    38,    65,    63,    37,    83,    81,    30,    82,
584
+      85,   105,    88,   103,   104,    89,    72,   110,   111,   117,
585
+     112,   118,   120,   123,   121,    15,   109,   124,   106,     0,
586
+      32,     0,    87
580 587
 };
581 588
 
582 589
 static const yytype_int8 yycheck[] =
583 590
 {
584
-      20,    45,    48,    21,     9,    35,    23,     9,    32,     9,
585
-       6,     7,    58,    59,     3,    33,     5,    61,     3,     8,
586
-       5,    26,    27,     8,    26,    27,    26,    27,    74,    75,
587
-      76,    77,    78,    79,    80,    81,    82,    83,    68,    10,
588
-       0,    85,    86,    32,    33,     8,    23,    32,     4,     5,
589
-       6,     7,    15,     9,     5,     6,     7,    28,     4,     5,
590
-       6,     7,    26,    27,    84,     8,    23,    87,   112,    22,
591
-      16,    17,    18,    19,    20,    21,    23,    24,    25,     8,
592
-      32,    28,     9,    30,    31,    32,    14,     9,   108,     4,
593
-       5,     6,     7,    10,   114,     8,     8,     8,    23,    32,
594
-      32,    11,    18,     9,    13,    13,     8,     4,    15,    14,
595
-       9,    29,    13,    13,     8,    89,   115,    -1,    68,    23,
596
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
597
-      33
591
+      13,    23,    35,    38,    39,    11,    25,     9,     7,     8,
592
+      23,     6,     7,     8,    16,    50,    51,    24,     3,    23,
593
+      53,     6,     3,    29,     9,     6,     0,     9,     9,     5,
594
+       6,     7,     8,    24,    69,    70,    71,    72,    73,    74,
595
+      75,    76,    77,    78,    63,    33,    79,    80,    33,    34,
596
+      10,    15,    33,     5,     6,     7,     8,     5,     6,     7,
597
+       8,    11,    10,    24,     9,    17,    18,    19,    20,    21,
598
+      22,     5,     6,     7,     8,    27,    28,     9,    24,    25,
599
+      14,   103,   104,    29,   117,    31,    32,    33,     9,    26,
600
+     103,   104,   114,    33,    14,    14,    14,    33,    33,   121,
601
+      12,   114,    16,    10,    15,     9,    15,    10,   121,    10,
602
+      10,    33,    14,    11,    11,    14,     8,    12,    12,     9,
603
+      30,    12,    10,    12,    11,    11,   105,   123,    87,    -1,
604
+      15,    -1,    63
598 605
 };
599 606
 
600 607
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
601 608
      symbol of state STATE-NUM.  */
602 609
 static const yytype_uint8 yystos[] =
603 610
 {
604
-       0,    23,    35,    36,    37,    32,     0,    23,    38,    36,
605
-       8,    22,    23,    39,    40,     8,    32,     9,    14,    41,
606
-       9,    10,    42,    40,    42,    23,    24,    25,    28,    30,
607
-      31,    32,    43,    44,    45,    47,    49,    50,    52,    54,
608
-      56,    57,    41,     8,     8,     8,    23,     8,    15,    11,
609
-      43,    32,    48,    49,    13,    13,    32,     3,     5,     8,
610
-      32,    33,    51,    55,    57,    55,    58,    51,    14,    46,
611
-       9,    51,    51,    55,     4,     5,     6,     7,    16,    17,
612
-      18,    19,    20,    21,     9,    26,    27,     9,     9,    48,
613
-      13,    13,     9,    51,    51,    51,    51,    51,    51,    51,
614
-      51,    51,    51,    42,    55,    55,    42,    46,    29,    53,
615
-      28,    42,     8,    55,     9,    42,    53
611
+       0,    24,    36,    23,     0,     9,    24,    37,    38,    33,
612
+      10,    15,    39,    11,    40,    38,    24,    25,    29,    31,
613
+      32,    33,    41,    42,    43,    45,    47,    48,    52,    54,
614
+      56,    57,    39,     9,     9,     9,    24,     9,    16,    26,
615
+      58,    41,    33,    46,    47,    14,    14,    14,    33,     3,
616
+       6,     9,    33,    34,    49,    55,    56,    55,    33,    50,
617
+      49,    49,    12,    15,    44,    10,    49,    49,    55,     5,
618
+       6,     7,     8,    17,    18,    19,    20,    21,    22,    27,
619
+      28,    10,    10,    15,    51,    10,    14,    46,    14,    14,
620
+      10,    49,    49,    49,    49,    49,    49,    49,    49,    49,
621
+      49,    55,    55,    11,    11,    33,    44,    41,    41,    51,
622
+      12,    12,    30,    53,    11,    29,    41,     9,    12,    55,
623
+      10,    11,    41,    12,    53
616 624
 };
617 625
 
618 626
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
619 627
 static const yytype_uint8 yyr1[] =
620 628
 {
621
-       0,    34,    35,    36,    36,    36,    37,    38,    39,    39,
622
-      40,    41,    41,    42,    43,    43,    44,    44,    44,    44,
623
-      44,    44,    44,    45,    46,    46,    47,    47,    48,    48,
624
-      49,    50,    51,    51,    51,    51,    51,    51,    51,    51,
625
-      51,    52,    53,    53,    53,    54,    55,    55,    55,    55,
626
-      55,    55,    55,    55,    55,    56,    57,    58
629
+       0,    35,    36,    37,    37,    38,    39,    39,    40,    41,
630
+      41,    42,    42,    42,    42,    42,    42,    43,    44,    44,
631
+      45,    45,    46,    46,    47,    48,    49,    49,    49,    49,
632
+      49,    49,    49,    49,    49,    50,    50,    51,    51,    52,
633
+      53,    53,    54,    55,    55,    55,    55,    55,    55,    55,
634
+      55,    55,    56,    57,    58
627 635
 };
628 636
 
629 637
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
630 638
 static const yytype_uint8 yyr2[] =
631 639
 {
632
-       0,     2,     2,     2,     1,     0,     6,     5,     0,     2,
633
-       2,     3,     0,     3,     2,     0,     1,     1,     1,     1,
634
-       1,     1,     2,     4,     3,     0,     1,     2,     1,     1,
635
-       3,     2,     1,     1,     3,     3,     3,     3,     1,     3,
636
-       2,     6,     0,     2,     7,     5,     3,     3,     3,     3,
637
-       3,     3,     3,     3,     2,     5,     4,     0
640
+       0,     2,     6,     0,     2,     2,     4,     0,     4,     2,
641
+       0,     1,     1,     1,     1,     1,     2,     4,     3,     0,
642
+       1,     2,     1,     1,     3,     2,     1,     1,     3,     3,
643
+       3,     3,     1,     3,     2,     2,     0,     3,     0,     8,
644
+       4,     9,     7,     3,     3,     3,     3,     3,     3,     3,
645
+       3,     2,     4,     5,     3
638 646
 };
639 647
 
640 648
 
@@ -1310,8 +1318,206 @@ yyreduce:
1310 1318
   YY_REDUCE_PRINT (yyn);
1311 1319
   switch (yyn)
1312 1320
     {
1313
-      
1314
-#line 1315 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1321
+        case 2:
1322
+#line 63 "analyse_syntaxique.y" /* yacc.c:1646  */
1323
+    {printf("Dans main\n");}
1324
+#line 1325 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1325
+    break;
1326
+
1327
+  case 3:
1328
+#line 65 "analyse_syntaxique.y" /* yacc.c:1646  */
1329
+    {printf("Sans params\n");}
1330
+#line 1331 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1331
+    break;
1332
+
1333
+  case 5:
1334
+#line 68 "analyse_syntaxique.y" /* yacc.c:1646  */
1335
+    {printf("Parametre : %s\n", (yyvsp[0].id));}
1336
+#line 1337 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1337
+    break;
1338
+
1339
+  case 8:
1340
+#line 75 "analyse_syntaxique.y" /* yacc.c:1646  */
1341
+    {printf("Dans body\n");}
1342
+#line 1343 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1343
+    break;
1344
+
1345
+  case 17:
1346
+#line 87 "analyse_syntaxique.y" /* yacc.c:1646  */
1347
+    {printf("Declaration\n");}
1348
+#line 1349 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1349
+    break;
1350
+
1351
+  case 20:
1352
+#line 92 "analyse_syntaxique.y" /* yacc.c:1646  */
1353
+    {printf("int\n");}
1354
+#line 1355 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1355
+    break;
1356
+
1357
+  case 21:
1358
+#line 93 "analyse_syntaxique.y" /* yacc.c:1646  */
1359
+    {printf("const int\n");}
1360
+#line 1361 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1361
+    break;
1362
+
1363
+  case 22:
1364
+#line 95 "analyse_syntaxique.y" /* yacc.c:1646  */
1365
+    {printf("Declaration %s\n", (yyvsp[0].id));}
1366
+#line 1367 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1367
+    break;
1368
+
1369
+  case 24:
1370
+#line 98 "analyse_syntaxique.y" /* yacc.c:1646  */
1371
+    {printf("Affectation : %s\n", (yyvsp[-2].id));}
1372
+#line 1373 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1373
+    break;
1374
+
1375
+  case 26:
1376
+#line 102 "analyse_syntaxique.y" /* yacc.c:1646  */
1377
+    {printf("int %d\n", (yyvsp[0].nombre));}
1378
+#line 1379 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1379
+    break;
1380
+
1381
+  case 27:
1382
+#line 103 "analyse_syntaxique.y" /* yacc.c:1646  */
1383
+    {printf("var %s\n", (yyvsp[0].id));}
1384
+#line 1385 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1385
+    break;
1386
+
1387
+  case 28:
1388
+#line 104 "analyse_syntaxique.y" /* yacc.c:1646  */
1389
+    {printf("Addition\n");}
1390
+#line 1391 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1391
+    break;
1392
+
1393
+  case 29:
1394
+#line 105 "analyse_syntaxique.y" /* yacc.c:1646  */
1395
+    {printf("Multiplication\n");}
1396
+#line 1397 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1397
+    break;
1398
+
1399
+  case 30:
1400
+#line 106 "analyse_syntaxique.y" /* yacc.c:1646  */
1401
+    {printf("Soustraction\n");}
1402
+#line 1403 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1403
+    break;
1404
+
1405
+  case 31:
1406
+#line 107 "analyse_syntaxique.y" /* yacc.c:1646  */
1407
+    {printf("Division\n");}
1408
+#line 1409 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1409
+    break;
1410
+
1411
+  case 33:
1412
+#line 109 "analyse_syntaxique.y" /* yacc.c:1646  */
1413
+    {printf("Parenthèse\n");}
1414
+#line 1415 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1415
+    break;
1416
+
1417
+  case 34:
1418
+#line 110 "analyse_syntaxique.y" /* yacc.c:1646  */
1419
+    {printf("Soustraction\n");}
1420
+#line 1421 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1421
+    break;
1422
+
1423
+  case 39:
1424
+#line 118 "analyse_syntaxique.y" /* yacc.c:1646  */
1425
+    {printf("Dans if\n");}
1426
+#line 1427 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1427
+    break;
1428
+
1429
+  case 40:
1430
+#line 120 "analyse_syntaxique.y" /* yacc.c:1646  */
1431
+    {printf("else\n");}
1432
+#line 1433 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1433
+    break;
1434
+
1435
+  case 41:
1436
+#line 121 "analyse_syntaxique.y" /* yacc.c:1646  */
1437
+    {printf("elsif\n");}
1438
+#line 1439 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1439
+    break;
1440
+
1441
+  case 42:
1442
+#line 123 "analyse_syntaxique.y" /* yacc.c:1646  */
1443
+    {printf("Dans while\n");}
1444
+#line 1445 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1445
+    break;
1446
+
1447
+  case 43:
1448
+#line 125 "analyse_syntaxique.y" /* yacc.c:1646  */
1449
+    {printf("Cond ==\n");}
1450
+#line 1451 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1451
+    break;
1452
+
1453
+  case 44:
1454
+#line 126 "analyse_syntaxique.y" /* yacc.c:1646  */
1455
+    {printf("Cond !=\n");}
1456
+#line 1457 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1457
+    break;
1458
+
1459
+  case 45:
1460
+#line 127 "analyse_syntaxique.y" /* yacc.c:1646  */
1461
+    {printf("Cond <\n");}
1462
+#line 1463 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1463
+    break;
1464
+
1465
+  case 46:
1466
+#line 128 "analyse_syntaxique.y" /* yacc.c:1646  */
1467
+    {printf("Cond >\n");}
1468
+#line 1469 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1469
+    break;
1470
+
1471
+  case 47:
1472
+#line 129 "analyse_syntaxique.y" /* yacc.c:1646  */
1473
+    {printf("Cond <=\n");}
1474
+#line 1475 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1475
+    break;
1476
+
1477
+  case 48:
1478
+#line 130 "analyse_syntaxique.y" /* yacc.c:1646  */
1479
+    {printf("Cond >=\n");}
1480
+#line 1481 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1481
+    break;
1482
+
1483
+  case 49:
1484
+#line 131 "analyse_syntaxique.y" /* yacc.c:1646  */
1485
+    {printf("Cond &&\n");}
1486
+#line 1487 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1487
+    break;
1488
+
1489
+  case 50:
1490
+#line 132 "analyse_syntaxique.y" /* yacc.c:1646  */
1491
+    {printf("Cond ||\n");}
1492
+#line 1493 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1493
+    break;
1494
+
1495
+  case 51:
1496
+#line 133 "analyse_syntaxique.y" /* yacc.c:1646  */
1497
+    {printf("Cond !\n");}
1498
+#line 1499 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1499
+    break;
1500
+
1501
+  case 52:
1502
+#line 135 "analyse_syntaxique.y" /* yacc.c:1646  */
1503
+    {printf("Dans invocation\n");}
1504
+#line 1505 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1505
+    break;
1506
+
1507
+  case 53:
1508
+#line 137 "analyse_syntaxique.y" /* yacc.c:1646  */
1509
+    {printf("printf de %s\n", (yyvsp[-2].id));}
1510
+#line 1511 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1511
+    break;
1512
+
1513
+  case 54:
1514
+#line 139 "analyse_syntaxique.y" /* yacc.c:1646  */
1515
+    {printf("return\n");}
1516
+#line 1517 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1517
+    break;
1518
+
1519
+
1520
+#line 1521 "analyse_syntaxique.tab.c" /* yacc.c:1646  */
1315 1521
       default: break;
1316 1522
     }
1317 1523
   /* User semantic actions sometimes alter yychar, and that requires
@@ -1539,5 +1745,10 @@ yyreturn:
1539 1745
 #endif
1540 1746
   return yyresult;
1541 1747
 }
1542
-#line 107 "analyse_syntaxique.y" /* yacc.c:1906  */
1748
+#line 141 "analyse_syntaxique.y" /* yacc.c:1906  */
1749
+
1750
+#include <stdio.h>
1751
+void main(void){
1752
+    yyparse();
1753
+}
1543 1754
 

+ 33
- 31
analyse_syntaxique.tab.h View File

@@ -46,36 +46,37 @@ extern int yydebug;
46 46
   enum yytokentype
47 47
   {
48 48
     tENTIER = 258,
49
-    tADD = 259,
50
-    tSUB = 260,
51
-    tMUL = 261,
52
-    tDIV = 262,
53
-    tPO = 263,
54
-    tPF = 264,
55
-    tAO = 265,
56
-    tAF = 266,
57
-    tERROR = 267,
58
-    tPV = 268,
59
-    tVIRGULE = 269,
60
-    tAFFECTATION = 270,
61
-    tEGAL = 271,
62
-    tDIFF = 272,
63
-    tLT = 273,
64
-    tGT = 274,
65
-    tGTE = 275,
66
-    tLTE = 276,
67
-    tMAIN = 277,
68
-    tINT = 278,
69
-    tPRINT = 279,
70
-    tRETURN = 280,
71
-    tOR = 281,
72
-    tAND = 282,
73
-    tIF = 283,
74
-    tELSE = 284,
75
-    tWHILE = 285,
76
-    tCONST = 286,
77
-    tVAR = 287,
78
-    tNOT = 288
49
+    tENTIEREXP = 259,
50
+    tADD = 260,
51
+    tSUB = 261,
52
+    tMUL = 262,
53
+    tDIV = 263,
54
+    tPO = 264,
55
+    tPF = 265,
56
+    tAO = 266,
57
+    tAF = 267,
58
+    tERROR = 268,
59
+    tPV = 269,
60
+    tVIRGULE = 270,
61
+    tAFFECTATION = 271,
62
+    tEGAL = 272,
63
+    tDIFF = 273,
64
+    tLT = 274,
65
+    tGT = 275,
66
+    tGTE = 276,
67
+    tLTE = 277,
68
+    tMAIN = 278,
69
+    tINT = 279,
70
+    tPRINT = 280,
71
+    tRETURN = 281,
72
+    tOR = 282,
73
+    tAND = 283,
74
+    tIF = 284,
75
+    tELSE = 285,
76
+    tWHILE = 286,
77
+    tCONST = 287,
78
+    tVAR = 288,
79
+    tNOT = 289
79 80
   };
80 81
 #endif
81 82
 
@@ -87,8 +88,9 @@ union YYSTYPE
87 88
 #line 1 "analyse_syntaxique.y" /* yacc.c:1909  */
88 89
 
89 90
 int nombre;
91
+char id[30];
90 92
 
91
-#line 92 "analyse_syntaxique.tab.h" /* yacc.c:1909  */
93
+#line 94 "analyse_syntaxique.tab.h" /* yacc.c:1909  */
92 94
 };
93 95
 
94 96
 typedef union YYSTYPE YYSTYPE;

+ 73
- 34
analyse_syntaxique.y View File

@@ -1,8 +1,16 @@
1 1
 %union {
2 2
 int nombre;
3
+char id[30];
3 4
 }
4 5
 
6
+%{
7
+#include <stdio.h>
8
+%}
9
+
10
+
5 11
 %token<nombre> tENTIER
12
+%token<nombre> tENTIEREXP
13
+
6 14
 %token tADD
7 15
 %token tSUB
8 16
 %token tMUL
@@ -34,74 +42,105 @@ int nombre;
34 42
 %token tELSE
35 43
 %token tWHILE
36 44
 %token tCONST
37
-%token tVAR
45
+%token<id> tVAR
38 46
 %token tNOT
39 47
 
40 48
 %left tADD
41 49
 %left tSUB
50
+%left tMUL
51
+%left tDIV
42 52
 %right tEGAL
43 53
 
44
-%type<nombre> E
54
+
45 55
 %%
46 56
 
47
-C : Fonctions Main ;
48
-Fonctions : Fonction Fonctions | Fonction | ;
57
+//C : Fonctions Main ;
49 58
 
50
-Fonction : tINT tVAR tPO Params tPF Body ;
59
+//Fonctions : Fonction Fonctions | ;
60
+//Fonction : tINT tVAR tPO Params tPF Body;
51 61
 
52
-Main : tINT tMAIN tPO tPF Body ;
53 62
 
54
-Params : | Param SuiteParams ;
55
-Param : tINT tVAR ;
63
+Main : tINT tMAIN tPO Params tPF Body {printf("Dans main\n");};
56 64
 
65
+Params : {printf("Sans params\n");} ;
66
+Params : Param SuiteParams ;
57 67
 
58
-// Ps : P Ps | ;
59
-// P : tINT tID ttVIRGULE
60
-// Ps =>* tINT tID ttVIRGULE tINT tID ttVIRGULE
61
-// Ps => P Ps => P P Ps ...
68
+Param : tINT tVAR {printf("Parametre : %s\n", $2);} ;
62 69
 
63
-SuiteParams : tVIRGULE Param SuiteParams | ;
64 70
 
65
-Body : tAO Instructions tAF ;
71
+SuiteParams : tVIRGULE Param SuiteParams tPV ;
72
+SuiteParams : ;
66 73
 
67
-Instructions : Instruction Instructions | ;
68 74
 
69
-Instruction : Aff | If | While | tRETURN | Print | Decl | Invocation tPV ;
75
+Body : tAO Instructions Return tAF {printf("Dans body\n");} ;
70 76
 
71
-Decl : Type Valeur SuiteDecl tPV;
77
+Instructions : Instruction Instructions ;
78
+Instructions : ;
72 79
 
73
-SuiteDecl: tVIRGULE Valeur SuiteDecl | ;
80
+Instruction : Aff ;
81
+Instruction : If ;
82
+Instruction : While ;
83
+Instruction : Print ;
84
+Instruction : Decl ;
85
+Instruction : Invocation tPV ;
74 86
 
75
-Type : tINT | tCONST tINT ; 
87
+Decl : Type Valeur SuiteDecl tPV {printf("Declaration\n");} ;
76 88
 
77
-Valeur : tVAR | Affbis ;
89
+SuiteDecl: tVIRGULE Valeur SuiteDecl ;
90
+SuiteDecl: ;
78 91
 
79
-Affbis : tVAR tAFFECTATION E;
92
+Type : tINT {printf("int\n");} ; 
93
+Type : tCONST tINT {printf("const int\n");} ;
80 94
 
81
-Aff : Affbis tPV ;
95
+Valeur : tVAR {printf("Declaration %s\n", $1);};
96
+Valeur : Affbis ;
82 97
 
83
-E : tENTIER | tVAR | E tADD E | E tMUL E | E tSUB E | E tDIV E | Invocation | tPO E tPF | tSUB E ;
98
+Affbis : tVAR tAFFECTATION E {printf("Affectation : %s\n", $1);};
84 99
 
85
-// E : tID tPlus tID | ...
100
+Aff : Affbis tPV ;
86 101
 
87
-If : tIF tPO Cond tPF Body Else;
102
+E : tENTIER {printf("int %d\n", $1);};
103
+E : tVAR {printf("var %s\n", $1);}; 
104
+E : E tADD E {printf("Addition\n");} ;
105
+E : E tMUL E {printf("Multiplication\n");}  ; 
106
+E : E tSUB E {printf("Soustraction\n");} ;
107
+E : E tDIV E {printf("Division\n");} ;
108
+E : Invocation ;
109
+E : tPO E tPF {printf("Parenthèse\n");} ;
110
+E : tSUB E {printf("Soustraction\n");} ;
88 111
 
89
-Else : | tELSE Body |tELSE tIF tPO Cond tPF Body Else;
112
+Args : tVAR SuiteArgs ;
113
+Args : ;
90 114
 
91
-While : tWHILE tPO Cond tPF Body ;
115
+SuiteArgs : tVIRGULE tVAR SuiteArgs ;
116
+SuiteArgs : ;
92 117
 
93
-Cond : Cond tAND Cond | Cond tOR Cond | E tEGAL E | E tDIFF E | E tLT E | E tGT E | E tLTE E | E tGTE E| tNOT Cond ;
118
+If : tIF tPO Cond tPF tAO Instructions tAF Else {printf("Dans if\n");};
94 119
 
95
-Print : tPRINT tPO tVAR tPF tPV ;
120
+Else : tELSE tAO Instructions tAF {printf("else\n");} ;
121
+Else : tELSE tIF tPO Cond tPF tAO Instructions tAF Else {printf("elsif\n");} ;
96 122
 
97
-Invocation : tVAR tPO  Args  tPF ;
123
+While : tWHILE tPO Cond tPF tAO Instructions tAF {printf("Dans while\n");};
98 124
 
99
-Args : | Arg SuiteArgs ;
125
+Cond : E tEGAL E {printf("Cond ==\n");} ;
126
+Cond : E tDIFF E {printf("Cond !=\n");} ;
127
+Cond : E tLT E {printf("Cond <\n");} ;
128
+Cond : E tGT E {printf("Cond >\n");} ;
129
+Cond : E tLTE E {printf("Cond <=\n");} ;
130
+Cond : E tGTE E{printf("Cond >=\n");} ;
131
+Cond : E tAND Cond {printf("Cond &&\n");} ;
132
+Cond : E tOR Cond {printf("Cond ||\n");} ;
133
+Cond : tNOT Cond {printf("Cond !\n");} ;
100 134
 
101
-Arg : tVAR ;
135
+Invocation : tVAR tPO  Args  tPF {printf("Dans invocation\n");};
102 136
 
103
-SuiteArgs : tVIRGULE Arg SuiteArgs ;
137
+Print : tPRINT tPO tVAR tPF tPV {printf("printf de %s\n", $3);};
104 138
 
105
-RETURN : tRETURN E tPV ;
139
+Return : tRETURN E tPV {printf("return\n");};
106 140
 
107 141
 %%
142
+#include <stdio.h>
143
+void main(void){
144
+    yyparse();
145
+}
146
+

+ 95
- 93
lex.yy.c View File

@@ -351,8 +351,8 @@ static void yynoreturn yy_fatal_error ( const char* msg  );
351 351
 	(yy_hold_char) = *yy_cp; \
352 352
 	*yy_cp = '\0'; \
353 353
 	(yy_c_buf_p) = yy_cp;
354
-#define YY_NUM_RULES 33
355
-#define YY_END_OF_BUFFER 34
354
+#define YY_NUM_RULES 34
355
+#define YY_END_OF_BUFFER 35
356 356
 /* This struct is not used in this scanner,
357 357
    but its presence is necessary. */
358 358
 struct yy_trans_info
@@ -362,13 +362,13 @@ struct yy_trans_info
362 362
 	};
363 363
 static const flex_int16_t yy_accept[70] =
364 364
     {   0,
365
-        0,    0,   34,   33,   10,   11,   20,   33,    5,    6,
365
+        0,    0,   35,   34,   10,   11,   20,   34,    5,    6,
366 366
         3,    1,   12,    2,    4,   31,    9,   16,   13,   17,
367
-       32,   32,   32,   32,   32,   32,   32,   32,    7,   33,
368
-        8,   15,   26,   31,   32,    0,   18,   14,   19,   32,
369
-       32,   27,   32,   32,   32,   32,   32,   25,   31,   32,
370
-       32,   22,   32,   32,   32,   32,   32,   28,   21,   32,
371
-       32,   32,   30,   32,   32,   29,   23,   24,    0
367
+       33,   33,   33,   33,   33,   33,   33,   33,    7,   34,
368
+        8,   15,   26,   31,   33,   33,   18,   14,   19,   33,
369
+       33,   27,   33,   33,   33,   33,   33,   25,   32,   33,
370
+       33,   22,   33,   33,   33,   33,   33,   28,   21,   33,
371
+       33,   33,   30,   33,   33,   29,   23,   24,    0
372 372
     } ;
373 373
 
374 374
 static const YY_CHAR yy_ec[256] =
@@ -382,11 +382,11 @@ static const YY_CHAR yy_ec[256] =
382 382
        17,   18,    1,    1,   19,   19,   19,   19,   19,   19,
383 383
        19,   19,   19,   19,   19,   19,   19,   19,   19,   19,
384 384
        19,   19,   19,   19,   19,   19,   19,   19,   19,   19,
385
-        1,    1,    1,   20,   19,    1,   21,   19,   22,   19,
385
+        1,    1,    1,    1,   19,    1,   20,   19,   21,   19,
386 386
 
387
-       23,   24,   19,   25,   26,   19,   19,   27,   28,   29,
388
-       30,   31,   19,   32,   33,   34,   35,   19,   36,   19,
389
-       19,   19,   37,   38,   39,    1,    1,    1,    1,    1,
387
+       22,   23,   19,   24,   25,   19,   19,   26,   27,   28,
388
+       29,   30,   19,   31,   32,   33,   34,   19,   35,   19,
389
+       19,   19,   36,   37,   38,    1,    1,    1,    1,    1,
390 390
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
391 391
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
392 392
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -403,23 +403,23 @@ static const YY_CHAR yy_ec[256] =
403 403
         1,    1,    1,    1,    1
404 404
     } ;
405 405
 
406
-static const YY_CHAR yy_meta[40] =
406
+static const YY_CHAR yy_meta[39] =
407 407
     {   0,
408 408
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
409 409
         1,    1,    1,    2,    1,    1,    1,    1,    2,    2,
410 410
         2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
411
-        2,    2,    2,    2,    2,    2,    1,    1,    1
411
+        2,    2,    2,    2,    2,    1,    1,    1
412 412
     } ;
413 413
 
414 414
 static const flex_int16_t yy_base[71] =
415 415
     {   0,
416
-        0,    0,  116,  117,  117,  117,   98,  108,  117,  117,
417
-      117,  117,  117,  117,  117,   26,  117,   96,   95,   94,
418
-       90,   21,   22,   23,   24,   28,   30,   34,  117,   71,
419
-      117,  117,  117,   41,   88,   93,  117,  117,  117,   36,
420
-       37,   86,   38,   42,   43,   44,   47,  117,   91,   46,
421
-       51,   84,   55,   56,   57,   60,   61,   83,   82,   62,
422
-       66,   68,   81,   69,   70,   80,   77,   74,  117,   81
416
+        0,    0,   79,   80,   80,   80,   61,   71,   80,   80,
417
+       80,   80,   80,   80,   80,   25,   80,   59,   58,   57,
418
+        0,   44,   46,   17,   51,   39,   47,   44,   80,   30,
419
+       80,   80,   80,   27,    0,   52,   80,   80,   80,   37,
420
+       32,    0,   30,   37,   36,   27,   34,   80,   44,   25,
421
+       34,    0,   27,   26,   19,   26,   18,    0,    0,   17,
422
+       17,   24,    0,   21,   15,    0,    0,    0,   80,   40
423 423
     } ;
424 424
 
425 425
 static const flex_int16_t yy_def[71] =
@@ -427,52 +427,44 @@ static const flex_int16_t yy_def[71] =
427 427
        69,    1,   69,   69,   69,   69,   69,   69,   69,   69,
428 428
        69,   69,   69,   69,   69,   70,   69,   69,   69,   69,
429 429
        70,   70,   70,   70,   70,   70,   70,   70,   69,   69,
430
-       69,   69,   69,   70,   70,   69,   69,   69,   69,   70,
431
-       70,   70,   70,   70,   70,   70,   70,   69,   69,   70,
430
+       69,   69,   69,   70,   70,   70,   69,   69,   69,   70,
431
+       70,   70,   70,   70,   70,   70,   70,   69,   70,   70,
432 432
        70,   70,   70,   70,   70,   70,   70,   70,   70,   70,
433 433
        70,   70,   70,   70,   70,   70,   70,   70,    0,   69
434 434
     } ;
435 435
 
436
-static const flex_int16_t yy_nxt[157] =
436
+static const flex_int16_t yy_nxt[119] =
437 437
     {   0,
438 438
         4,    5,    6,    5,    7,    8,    9,   10,   11,   12,
439
-       13,   14,   15,   16,   17,   18,   19,   20,   21,    4,
440
-       21,   22,   23,   21,   21,   24,   21,   25,   21,   21,
441
-       26,   27,   21,   21,   21,   28,   29,   30,   31,   34,
442
-       69,   69,   69,   69,   44,   36,   42,   69,   41,   69,
443
-       40,   43,   46,   69,   34,   69,   69,   69,   47,   45,
444
-       36,   69,   69,   69,   50,   69,   69,   53,   54,   51,
445
-       69,   52,   56,   58,   69,   69,   69,   55,   57,   69,
446
-       69,   69,   35,   59,   60,   69,   62,   69,   69,   69,
447
-       66,   61,   67,   69,   63,   64,   69,   65,   68,   69,
448
-
449
-       69,   69,   69,   69,   49,   69,   49,   69,   48,   69,
450
-       39,   38,   37,   33,   32,   69,    3,   69,   69,   69,
439
+       13,   14,   15,   16,   17,   18,   19,   20,   21,   21,
440
+       22,   23,   21,   21,   24,   21,   25,   21,   21,   26,
441
+       27,   21,   21,   21,   28,   29,   30,   31,   34,   42,
442
+       34,   35,   68,   67,   43,   66,   36,   65,   36,   64,
443
+       63,   62,   61,   60,   59,   58,   57,   49,   56,   55,
444
+       54,   53,   52,   51,   50,   49,   48,   47,   46,   45,
445
+       44,   41,   40,   39,   38,   37,   33,   32,   69,    3,
451 446
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
452 447
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
448
+
453 449
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
454
-       69,   69,   69,   69,   69,   69
450
+       69,   69,   69,   69,   69,   69,   69,   69
455 451
     } ;
456 452
 
457
-static const flex_int16_t yy_chk[157] =
453
+static const flex_int16_t yy_chk[119] =
458 454
     {   0,
459 455
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
460 456
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
461 457
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
462
-        1,    1,    1,    1,    1,    1,    1,    1,    1,   16,
463
-       22,   23,   24,   25,   25,   16,   24,   26,   23,   27,
464
-       22,   24,   27,   28,   34,   40,   41,   43,   28,   26,
465
-       34,   44,   45,   46,   40,   50,   47,   44,   45,   41,
466
-       51,   43,   47,   51,   53,   54,   55,   46,   50,   56,
467
-       57,   60,   70,   53,   54,   61,   56,   62,   64,   65,
468
-       62,   55,   64,   68,   57,   60,   67,   61,   65,   66,
469
-
470
-       63,   59,   58,   52,   49,   42,   36,   35,   30,   21,
471
-       20,   19,   18,    8,    7,    3,   69,   69,   69,   69,
458
+        1,    1,    1,    1,    1,    1,    1,    1,   16,   24,
459
+       34,   70,   65,   64,   24,   62,   16,   61,   34,   60,
460
+       57,   56,   55,   54,   53,   51,   50,   49,   47,   46,
461
+       45,   44,   43,   41,   40,   36,   30,   28,   27,   26,
462
+       25,   23,   22,   20,   19,   18,    8,    7,    3,   69,
472 463
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
473 464
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
465
+
474 466
        69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
475
-       69,   69,   69,   69,   69,   69
467
+       69,   69,   69,   69,   69,   69,   69,   69
476 468
     } ;
477 469
 
478 470
 static yy_state_type yy_last_accepting_state;
@@ -490,7 +482,14 @@ int yy_flex_debug = 0;
490 482
 #define YY_RESTORE_YY_MORE_OFFSET
491 483
 char *yytext;
492 484
 #line 1 "analyse_lexicale.lex"
493
-#line 494 "lex.yy.c"
485
+#line 2 "analyse_lexicale.lex"
486
+#include "analyse_syntaxique.tab.h" 
487
+int yywrap(void){
488
+    return 1;
489
+}
490
+
491
+#line 492 "lex.yy.c"
492
+#line 493 "lex.yy.c"
494 493
 
495 494
 #define INITIAL 0
496 495
 
@@ -707,10 +706,10 @@ YY_DECL
707 706
 		}
708 707
 
709 708
 	{
710
-#line 41 "analyse_lexicale.lex"
709
+#line 53 "analyse_lexicale.lex"
711 710
 
712 711
 
713
-#line 714 "lex.yy.c"
712
+#line 713 "lex.yy.c"
714 713
 
715 714
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
716 715
 		{
@@ -743,7 +742,7 @@ yy_match:
743 742
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
744 743
 			++yy_cp;
745 744
 			}
746
-		while ( yy_base[yy_current_state] != 117 );
745
+		while ( yy_base[yy_current_state] != 80 );
747 746
 
748 747
 yy_find_action:
749 748
 		yy_act = yy_accept[yy_current_state];
@@ -769,171 +768,176 @@ do_action:	/* This label is used only to access EOF actions. */
769 768
 
770 769
 case 1:
771 770
 YY_RULE_SETUP
772
-#line 43 "analyse_lexicale.lex"
771
+#line 55 "analyse_lexicale.lex"
773 772
 {return tADD ;}
774 773
 	YY_BREAK
775 774
 case 2:
776 775
 YY_RULE_SETUP
777
-#line 44 "analyse_lexicale.lex"
776
+#line 56 "analyse_lexicale.lex"
778 777
 {return tSUB ;}
779 778
 	YY_BREAK
780 779
 case 3:
781 780
 YY_RULE_SETUP
782
-#line 45 "analyse_lexicale.lex"
781
+#line 57 "analyse_lexicale.lex"
783 782
 {return tMUL ;}
784 783
 	YY_BREAK
785 784
 case 4:
786 785
 YY_RULE_SETUP
787
-#line 46 "analyse_lexicale.lex"
786
+#line 58 "analyse_lexicale.lex"
788 787
 {return tDIV ;}
789 788
 	YY_BREAK
790 789
 case 5:
791 790
 YY_RULE_SETUP
792
-#line 48 "analyse_lexicale.lex"
791
+#line 60 "analyse_lexicale.lex"
793 792
 {return tPO ;}
794 793
 	YY_BREAK
795 794
 case 6:
796 795
 YY_RULE_SETUP
797
-#line 49 "analyse_lexicale.lex"
796
+#line 61 "analyse_lexicale.lex"
798 797
 {return tPF ;}
799 798
 	YY_BREAK
800 799
 case 7:
801 800
 YY_RULE_SETUP
802
-#line 50 "analyse_lexicale.lex"
801
+#line 62 "analyse_lexicale.lex"
803 802
 {return tAO ;}
804 803
 	YY_BREAK
805 804
 case 8:
806 805
 YY_RULE_SETUP
807
-#line 51 "analyse_lexicale.lex"
806
+#line 63 "analyse_lexicale.lex"
808 807
 {return tAF ;}
809 808
 	YY_BREAK
810 809
 case 9:
811 810
 YY_RULE_SETUP
812
-#line 53 "analyse_lexicale.lex"
811
+#line 65 "analyse_lexicale.lex"
813 812
 {return tPV ;}
814 813
 	YY_BREAK
815 814
 case 10:
816 815
 YY_RULE_SETUP
817
-#line 54 "analyse_lexicale.lex"
816
+#line 66 "analyse_lexicale.lex"
818 817
 {}
819 818
 	YY_BREAK
820 819
 case 11:
821 820
 /* rule 11 can match eol */
822 821
 YY_RULE_SETUP
823
-#line 55 "analyse_lexicale.lex"
822
+#line 67 "analyse_lexicale.lex"
824 823
 {}
825 824
 	YY_BREAK
826 825
 case 12:
827 826
 YY_RULE_SETUP
828
-#line 56 "analyse_lexicale.lex"
827
+#line 68 "analyse_lexicale.lex"
829 828
 {return tVIRGULE ;}
830 829
 	YY_BREAK
831 830
 case 13:
832 831
 YY_RULE_SETUP
833
-#line 58 "analyse_lexicale.lex"
832
+#line 70 "analyse_lexicale.lex"
834 833
 {return tAFFECTATION ;}
835 834
 	YY_BREAK
836 835
 case 14:
837 836
 YY_RULE_SETUP
838
-#line 60 "analyse_lexicale.lex"
837
+#line 72 "analyse_lexicale.lex"
839 838
 {return tEGAL ;}
840 839
 	YY_BREAK
841 840
 case 15:
842 841
 YY_RULE_SETUP
843
-#line 61 "analyse_lexicale.lex"
842
+#line 73 "analyse_lexicale.lex"
844 843
 {return tDIFF ;}
845 844
 	YY_BREAK
846 845
 case 16:
847 846
 YY_RULE_SETUP
848
-#line 62 "analyse_lexicale.lex"
847
+#line 74 "analyse_lexicale.lex"
849 848
 {return tLT ;}
850 849
 	YY_BREAK
851 850
 case 17:
852 851
 YY_RULE_SETUP
853
-#line 63 "analyse_lexicale.lex"
852
+#line 75 "analyse_lexicale.lex"
854 853
 {return tGT ;}
855 854
 	YY_BREAK
856 855
 case 18:
857 856
 YY_RULE_SETUP
858
-#line 64 "analyse_lexicale.lex"
857
+#line 76 "analyse_lexicale.lex"
859 858
 {return tLTE ;}
860 859
 	YY_BREAK
861 860
 case 19:
862 861
 YY_RULE_SETUP
863
-#line 65 "analyse_lexicale.lex"
862
+#line 77 "analyse_lexicale.lex"
864 863
 {return tGTE ;}
865 864
 	YY_BREAK
866 865
 case 20:
867 866
 YY_RULE_SETUP
868
-#line 66 "analyse_lexicale.lex"
867
+#line 78 "analyse_lexicale.lex"
869 868
 {return tNOT ;}
870 869
 	YY_BREAK
871 870
 case 21:
872 871
 YY_RULE_SETUP
873
-#line 69 "analyse_lexicale.lex"
872
+#line 81 "analyse_lexicale.lex"
874 873
 {return tMAIN ;}
875 874
 	YY_BREAK
876 875
 case 22:
877 876
 YY_RULE_SETUP
878
-#line 70 "analyse_lexicale.lex"
877
+#line 82 "analyse_lexicale.lex"
879 878
 {return tINT ;}
880 879
 	YY_BREAK
881 880
 case 23:
882 881
 YY_RULE_SETUP
883
-#line 71 "analyse_lexicale.lex"
882
+#line 83 "analyse_lexicale.lex"
884 883
 {return tPRINT ;}
885 884
 	YY_BREAK
886 885
 case 24:
887 886
 YY_RULE_SETUP
888
-#line 72 "analyse_lexicale.lex"
887
+#line 84 "analyse_lexicale.lex"
889 888
 {return tRETURN ;}
890 889
 	YY_BREAK
891 890
 case 25:
892 891
 YY_RULE_SETUP
893
-#line 74 "analyse_lexicale.lex"
892
+#line 86 "analyse_lexicale.lex"
894 893
 {return tOR ;}
895 894
 	YY_BREAK
896 895
 case 26:
897 896
 YY_RULE_SETUP
898
-#line 75 "analyse_lexicale.lex"
897
+#line 87 "analyse_lexicale.lex"
899 898
 {return tAND ;}
900 899
 	YY_BREAK
901 900
 case 27:
902 901
 YY_RULE_SETUP
903
-#line 77 "analyse_lexicale.lex"
902
+#line 89 "analyse_lexicale.lex"
904 903
 {return tIF ;}
905 904
 	YY_BREAK
906 905
 case 28:
907 906
 YY_RULE_SETUP
908
-#line 78 "analyse_lexicale.lex"
907
+#line 90 "analyse_lexicale.lex"
909 908
 {return tELSE ;}
910 909
 	YY_BREAK
911 910
 case 29:
912 911
 YY_RULE_SETUP
913
-#line 79 "analyse_lexicale.lex"
912
+#line 91 "analyse_lexicale.lex"
914 913
 {return tWHILE ;}
915 914
 	YY_BREAK
916 915
 case 30:
917 916
 YY_RULE_SETUP
918
-#line 81 "analyse_lexicale.lex"
917
+#line 93 "analyse_lexicale.lex"
919 918
 {return tCONST ;}
920 919
 	YY_BREAK
921 920
 case 31:
922 921
 YY_RULE_SETUP
923
-#line 82 "analyse_lexicale.lex"
924
-{return tENTIER ;}
922
+#line 94 "analyse_lexicale.lex"
923
+{yylval.nombre = atoi(yytext); return tENTIER ;}
925 924
 	YY_BREAK
926 925
 case 32:
927 926
 YY_RULE_SETUP
928
-#line 83 "analyse_lexicale.lex"
929
-{return tVAR ;}
927
+#line 95 "analyse_lexicale.lex"
928
+{yylval.nombre = -1; return tENTIEREXP;}
930 929
 	YY_BREAK
931 930
 case 33:
932 931
 YY_RULE_SETUP
933
-#line 85 "analyse_lexicale.lex"
932
+#line 96 "analyse_lexicale.lex"
933
+{strcpy(yylval.id, yytext); return tVAR  ;}
934
+	YY_BREAK
935
+case 34:
936
+YY_RULE_SETUP
937
+#line 98 "analyse_lexicale.lex"
934 938
 ECHO;
935 939
 	YY_BREAK
936
-#line 937 "lex.yy.c"
940
+#line 941 "lex.yy.c"
937 941
 case YY_STATE_EOF(INITIAL):
938 942
 	yyterminate();
939 943
 
@@ -1938,11 +1942,9 @@ void yyfree (void * ptr )
1938 1942
 
1939 1943
 #define YYTABLES_NAME "yytables"
1940 1944
 
1941
-#line 85 "analyse_lexicale.lex"
1945
+#line 98 "analyse_lexicale.lex"
1946
+
1942 1947
 
1943
-int yywrap(void){
1944
-    return 1;
1945
-}
1946 1948
 //int main(void){
1947 1949
 //    yylex();
1948 1950
 //}

+ 64
- 0
poubelle/as.y View File

@@ -0,0 +1,64 @@
1
+%union {
2
+int nombre;
3
+}
4
+
5
+%token tENTIER
6
+%token tADD
7
+%token tSUB
8
+%token tMUL
9
+%token tDIV
10
+
11
+%token tPO
12
+%token tPF
13
+%token tAO
14
+%token tAF
15
+
16
+%token tERROR
17
+
18
+%token tPV
19
+%token tVIRGULE
20
+%token tAFFECTATION
21
+%token tEGAL
22
+%token tDIFF
23
+%token tLT
24
+%token tGT
25
+%token tGTE
26
+%token tLTE
27
+%token tMAIN
28
+%token tINT
29
+%token tPRINT
30
+%token tRETURN
31
+%token tOR
32
+%token tAND
33
+%token tIF
34
+%token tELSE
35
+%token tWHILE
36
+%token tCONST
37
+%token tVAR
38
+%token tNOT
39
+
40
+%left tADD
41
+%left tSUB
42
+%left tMUL
43
+%left tDIV
44
+%right tEGAL
45
+
46
+
47
+%%
48
+
49
+Prog : tINT tMAIN tPO tPF Body {printf("Dans main\n");};
50
+
51
+
52
+Body : tAO Instructions Return tAF ;
53
+
54
+Instructions : Instruction Instructions | ;
55
+
56
+Instruction : Print ;
57
+
58
+Type : tINT | tCONST tINT ; 
59
+
60
+Valeur : tVAR | Affbis ;
61
+
62
+Affbis : tVAR tAFFECTATION E;
63
+
64
+Aff : Affbis tPV ;

+ 1956
- 0
poubelle/lex.yy.c
File diff suppressed because it is too large
View File


test → poubelle/test View File


+ 1474
- 0
poubelle/y.output
File diff suppressed because it is too large
View File


+ 1705
- 0
poubelle/y.tab.c
File diff suppressed because it is too large
View File


+ 137
- 0
poubelle/y.tab.h View File

@@ -0,0 +1,137 @@
1
+/* A Bison parser, made by GNU Bison 3.0.4.  */
2
+
3
+/* Bison interface for Yacc-like parsers in C
4
+
5
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
+
7
+   This program is free software: you can redistribute it and/or modify
8
+   it under the terms of the GNU General Public License as published by
9
+   the Free Software Foundation, either version 3 of the License, or
10
+   (at your option) any later version.
11
+
12
+   This program is distributed in the hope that it will be useful,
13
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+   GNU General Public License for more details.
16
+
17
+   You should have received a copy of the GNU General Public License
18
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
+
20
+/* As a special exception, you may create a larger work that contains
21
+   part or all of the Bison parser skeleton and distribute that work
22
+   under terms of your choice, so long as that work isn't itself a
23
+   parser generator using the skeleton or a modified version thereof
24
+   as a parser skeleton.  Alternatively, if you modify or redistribute
25
+   the parser skeleton itself, you may (at your option) remove this
26
+   special exception, which will cause the skeleton and the resulting
27
+   Bison output files to be licensed under the GNU General Public
28
+   License without this special exception.
29
+
30
+   This special exception was added by the Free Software Foundation in
31
+   version 2.2 of Bison.  */
32
+
33
+#ifndef YY_YY_Y_TAB_H_INCLUDED
34
+# define YY_YY_Y_TAB_H_INCLUDED
35
+/* Debug traces.  */
36
+#ifndef YYDEBUG
37
+# define YYDEBUG 1
38
+#endif
39
+#if YYDEBUG
40
+extern int yydebug;
41
+#endif
42
+
43
+/* Token type.  */
44
+#ifndef YYTOKENTYPE
45
+# define YYTOKENTYPE
46
+  enum yytokentype
47
+  {
48
+    tENTIER = 258,
49
+    tADD = 259,
50
+    tSUB = 260,
51
+    tMUL = 261,
52
+    tDIV = 262,
53
+    tPO = 263,
54
+    tPF = 264,
55
+    tAO = 265,
56
+    tAF = 266,
57
+    tERROR = 267,
58
+    tPV = 268,
59
+    tVIRGULE = 269,
60
+    tAFFECTATION = 270,
61
+    tEGAL = 271,
62
+    tDIFF = 272,
63
+    tLT = 273,
64
+    tGT = 274,
65
+    tGTE = 275,
66
+    tLTE = 276,
67
+    tMAIN = 277,
68
+    tINT = 278,
69
+    tPRINT = 279,
70
+    tRETURN = 280,
71
+    tOR = 281,
72
+    tAND = 282,
73
+    tIF = 283,
74
+    tELSE = 284,
75
+    tWHILE = 285,
76
+    tCONST = 286,
77
+    tVAR = 287,
78
+    tNOT = 288
79
+  };
80
+#endif
81
+/* Tokens.  */
82
+#define tENTIER 258
83
+#define tADD 259
84
+#define tSUB 260
85
+#define tMUL 261
86
+#define tDIV 262
87
+#define tPO 263
88
+#define tPF 264
89
+#define tAO 265
90
+#define tAF 266
91
+#define tERROR 267
92
+#define tPV 268
93
+#define tVIRGULE 269
94
+#define tAFFECTATION 270
95
+#define tEGAL 271
96
+#define tDIFF 272
97
+#define tLT 273
98
+#define tGT 274
99
+#define tGTE 275
100
+#define tLTE 276
101
+#define tMAIN 277
102
+#define tINT 278
103
+#define tPRINT 279
104
+#define tRETURN 280
105
+#define tOR 281
106
+#define tAND 282
107
+#define tIF 283
108
+#define tELSE 284
109
+#define tWHILE 285
110
+#define tCONST 286
111
+#define tVAR 287
112
+#define tNOT 288
113
+
114
+/* Value type.  */
115
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
116
+
117
+union YYSTYPE
118
+{
119
+#line 1 "analyse_syntaxique.y" /* yacc.c:1909  */
120
+
121
+int nombre;
122
+char id[30];
123
+
124
+#line 125 "y.tab.h" /* yacc.c:1909  */
125
+};
126
+
127
+typedef union YYSTYPE YYSTYPE;
128
+# define YYSTYPE_IS_TRIVIAL 1
129
+# define YYSTYPE_IS_DECLARED 1
130
+#endif
131
+
132
+
133
+extern YYSTYPE yylval;
134
+
135
+int yyparse (void);
136
+
137
+#endif /* !YY_YY_Y_TAB_H_INCLUDED  */

+ 5
- 22
script.sh View File

@@ -1,31 +1,14 @@
1 1
 bison -d -t analyse_syntaxique.y -v
2 2
 flex analyse_lexicale.lex 
3
-gcc *.c -ly
3
+gcc -w *.c -ly
4 4
 echo "
5
-    int fonction1(int toto){
6
-    toto = toto + 1 ;
7
-    return toto;
8
-    }
9
-
10
-    int fonction2(){
11
-        int i = 0;
12
-        while (i <= 2){
13
-            printf(i);
14
-            i = i +1 ;
15
-        }
16
-        return i;
17
-    }
18
-
19 5
     int main(){
20 6
         const int toto = 1, mimi, lolo = 6;
21 7
         int tata = 5, lala;
22
-
23
-        if (tata == 5){
24
-            fonction1(lolo);
25
-        } else if (toto == 1){
26
-            fonction2();
27
-        }
28
-
8
+        while (tata == 5){
9
+            printf(tata);
10
+            lala = lolo + 6;
11
+        } 
29 12
         return 1;
30 13
     }
31 14
 " | ./a.out

Loading…
Cancel
Save