Browse Source

Analyse grammaticale ok*

Tali Elies 8 months ago
parent
commit
524b766ac4

BIN
Analyse_Lexicale/a.out View File


+ 33
- 27
Analyse_Lexicale/al.lex View File

@@ -1,38 +1,44 @@
1 1
 %{
2 2
 #include "as.tab.h"
3
-#include <stdio.h>
3
+int yywrap(void){return 1;}
4 4
 %}
5 5
 
6 6
 %%
7 7
 
8
-"main"      { printf("tMAIN\n");} 
9
-"{"         { printf("tOBRACKET\n"); }
10
-"}"         { printf("tCBRACKET\n"); }
11
-"("			{ printf("tOBRACE\n"); }
12
-")"			{ printf("tCBRACE\n"); }
13
-"const"     { printf("tCONST\n"); }
14
-"int"       { printf("tINT\n"); }
15
-"printf"    { printf("tPRINTF\n"); } //Degeu mais à degager
16
-
17
-
18
-
19
-
20
-[0-9]+	{ printf("tNB\n"); }
21
-[0-9]+e[0-9]+	{ printf("tNBEXP\n"); } //Renvoyer le token tNB et pas tNBEXP
22
-"+"			{ printf("tADD\n"); }
23
-"-"			{ printf("tSUB\n"); }
24
-"*"         { printf("tMUL\n"); }
25
-"/"         { printf("tDIV\n"); }
26
-"="         { printf("tEQ\n"); }
27
-";"			{ printf("tPV\n"); }
28
-" "			{ printf("tSPACE\n"); } //Ne pas les retourner à Yacc
29
-"   "       { printf("tTAB\n"); } //Ne pas les retourner à Yacc
30
-","         { printf("tCOMA\n"); }
31
-"\n"        { printf("tRC\n") ; } //Ne pas les retourner à Yacc
32
-[a-zA-Z][a-zA-Z0-9_]* { printf("tID\n"); }
8
+"main"      { return tMAIN ;} 
9
+"{"         { return tOBRACKET;}
10
+"}"         { return tCBRACKET; }
11
+"("			{ return tOBRACE; }
12
+")"			{ return tCBRACE; }
13
+"const"     { return tCONST; }
14
+"int"       { return tINT; }
15
+"printf"    { return tPRINTF; } //Degeu mais à degager
16
+"if"        { return tIF; }
17
+"while"     { return tWHILE; }
18
+"<"         { return tLT; }
19
+">"         { return tGT; }
20
+"=="        { return tEQCOND; }
21
+"&&"        { return tAND; }
22
+"||"        { return tOR; }
23
+"else"      { return tELSE;}
24
+
25
+
26
+[0-9]+	{ yylval.nombre = atoi(yytext); return tNB; }
27
+[0-9]+e[0-9]+	{ yylval.nombre = -1; return tNBEXP; } //Renvoyer le token tNB et pas tNBEXP
28
+"+"			{ return tADD; }
29
+"-"			{ return tSUB; }
30
+"*"         { return tMUL; }
31
+"/"         { return tDIV; }
32
+"="         { return tEQ; }
33
+";"			{ return tPV; }
34
+" "			{} //Ne pas les retourner à Yacc
35
+"   "       {} //Ne pas les retourner à Yacc
36
+","         { return tCOMA; }
37
+"/*"[^(*/)]*"*/" { printf("commentaire\n");}
38
+"\n"        {} //Ne pas les retourner à Yacc
39
+[a-zA-Z][a-zA-Z0-9_]* { strcpy(yylval.id, yytext); return tID; }
33 40
 .				{ return tERROR; }
34 41
 
35 42
 %%
36 43
 
37 44
 
38
-int yywrap(void){return 1;}

+ 207
- 65
Analyse_Lexicale/as.tab.c View File

@@ -98,14 +98,33 @@ extern int yydebug;
98 98
 # define YYTOKENTYPE
99 99
   enum yytokentype
100 100
   {
101
-    tNB = 258,
102
-    tADD = 259,
103
-    tSUB = 260,
104
-    tOB = 261,
105
-    tCB = 262,
106
-    tPV = 263,
107
-    tERROR = 264,
108
-    tMAIN = 265
101
+    tMAIN = 258,
102
+    tOBRACKET = 259,
103
+    tCBRACKET = 260,
104
+    tOBRACE = 261,
105
+    tCBRACE = 262,
106
+    tINT = 263,
107
+    tCONST = 264,
108
+    tPV = 265,
109
+    tCOMA = 266,
110
+    tMUL = 267,
111
+    tDIV = 268,
112
+    tADD = 269,
113
+    tSUB = 270,
114
+    tEQ = 271,
115
+    tNB = 272,
116
+    tNBEXP = 273,
117
+    tID = 274,
118
+    tPRINTF = 275,
119
+    tERROR = 276,
120
+    tIF = 277,
121
+    tWHILE = 278,
122
+    tELSE = 279,
123
+    tLT = 280,
124
+    tGT = 281,
125
+    tEQCOND = 282,
126
+    tAND = 283,
127
+    tOR = 284
109 128
   };
110 129
 #endif
111 130
 
@@ -117,8 +136,9 @@ union YYSTYPE
117 136
 #line 1 "as.y" /* yacc.c:355  */
118 137
 
119 138
 	int nombre;
139
+    char id[30];
120 140
 
121
-#line 122 "as.tab.c" /* yacc.c:355  */
141
+#line 142 "as.tab.c" /* yacc.c:355  */
122 142
 };
123 143
 
124 144
 typedef union YYSTYPE YYSTYPE;
@@ -134,8 +154,11 @@ int yyparse (void);
134 154
 #endif /* !YY_YY_AS_TAB_H_INCLUDED  */
135 155
 
136 156
 /* Copy the second part of user declarations.  */
157
+#line 5 "as.y" /* yacc.c:358  */
137 158
 
138
-#line 139 "as.tab.c" /* yacc.c:358  */
159
+#include <stdio.h>
160
+
161
+#line 162 "as.tab.c" /* yacc.c:358  */
139 162
 
140 163
 #ifdef short
141 164
 # undef short
@@ -375,23 +398,23 @@ union yyalloc
375 398
 #endif /* !YYCOPY_NEEDED */
376 399
 
377 400
 /* YYFINAL -- State number of the termination state.  */
378
-#define YYFINAL  6
401
+#define YYFINAL  4
379 402
 /* YYLAST -- Last index in YYTABLE.  */
380
-#define YYLAST   15
403
+#define YYLAST   117
381 404
 
382 405
 /* YYNTOKENS -- Number of terminals.  */
383
-#define YYNTOKENS  11
406
+#define YYNTOKENS  30
384 407
 /* YYNNTS -- Number of nonterminals.  */
385
-#define YYNNTS  4
408
+#define YYNNTS  19
386 409
 /* YYNRULES -- Number of rules.  */
387
-#define YYNRULES  8
410
+#define YYNRULES  45
388 411
 /* YYNSTATES -- Number of states.  */
389
-#define YYNSTATES  15
412
+#define YYNSTATES  98
390 413
 
391 414
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
392 415
    by yylex, with out-of-bounds checking.  */
393 416
 #define YYUNDEFTOK  2
394
-#define YYMAXUTOK   265
417
+#define YYMAXUTOK   284
395 418
 
396 419
 #define YYTRANSLATE(YYX)                                                \
397 420
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -426,14 +449,20 @@ static const yytype_uint8 yytranslate[] =
426 449
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427 450
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
428 451
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
429
-       5,     6,     7,     8,     9,    10
452
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
453
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
454
+      25,    26,    27,    28,    29
430 455
 };
431 456
 
432 457
 #if YYDEBUG
433 458
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
434 459
 static const yytype_uint8 yyrline[] =
435 460
 {
436
-       0,    30,    30,    29,    32,    35,    36,    37,    38
461
+       0,    28,    28,    30,    31,    32,    33,    34,    36,    39,
462
+      40,    41,    42,    43,    44,    45,    48,    49,    50,    51,
463
+      52,    54,    55,    56,    57,    60,    62,    63,    64,    65,
464
+      66,    67,    68,    69,    70,    71,    72,    73,    74,    77,
465
+      78,    79,    80,    81,    82,    84
437 466
 };
438 467
 #endif
439 468
 
@@ -442,8 +471,14 @@ static const yytype_uint8 yyrline[] =
442 471
    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
443 472
 static const char *const yytname[] =
444 473
 {
445
-  "$end", "error", "$undefined", "tNB", "tADD", "tSUB", "tOB", "tCB",
446
-  "tPV", "tERROR", "tMAIN", "$accept", "S", "$@1", "E", YY_NULLPTR
474
+  "$end", "error", "$undefined", "tMAIN", "tOBRACKET", "tCBRACKET",
475
+  "tOBRACE", "tCBRACE", "tINT", "tCONST", "tPV", "tCOMA", "tMUL", "tDIV",
476
+  "tADD", "tSUB", "tEQ", "tNB", "tNBEXP", "tID", "tPRINTF", "tERROR",
477
+  "tIF", "tWHILE", "tELSE", "tLT", "tGT", "tEQCOND", "tAND", "tOR",
478
+  "$accept", "Main", "Params", "Param", "SuiteParams", "Body",
479
+  "Instructions", "Instruction", "If", "Else", "While", "Cond",
480
+  "SuiteCond", "Aff", "E", "Decl", "SuiteDecl", "FinDeclaration",
481
+  "Invocation", YY_NULLPTR
447 482
 };
448 483
 #endif
449 484
 
@@ -453,14 +488,15 @@ static const char *const yytname[] =
453 488
 static const yytype_uint16 yytoknum[] =
454 489
 {
455 490
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
456
-     265
491
+     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
492
+     275,   276,   277,   278,   279,   280,   281,   282,   283,   284
457 493
 };
458 494
 # endif
459 495
 
460
-#define YYPACT_NINF -4
496
+#define YYPACT_NINF -68
461 497
 
462 498
 #define yypact_value_is_default(Yystate) \
463
-  (!!((Yystate) == (-4)))
499
+  (!!((Yystate) == (-68)))
464 500
 
465 501
 #define YYTABLE_NINF -1
466 502
 
@@ -471,8 +507,16 @@ static const yytype_uint16 yytoknum[] =
471 507
      STATE-NUM.  */
472 508
 static const yytype_int8 yypact[] =
473 509
 {
474
-       7,    -4,     7,     1,    -1,     4,    -4,     7,     7,    -4,
475
-      -4,    -3,    -4,     7,    -4
510
+       9,     2,    22,    30,   -68,    20,    18,    39,    40,   -68,
511
+      48,    20,   -68,    73,   -68,    40,    45,    50,    43,    64,
512
+      69,    70,    72,    73,   -68,   -68,   -68,   -68,    81,   -68,
513
+      86,    79,    88,    80,    88,    88,   -68,   -68,   -68,    85,
514
+      -7,    86,    88,    88,   -68,   -68,   -68,    35,   -68,    76,
515
+     102,    28,   103,    86,   -68,    88,   -68,    95,     0,    75,
516
+     -68,    88,    88,    88,    88,    88,    88,    88,   -68,    48,
517
+      88,    88,   -68,    48,   -68,    53,    88,   -68,    75,    75,
518
+      75,    75,    75,    75,    75,    89,    28,    28,   -68,   -68,
519
+      59,    -3,   -68,   -68,   -68,   -68,   -68,   -68
476 520
 };
477 521
 
478 522
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -480,20 +524,30 @@ static const yytype_int8 yypact[] =
480 524
      means the default is an error.  */
481 525
 static const yytype_uint8 yydefact[] =
482 526
 {
483
-       4,     8,     0,     0,     0,     0,     1,     0,     0,     2,
484
-       7,     5,     6,     4,     3
527
+       0,     0,     0,     0,     1,     3,     0,     0,     7,     5,
528
+       0,     0,     4,    10,     2,     7,     0,     0,     0,     0,
529
+       0,     0,     0,    10,    14,    15,    11,    12,     0,     6,
530
+      42,     0,     0,     0,     0,     0,     8,     9,    13,     0,
531
+       0,    42,     0,     0,    26,    27,    28,     0,    33,     0,
532
+       0,    22,     0,    42,    44,     0,    39,     0,     0,    35,
533
+      25,     0,     0,     0,     0,     0,     0,     0,    45,     0,
534
+       0,     0,    21,     0,    41,     0,     0,    34,    30,    32,
535
+      29,    31,    38,    37,    36,    19,    22,    22,    20,    43,
536
+       0,     0,    16,    23,    24,    40,    18,    17
485 537
 };
486 538
 
487 539
   /* YYPGOTO[NTERM-NUM].  */
488 540
 static const yytype_int8 yypgoto[] =
489 541
 {
490
-      -4,     2,    -4,    -2
542
+     -68,   -68,   -68,   101,    99,   -67,    92,   -68,    25,   -68,
543
+     -68,    82,   -66,   -68,   -32,   -68,   -37,   -68,    -5
491 544
 };
492 545
 
493 546
   /* YYDEFGOTO[NTERM-NUM].  */
494 547
 static const yytype_int8 yydefgoto[] =
495 548
 {
496
-      -1,     3,    13,     4
549
+      -1,     2,     7,     8,    12,    14,    22,    23,    24,    92,
550
+      25,    50,    72,    26,    51,    27,    40,    56,    48
497 551
 };
498 552
 
499 553
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -501,34 +555,70 @@ static const yytype_int8 yydefgoto[] =
501 555
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
502 556
 static const yytype_uint8 yytable[] =
503 557
 {
504
-       5,     6,     8,     7,     8,    11,    12,     9,     7,     8,
505
-       1,    10,     0,     2,     0,    14
558
+      47,    13,    85,    54,    57,     3,    88,    77,    28,    55,
559
+      58,    59,    61,    62,    63,    64,    74,     1,    28,    20,
560
+      93,    94,     4,    75,    96,    65,    66,    67,     6,    78,
561
+      79,    80,    81,    82,    83,    84,     5,     9,    86,    87,
562
+      61,    62,    63,    64,    90,    60,    10,    61,    62,    63,
563
+      64,    11,    13,    65,    66,    67,    70,    71,    31,    32,
564
+      65,    66,    67,    89,    30,    61,    62,    63,    64,    95,
565
+      33,    61,    62,    63,    64,    34,    35,    36,    65,    66,
566
+      67,    16,    17,    68,    65,    66,    67,    61,    62,    63,
567
+      64,    38,    18,    19,    42,    20,    21,    39,    41,    49,
568
+      65,    66,    67,    43,    53,    44,    45,    46,    19,    69,
569
+      73,    76,    15,    91,    29,    37,    97,    52
506 570
 };
507 571
 
508
-static const yytype_int8 yycheck[] =
572
+static const yytype_uint8 yycheck[] =
509 573
 {
510
-       2,     0,     5,     4,     5,     7,     8,     8,     4,     5,
511
-       3,     7,    -1,     6,    -1,    13
574
+      32,     4,    69,    10,    41,     3,    73,     7,    13,    16,
575
+      42,    43,    12,    13,    14,    15,    53,     8,    23,    22,
576
+      86,    87,     0,    55,    91,    25,    26,    27,     8,    61,
577
+      62,    63,    64,    65,    66,    67,     6,    19,    70,    71,
578
+      12,    13,    14,    15,    76,    10,     7,    12,    13,    14,
579
+      15,    11,     4,    25,    26,    27,    28,    29,     8,    16,
580
+      25,    26,    27,    10,    19,    12,    13,    14,    15,    10,
581
+       6,    12,    13,    14,    15,     6,     6,     5,    25,    26,
582
+      27,     8,     9,     7,    25,    26,    27,    12,    13,    14,
583
+      15,    10,    19,    20,     6,    22,    23,    11,    19,    19,
584
+      25,    26,    27,    15,    19,    17,    18,    19,    20,     7,
585
+       7,    16,    11,    24,    15,    23,    91,    35
512 586
 };
513 587
 
514 588
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
515 589
      symbol of state STATE-NUM.  */
516 590
 static const yytype_uint8 yystos[] =
517 591
 {
518
-       0,     3,     6,    12,    14,    14,     0,     4,     5,     8,
519
-       7,    14,    14,    13,    12
592
+       0,     8,    31,     3,     0,     6,     8,    32,    33,    19,
593
+       7,    11,    34,     4,    35,    33,     8,     9,    19,    20,
594
+      22,    23,    36,    37,    38,    40,    43,    45,    48,    34,
595
+      19,     8,    16,     6,     6,     6,     5,    36,    10,    11,
596
+      46,    19,     6,    15,    17,    18,    19,    44,    48,    19,
597
+      41,    44,    41,    19,    10,    16,    47,    46,    44,    44,
598
+      10,    12,    13,    14,    15,    25,    26,    27,     7,     7,
599
+      28,    29,    42,     7,    46,    44,    16,     7,    44,    44,
600
+      44,    44,    44,    44,    44,    35,    44,    44,    35,    10,
601
+      44,    24,    39,    42,    42,    10,    35,    38
520 602
 };
521 603
 
522 604
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
523 605
 static const yytype_uint8 yyr1[] =
524 606
 {
525
-       0,    11,    13,    12,    12,    14,    14,    14,    14
607
+       0,    30,    31,    32,    32,    33,    34,    34,    35,    36,
608
+      36,    37,    37,    37,    37,    37,    38,    39,    39,    39,
609
+      40,    41,    42,    42,    42,    43,    44,    44,    44,    44,
610
+      44,    44,    44,    44,    44,    44,    44,    44,    44,    45,
611
+      45,    46,    46,    47,    47,    48
526 612
 };
527 613
 
528 614
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
529 615
 static const yytype_uint8 yyr2[] =
530 616
 {
531
-       0,     2,     0,     4,     0,     3,     3,     3,     1
617
+       0,     2,     6,     0,     2,     2,     3,     0,     3,     2,
618
+       0,     1,     1,     2,     1,     1,     6,     2,     2,     0,
619
+       5,     2,     0,     3,     3,     4,     1,     1,     1,     3,
620
+       3,     3,     3,     1,     3,     2,     3,     3,     3,     4,
621
+       7,     3,     0,     3,     1,     4
532 622
 };
533 623
 
534 624
 
@@ -1205,43 +1295,97 @@ yyreduce:
1205 1295
   switch (yyn)
1206 1296
     {
1207 1297
         case 2:
1208
-#line 30 "as.y" /* yacc.c:1646  */
1209
-    { printf("RES: %d\n", (yyvsp[-1].nombre)); }
1210
-#line 1211 "as.tab.c" /* yacc.c:1646  */
1298
+#line 28 "as.y" /* yacc.c:1646  */
1299
+    { printf("Main reconnu\n"); }
1300
+#line 1301 "as.tab.c" /* yacc.c:1646  */
1211 1301
     break;
1212 1302
 
1213
-  case 4:
1214
-#line 32 "as.y" /* yacc.c:1646  */
1215
-    { printf("END\n"); }
1216
-#line 1217 "as.tab.c" /* yacc.c:1646  */
1303
+  case 3:
1304
+#line 30 "as.y" /* yacc.c:1646  */
1305
+    { printf("Sans Params\n"); }
1306
+#line 1307 "as.tab.c" /* yacc.c:1646  */
1217 1307
     break;
1218 1308
 
1219 1309
   case 5:
1220
-#line 35 "as.y" /* yacc.c:1646  */
1221
-    { (yyval.nombre) = (yyvsp[-2].nombre) + (yyvsp[0].nombre); }
1222
-#line 1223 "as.tab.c" /* yacc.c:1646  */
1310
+#line 32 "as.y" /* yacc.c:1646  */
1311
+    { printf("Prametre : %s\n", (yyvsp[0].id)); }
1312
+#line 1313 "as.tab.c" /* yacc.c:1646  */
1223 1313
     break;
1224 1314
 
1225
-  case 6:
1315
+  case 8:
1226 1316
 #line 36 "as.y" /* yacc.c:1646  */
1227
-    { (yyval.nombre) = (yyvsp[-2].nombre) - (yyvsp[0].nombre); }
1228
-#line 1229 "as.tab.c" /* yacc.c:1646  */
1317
+    { printf("Body reconnu\n"); }
1318
+#line 1319 "as.tab.c" /* yacc.c:1646  */
1229 1319
     break;
1230 1320
 
1231
-  case 7:
1232
-#line 37 "as.y" /* yacc.c:1646  */
1233
-    { (yyval.nombre) = (yyvsp[-1].nombre); }
1234
-#line 1235 "as.tab.c" /* yacc.c:1646  */
1321
+  case 16:
1322
+#line 48 "as.y" /* yacc.c:1646  */
1323
+    { printf("If reconnu\n"); }
1324
+#line 1325 "as.tab.c" /* yacc.c:1646  */
1235 1325
     break;
1236 1326
 
1237
-  case 8:
1238
-#line 38 "as.y" /* yacc.c:1646  */
1239
-    { (yyval.nombre) = (yyvsp[0].nombre); }
1240
-#line 1241 "as.tab.c" /* yacc.c:1646  */
1327
+  case 17:
1328
+#line 49 "as.y" /* yacc.c:1646  */
1329
+    { printf("Else if reconnu\n"); }
1330
+#line 1331 "as.tab.c" /* yacc.c:1646  */
1241 1331
     break;
1242 1332
 
1333
+  case 18:
1334
+#line 50 "as.y" /* yacc.c:1646  */
1335
+    { printf("Else reconnu\n"); }
1336
+#line 1337 "as.tab.c" /* yacc.c:1646  */
1337
+    break;
1338
+
1339
+  case 20:
1340
+#line 52 "as.y" /* yacc.c:1646  */
1341
+    { printf("While reconnu\n"); }
1342
+#line 1343 "as.tab.c" /* yacc.c:1646  */
1343
+    break;
1344
+
1345
+  case 25:
1346
+#line 60 "as.y" /* yacc.c:1646  */
1347
+    { printf("%s prend une valeur\n", (yyvsp[-3].id)); }
1348
+#line 1349 "as.tab.c" /* yacc.c:1646  */
1349
+    break;
1350
+
1351
+  case 39:
1352
+#line 77 "as.y" /* yacc.c:1646  */
1353
+    { printf("Declaration de %s\n", (yyvsp[-2].id)); }
1354
+#line 1355 "as.tab.c" /* yacc.c:1646  */
1355
+    break;
1243 1356
 
1244
-#line 1245 "as.tab.c" /* yacc.c:1646  */
1357
+  case 40:
1358
+#line 78 "as.y" /* yacc.c:1646  */
1359
+    { printf("Declaration de %s (CONSTANTE)\n", (yyvsp[-4].id)); }
1360
+#line 1361 "as.tab.c" /* yacc.c:1646  */
1361
+    break;
1362
+
1363
+  case 41:
1364
+#line 79 "as.y" /* yacc.c:1646  */
1365
+    { printf("Declaration de %s\n", (yyvsp[-1].id)); }
1366
+#line 1367 "as.tab.c" /* yacc.c:1646  */
1367
+    break;
1368
+
1369
+  case 43:
1370
+#line 81 "as.y" /* yacc.c:1646  */
1371
+    { printf("Declaration avec valeur\n"); }
1372
+#line 1373 "as.tab.c" /* yacc.c:1646  */
1373
+    break;
1374
+
1375
+  case 44:
1376
+#line 82 "as.y" /* yacc.c:1646  */
1377
+    { printf("Declaration sans valeur\n"); }
1378
+#line 1379 "as.tab.c" /* yacc.c:1646  */
1379
+    break;
1380
+
1381
+  case 45:
1382
+#line 84 "as.y" /* yacc.c:1646  */
1383
+    { printf("Appel de printf sur %s\n", (yyvsp[-1].id)); }
1384
+#line 1385 "as.tab.c" /* yacc.c:1646  */
1385
+    break;
1386
+
1387
+
1388
+#line 1389 "as.tab.c" /* yacc.c:1646  */
1245 1389
       default: break;
1246 1390
     }
1247 1391
   /* User semantic actions sometimes alter yychar, and that requires
@@ -1469,11 +1613,9 @@ yyreturn:
1469 1613
 #endif
1470 1614
   return yyresult;
1471 1615
 }
1472
-#line 41 "as.y" /* yacc.c:1906  */
1473
-
1474
-
1475
-int yywrap(void){return 1;}
1616
+#line 98 "as.y" /* yacc.c:1906  */
1476 1617
 
1618
+#include <stdio.h> 
1477 1619
 void main(void) {
1478 1620
 	yyparse();
1479 1621
 }

+ 29
- 9
Analyse_Lexicale/as.tab.h View File

@@ -45,14 +45,33 @@ extern int yydebug;
45 45
 # define YYTOKENTYPE
46 46
   enum yytokentype
47 47
   {
48
-    tNB = 258,
49
-    tADD = 259,
50
-    tSUB = 260,
51
-    tOB = 261,
52
-    tCB = 262,
53
-    tPV = 263,
54
-    tERROR = 264,
55
-    tMAIN = 265
48
+    tMAIN = 258,
49
+    tOBRACKET = 259,
50
+    tCBRACKET = 260,
51
+    tOBRACE = 261,
52
+    tCBRACE = 262,
53
+    tINT = 263,
54
+    tCONST = 264,
55
+    tPV = 265,
56
+    tCOMA = 266,
57
+    tMUL = 267,
58
+    tDIV = 268,
59
+    tADD = 269,
60
+    tSUB = 270,
61
+    tEQ = 271,
62
+    tNB = 272,
63
+    tNBEXP = 273,
64
+    tID = 274,
65
+    tPRINTF = 275,
66
+    tERROR = 276,
67
+    tIF = 277,
68
+    tWHILE = 278,
69
+    tELSE = 279,
70
+    tLT = 280,
71
+    tGT = 281,
72
+    tEQCOND = 282,
73
+    tAND = 283,
74
+    tOR = 284
56 75
   };
57 76
 #endif
58 77
 
@@ -64,8 +83,9 @@ union YYSTYPE
64 83
 #line 1 "as.y" /* yacc.c:1909  */
65 84
 
66 85
 	int nombre;
86
+    char id[30];
67 87
 
68
-#line 69 "as.tab.h" /* yacc.c:1909  */
88
+#line 89 "as.tab.h" /* yacc.c:1909  */
69 89
 };
70 90
 
71 91
 typedef union YYSTYPE YYSTYPE;

+ 68
- 10
Analyse_Lexicale/as.y View File

@@ -1,6 +1,10 @@
1 1
 %union {
2 2
 	int nombre;
3
+    char id[30];
3 4
 }
5
+%{
6
+#include <stdio.h>
7
+%}
4 8
 
5 9
 %token tMAIN
6 10
 %token tOBRACKET tCBRACKET
@@ -10,22 +14,76 @@
10 14
 %token tPV tCOMA
11 15
 %token tMUL tDIV tADD tSUB tEQ
12 16
 %token<nombre> tNB tNBEXP
17
+%token<id> tID
13 18
 %token tPRINTF
14 19
 %token tERROR
20
+%token tIF tWHILE tELSE
21
+%token tLT tGT tEQCOND
22
+%token tAND tOR
15 23
 
16 24
 //%type<nombre> E
17 25
 
18
-/* 1 + 2 + 3 + 4 */
26
+%%
19 27
 
20
-/* E => E + E => 1 + E => 1 + E + E ... */
21
-/* E => E + E => E + 4 => E + E + 4 ... */
28
+Main : tINT tMAIN tOBRACE Params tCBRACE Body { printf("Main reconnu\n"); } ; 
22 29
 
23
-%%
30
+Params : { printf("Sans Params\n"); } ;
31
+Params : Param SuiteParams ;
32
+Param : tINT tID { printf("Prametre : %s\n", $2); };
33
+SuiteParams : tCOMA Param SuiteParams ;
34
+SuiteParams : ;
35
+
36
+Body : tOBRACKET Instructions tCBRACKET { printf("Body reconnu\n"); } ;
37
+
38
+
39
+Instructions : Instruction Instructions ;
40
+Instructions : ;
41
+Instruction : Aff ;
42
+Instruction : Decl ;
43
+Instruction : Invocation tPV ;
44
+Instruction : If;
45
+Instruction : While;
46
+
47
+
48
+If : tIF tOBRACE Cond tCBRACE Body Else { printf("If reconnu\n"); };
49
+Else : tELSE If { printf("Else if reconnu\n"); };
50
+Else : tELSE Body { printf("Else reconnu\n"); };
51
+Else : ;
52
+While : tWHILE tOBRACE Cond tCBRACE Body { printf("While reconnu\n"); };
53
+
54
+Cond : E SuiteCond ;
55
+SuiteCond : ;
56
+SuiteCond : tAND E SuiteCond;
57
+SuiteCond : tOR E SuiteCond;
24 58
 
25
-/* S -> E ; S
26
- * S ->
27
- */
28
-S : E tPV
59
+
60
+Aff : tID tEQ E tPV { printf("%s prend une valeur\n", $1); } ;
61
+
62
+E : tNB ;
63
+E : tNBEXP ;
64
+E : tID ;
65
+E : E tADD E ;
66
+E : E tMUL E ;
67
+E : E tSUB E ;
68
+E : E tDIV E ;
69
+E : Invocation ;
70
+E : tOBRACE E tCBRACE ;
71
+E : tSUB E ;
72
+E : E tEQCOND E;
73
+E : E tGT E;
74
+E : E tLT E;
75
+
76
+
77
+Decl : tINT tID SuiteDecl FinDeclaration { printf("Declaration de %s\n", $2); } ;
78
+Decl : tCONST tINT tID SuiteDecl tEQ E tPV { printf("Declaration de %s (CONSTANTE)\n", $3); } ;
79
+SuiteDecl : tCOMA tID SuiteDecl { printf("Declaration de %s\n", $2); } ;
80
+SuiteDecl : ;
81
+FinDeclaration : tEQ E tPV { printf("Declaration avec valeur\n"); };
82
+FinDeclaration : tPV { printf("Declaration sans valeur\n"); };
83
+
84
+Invocation : tPRINTF tOBRACE  tID  tCBRACE { printf("Appel de printf sur %s\n", $3); } ;
85
+
86
+/*S : E tPV
29 87
 						{ printf("RES: %d\n", $1); }
30 88
 		S
31 89
 	|					{ printf("END\n"); }
@@ -35,10 +93,10 @@ E : E tADD E	{ $$ = $1 + $3; }
35 93
 	| E tSUB E	{ $$ = $1 - $3; }
36 94
 	| tOB E tCB	{ $$ = $2; }
37 95
 	| tNB				{ $$ = $1; }
38
-	;
96
+	;*/
39 97
 
40 98
 %%
41
-
99
+#include <stdio.h> 
42 100
 void main(void) {
43 101
 	yyparse();
44 102
 }

+ 162
- 101
Analyse_Lexicale/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 23
355
-#define YY_END_OF_BUFFER 24
354
+#define YY_NUM_RULES 32
355
+#define YY_END_OF_BUFFER 33
356 356
 /* This struct is not used in this scanner,
357 357
    but its presence is necessary. */
358 358
 struct yy_trans_info
@@ -360,13 +360,15 @@ struct yy_trans_info
360 360
 	flex_int32_t yy_verify;
361 361
 	flex_int32_t yy_nxt;
362 362
 	};
363
-static const flex_int16_t yy_accept[45] =
363
+static const flex_int16_t yy_accept[66] =
364 364
     {   0,
365
-        0,    0,   24,   22,   20,   17,    4,    5,   13,   11,
366
-       19,   12,   14,    9,   16,   15,   21,   21,   21,   21,
367
-       21,    2,    3,    0,    9,    0,   21,   21,   21,   21,
368
-       21,   18,   10,   21,    7,   21,   21,   21,    1,   21,
369
-        6,   21,    8,    0
365
+        0,    0,   33,   31,   29,   25,   31,    4,    5,   21,
366
+       19,   27,   20,   22,   17,   24,   11,   23,   12,   30,
367
+       30,   30,   30,   30,   30,   30,    2,   31,    3,    0,
368
+       14,    0,   17,    0,   13,   30,   30,   30,    9,   30,
369
+       30,   30,   30,   15,   26,    0,    0,   18,   30,   30,
370
+        7,   30,   30,   30,   28,   30,   16,    1,   30,   30,
371
+        6,   30,   10,    8,    0
370 372
     } ;
371 373
 
372 374
 static const YY_CHAR yy_ec[256] =
@@ -374,17 +376,17 @@ static const YY_CHAR yy_ec[256] =
374 376
         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
375 377
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
376 378
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
377
-        1,    3,    1,    1,    1,    1,    1,    1,    1,    4,
378
-        5,    6,    7,    8,    9,    1,   10,   11,   11,   11,
379
-       11,   11,   11,   11,   11,   11,   11,    1,   12,    1,
380
-       13,    1,    1,    1,   14,   14,   14,   14,   14,   14,
381
-       14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
382
-       14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
383
-        1,    1,    1,    1,   15,    1,   16,   14,   17,   14,
384
-
385
-       18,   19,   14,   14,   20,   14,   14,   14,   21,   22,
386
-       23,   24,   14,   25,   26,   27,   14,   14,   14,   14,
387
-       14,   14,   28,    1,   29,    1,    1,    1,    1,    1,
379
+        1,    3,    1,    4,    1,    1,    1,    5,    1,    6,
380
+        7,    8,    9,   10,   11,    1,   12,   13,   13,   13,
381
+       13,   13,   13,   13,   13,   13,   13,    1,   14,   15,
382
+       16,   17,    1,    1,   18,   18,   18,   18,   18,   18,
383
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
384
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
385
+        1,    1,    1,    1,   19,    1,   20,   18,   21,   18,
386
+
387
+       22,   23,   18,   24,   25,   18,   18,   26,   27,   28,
388
+       29,   30,   18,   31,   32,   33,   18,   18,   34,   18,
389
+       18,   18,   35,   36,   37,    1,    1,    1,    1,    1,
388 390
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
389 391
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
390 392
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -401,55 +403,68 @@ static const YY_CHAR yy_ec[256] =
401 403
         1,    1,    1,    1,    1
402 404
     } ;
403 405
 
404
-static const YY_CHAR yy_meta[30] =
406
+static const YY_CHAR yy_meta[38] =
405 407
     {   0,
406
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
407
-        2,    1,    1,    2,    2,    2,    2,    2,    2,    2,
408
-        2,    2,    2,    2,    2,    2,    2,    1,    1
408
+        1,    1,    1,    2,    1,    1,    1,    1,    1,    1,
409
+        1,    2,    3,    1,    1,    1,    1,    3,    3,    3,
410
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
411
+        3,    3,    3,    3,    1,    1,    1
409 412
     } ;
410 413
 
411
-static const flex_int16_t yy_base[46] =
414
+static const flex_int16_t yy_base[68] =
412 415
     {   0,
413
-        0,    0,   53,   54,   54,   49,   54,   54,   54,   54,
414
-       54,   54,   54,   19,   54,   54,    0,   28,   28,   33,
415
-       23,   54,   54,   44,   20,   35,    0,   23,   17,   23,
416
-       22,   54,   30,   14,    0,   17,   14,    8,    0,    7,
417
-        0,   14,    0,   54,   30
416
+        0,    0,   78,   79,   79,   74,   71,   79,   79,   79,
417
+       79,   79,   79,   67,   25,   79,   79,   58,   79,    0,
418
+       44,   46,   16,   51,   39,   45,   79,   32,   79,   64,
419
+       79,   58,   27,   52,   79,    0,   36,   31,    0,   29,
420
+       36,   35,   34,   79,   79,   50,   45,   43,   23,   32,
421
+        0,   25,   23,   22,   79,   13,    0,    0,   12,   21,
422
+        0,   19,    0,    0,   79,   38,   49
418 423
     } ;
419 424
 
420
-static const flex_int16_t yy_def[46] =
425
+static const flex_int16_t yy_def[68] =
421 426
     {   0,
422
-       44,    1,   44,   44,   44,   44,   44,   44,   44,   44,
423
-       44,   44,   44,   44,   44,   44,   45,   45,   45,   45,
424
-       45,   44,   44,   44,   44,   44,   45,   45,   45,   45,
425
-       45,   44,   44,   45,   45,   45,   45,   45,   45,   45,
426
-       45,   45,   45,    0,   44
427
+       65,    1,   65,   65,   65,   65,   65,   65,   65,   65,
428
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   66,
429
+       66,   66,   66,   66,   66,   66,   65,   65,   65,   65,
430
+       65,   67,   65,   65,   65,   66,   66,   66,   66,   66,
431
+       66,   66,   66,   65,   65,   67,   65,   65,   66,   66,
432
+       66,   66,   66,   66,   65,   66,   66,   66,   66,   66,
433
+       66,   66,   66,   66,    0,   65,   65
427 434
     } ;
428 435
 
429
-static const flex_int16_t yy_nxt[84] =
436
+static const flex_int16_t yy_nxt[117] =
430 437
     {   0,
431
-        4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
432
-       14,   15,   16,   17,    4,   17,   18,   17,   17,   19,
433
-       20,   17,   17,   21,   17,   17,   17,   22,   23,   25,
434
-       25,   27,   43,   42,   41,   40,   26,   26,   39,   38,
435
-       33,   37,   36,   35,   34,   33,   32,   31,   30,   29,
436
-       28,   24,   44,    3,   44,   44,   44,   44,   44,   44,
437
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
438
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
439
-       44,   44,   44
438
+        4,    5,    6,    4,    7,    8,    9,   10,   11,   12,
439
+       13,   14,   15,   16,   17,   18,   19,   20,    4,   20,
440
+       21,   22,   20,   20,   23,   20,   24,   20,   20,   25,
441
+       20,   20,   20,   26,   27,   28,   29,   33,   39,   33,
442
+       36,   64,   63,   40,   62,   61,   34,   60,   34,   46,
443
+       59,   46,   58,   57,   56,   48,   55,   47,   54,   53,
444
+       52,   51,   50,   49,   48,   47,   45,   44,   43,   42,
445
+       41,   38,   37,   35,   32,   31,   30,   65,    3,   65,
446
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
447
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
448
+
449
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
450
+       65,   65,   65,   65,   65,   65
440 451
     } ;
441 452
 
442
-static const flex_int16_t yy_chk[84] =
453
+static const flex_int16_t yy_chk[117] =
443 454
     {   0,
444 455
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
445 456
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
446
-        1,    1,    1,    1,    1,    1,    1,    1,    1,   14,
447
-       25,   45,   42,   40,   38,   37,   14,   25,   36,   34,
448
-       33,   31,   30,   29,   28,   26,   24,   21,   20,   19,
449
-       18,    6,    3,   44,   44,   44,   44,   44,   44,   44,
450
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
451
-       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
452
-       44,   44,   44
457
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
458
+        1,    1,    1,    1,    1,    1,    1,   15,   23,   33,
459
+       66,   62,   60,   23,   59,   56,   15,   54,   33,   67,
460
+       53,   67,   52,   50,   49,   48,   47,   46,   43,   42,
461
+       41,   40,   38,   37,   34,   32,   30,   28,   26,   25,
462
+       24,   22,   21,   18,   14,    7,    6,    3,   65,   65,
463
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
464
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
465
+
466
+       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
467
+       65,   65,   65,   65,   65,   65
453 468
     } ;
454 469
 
455 470
 static yy_state_type yy_last_accepting_state;
@@ -469,9 +484,9 @@ char *yytext;
469 484
 #line 1 "al.lex"
470 485
 #line 2 "al.lex"
471 486
 #include "as.tab.h"
472
-#include <stdio.h>
473
-#line 474 "lex.yy.c"
474
-#line 475 "lex.yy.c"
487
+int yywrap(void){return 1;}
488
+#line 489 "lex.yy.c"
489
+#line 490 "lex.yy.c"
475 490
 
476 491
 #define INITIAL 0
477 492
 
@@ -691,7 +706,7 @@ YY_DECL
691 706
 #line 6 "al.lex"
692 707
 
693 708
 
694
-#line 695 "lex.yy.c"
709
+#line 710 "lex.yy.c"
695 710
 
696 711
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
697 712
 		{
@@ -718,13 +733,13 @@ yy_match:
718 733
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
719 734
 				{
720 735
 				yy_current_state = (int) yy_def[yy_current_state];
721
-				if ( yy_current_state >= 45 )
736
+				if ( yy_current_state >= 66 )
722 737
 					yy_c = yy_meta[yy_c];
723 738
 				}
724 739
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
725 740
 			++yy_cp;
726 741
 			}
727
-		while ( yy_base[yy_current_state] != 54 );
742
+		while ( yy_base[yy_current_state] != 79 );
728 743
 
729 744
 yy_find_action:
730 745
 		yy_act = yy_accept[yy_current_state];
@@ -751,120 +766,166 @@ do_action:	/* This label is used only to access EOF actions. */
751 766
 case 1:
752 767
 YY_RULE_SETUP
753 768
 #line 8 "al.lex"
754
-{ printf("tMAIN\n");} 
769
+{ return tMAIN ;} 
755 770
 	YY_BREAK
756 771
 case 2:
757 772
 YY_RULE_SETUP
758 773
 #line 9 "al.lex"
759
-{ printf("tOBRACKET\n"); }
774
+{ return tOBRACKET;}
760 775
 	YY_BREAK
761 776
 case 3:
762 777
 YY_RULE_SETUP
763 778
 #line 10 "al.lex"
764
-{ printf("tCBRACKET\n"); }
779
+{ return tCBRACKET; }
765 780
 	YY_BREAK
766 781
 case 4:
767 782
 YY_RULE_SETUP
768 783
 #line 11 "al.lex"
769
-{ printf("tOBRACE\n"); }
784
+{ return tOBRACE; }
770 785
 	YY_BREAK
771 786
 case 5:
772 787
 YY_RULE_SETUP
773 788
 #line 12 "al.lex"
774
-{ printf("tOBRACE\n"); }
789
+{ return tCBRACE; }
775 790
 	YY_BREAK
776 791
 case 6:
777 792
 YY_RULE_SETUP
778 793
 #line 13 "al.lex"
779
-{ printf("tCONST\n"); }
794
+{ return tCONST; }
780 795
 	YY_BREAK
781 796
 case 7:
782 797
 YY_RULE_SETUP
783 798
 #line 14 "al.lex"
784
-{ printf("tINT\n"); }
799
+{ return tINT; }
785 800
 	YY_BREAK
786 801
 case 8:
787 802
 YY_RULE_SETUP
788 803
 #line 15 "al.lex"
789
-{ printf("tPRINTF\n"); } //Degeu mais à degager
804
+{ return tPRINTF; } //Degeu mais à degager
790 805
 	YY_BREAK
791 806
 case 9:
792 807
 YY_RULE_SETUP
793
-#line 20 "al.lex"
794
-{ printf("tNB\n"); }
808
+#line 16 "al.lex"
809
+{ return tIF; }
795 810
 	YY_BREAK
796 811
 case 10:
797 812
 YY_RULE_SETUP
798
-#line 21 "al.lex"
799
-{ printf("tNBEXP\n"); }
813
+#line 17 "al.lex"
814
+{ return tWHILE; }
800 815
 	YY_BREAK
801 816
 case 11:
802 817
 YY_RULE_SETUP
803
-#line 22 "al.lex"
804
-{ printf("tADD\n"); }
818
+#line 18 "al.lex"
819
+{ return tLT; }
805 820
 	YY_BREAK
806 821
 case 12:
807 822
 YY_RULE_SETUP
808
-#line 23 "al.lex"
809
-{ printf("tSUB\n"); }
823
+#line 19 "al.lex"
824
+{ return tGT; }
810 825
 	YY_BREAK
811 826
 case 13:
812 827
 YY_RULE_SETUP
813
-#line 24 "al.lex"
814
-{ printf("tMUL\n"); }
828
+#line 20 "al.lex"
829
+{ return tEQCOND; }
815 830
 	YY_BREAK
816 831
 case 14:
817 832
 YY_RULE_SETUP
818
-#line 25 "al.lex"
819
-{ printf("tDIV\n"); }
833
+#line 21 "al.lex"
834
+{ return tAND; }
820 835
 	YY_BREAK
821 836
 case 15:
822 837
 YY_RULE_SETUP
823
-#line 26 "al.lex"
824
-{ printf("tEQ\n"); }
838
+#line 22 "al.lex"
839
+{ return tOR; }
825 840
 	YY_BREAK
826 841
 case 16:
827 842
 YY_RULE_SETUP
828
-#line 27 "al.lex"
829
-{ printf("tPV\n"); }
843
+#line 23 "al.lex"
844
+{ return tELSE;}
830 845
 	YY_BREAK
831 846
 case 17:
832 847
 YY_RULE_SETUP
833
-#line 28 "al.lex"
834
-{ printf("tSPACE\n"); }
848
+#line 26 "al.lex"
849
+{ yylval.nombre = atoi(yytext); return tNB; }
835 850
 	YY_BREAK
836 851
 case 18:
837 852
 YY_RULE_SETUP
838
-#line 29 "al.lex"
839
-{ printf("tTAB\n"); }
853
+#line 27 "al.lex"
854
+{ yylval.nombre = -1; return tNBEXP; } //Renvoyer le token tNB et pas tNBEXP
840 855
 	YY_BREAK
841 856
 case 19:
842 857
 YY_RULE_SETUP
843
-#line 30 "al.lex"
844
-{ printf("tCOMA\n"); }
858
+#line 28 "al.lex"
859
+{ return tADD; }
845 860
 	YY_BREAK
846 861
 case 20:
847
-/* rule 20 can match eol */
848 862
 YY_RULE_SETUP
849
-#line 31 "al.lex"
850
-{ printf("tRC\n") ; }
863
+#line 29 "al.lex"
864
+{ return tSUB; }
851 865
 	YY_BREAK
852 866
 case 21:
853 867
 YY_RULE_SETUP
854
-#line 32 "al.lex"
855
-{ printf("tID\n"); }
868
+#line 30 "al.lex"
869
+{ return tMUL; }
856 870
 	YY_BREAK
857 871
 case 22:
858 872
 YY_RULE_SETUP
859
-#line 33 "al.lex"
860
-{ return tERROR; }
873
+#line 31 "al.lex"
874
+{ return tDIV; }
861 875
 	YY_BREAK
862 876
 case 23:
863 877
 YY_RULE_SETUP
878
+#line 32 "al.lex"
879
+{ return tEQ; }
880
+	YY_BREAK
881
+case 24:
882
+YY_RULE_SETUP
883
+#line 33 "al.lex"
884
+{ return tPV; }
885
+	YY_BREAK
886
+case 25:
887
+YY_RULE_SETUP
888
+#line 34 "al.lex"
889
+{} //Ne pas les retourner à Yacc
890
+	YY_BREAK
891
+case 26:
892
+YY_RULE_SETUP
864 893
 #line 35 "al.lex"
894
+{} //Ne pas les retourner à Yacc
895
+	YY_BREAK
896
+case 27:
897
+YY_RULE_SETUP
898
+#line 36 "al.lex"
899
+{ return tCOMA; }
900
+	YY_BREAK
901
+case 28:
902
+/* rule 28 can match eol */
903
+YY_RULE_SETUP
904
+#line 37 "al.lex"
905
+{ printf("commentaire\n");}
906
+	YY_BREAK
907
+case 29:
908
+/* rule 29 can match eol */
909
+YY_RULE_SETUP
910
+#line 38 "al.lex"
911
+{} //Ne pas les retourner à Yacc
912
+	YY_BREAK
913
+case 30:
914
+YY_RULE_SETUP
915
+#line 39 "al.lex"
916
+{ strcpy(yylval.id, yytext); return tID; }
917
+	YY_BREAK
918
+case 31:
919
+YY_RULE_SETUP
920
+#line 40 "al.lex"
921
+{ return tERROR; }
922
+	YY_BREAK
923
+case 32:
924
+YY_RULE_SETUP
925
+#line 42 "al.lex"
865 926
 ECHO;
866 927
 	YY_BREAK
867
-#line 868 "lex.yy.c"
928
+#line 929 "lex.yy.c"
868 929
 case YY_STATE_EOF(INITIAL):
869 930
 	yyterminate();
870 931
 
@@ -1161,7 +1222,7 @@ static int yy_get_next_buffer (void)
1161 1222
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1162 1223
 			{
1163 1224
 			yy_current_state = (int) yy_def[yy_current_state];
1164
-			if ( yy_current_state >= 45 )
1225
+			if ( yy_current_state >= 66 )
1165 1226
 				yy_c = yy_meta[yy_c];
1166 1227
 			}
1167 1228
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1189,11 +1250,11 @@ static int yy_get_next_buffer (void)
1189 1250
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1190 1251
 		{
1191 1252
 		yy_current_state = (int) yy_def[yy_current_state];
1192
-		if ( yy_current_state >= 45 )
1253
+		if ( yy_current_state >= 66 )
1193 1254
 			yy_c = yy_meta[yy_c];
1194 1255
 		}
1195 1256
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1196
-	yy_is_jam = (yy_current_state == 44);
1257
+	yy_is_jam = (yy_current_state == 65);
1197 1258
 
1198 1259
 		return yy_is_jam ? 0 : yy_current_state;
1199 1260
 }
@@ -1869,7 +1930,7 @@ void yyfree (void * ptr )
1869 1930
 
1870 1931
 #define YYTABLES_NAME "yytables"
1871 1932
 
1872
-#line 35 "al.lex"
1933
+#line 42 "al.lex"
1873 1934
 
1874 1935
 
1875 1936
 

+ 14
- 4
Analyse_Lexicale/progC View File

@@ -1,7 +1,17 @@
1
-#include <stdio.h>
2
-
3 1
 int main(int x, int i){
4
-   int azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn; printf("%d\n", azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn);
5
-    int y = 2;
2
+    const int a = 4; 
3
+    const int a, b, c = 2 + a - 5 * (7 / 8); 
4
+    printf(coucou);
5
+    int y = 7e8;
6 6
     int res_2 = x + y;
7
+
8
+    if ( (a == 2) && b || c > (7*8)) {
9
+    }
10
+    else if (a) {
11
+        int x = 90;
12
+    } else {
13
+        int a = b;
14
+    }
15
+/* SAlut Elies */
16
+    printf(i);
7 17
 }

+ 0
- 7
Analyse_Lexicale/progC.c View File

@@ -1,7 +0,0 @@
1
-#include <stdio.h>
2
-
3
-int main(int x, int i){
4
-   int azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn; printf("%d\n", azertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbnazertyuiopqsdfghjklmwxcvbn);
5
-    int y = 2;
6
-    int res_2 = x + y;
7
-}

+ 0
- 0
Analyse_Lexicale/table_symboles.c View File


+ 0
- 0
Analyse_Lexicale/table_symboles.h View File


Loading…
Cancel
Save