Browse Source

Dossiers propres

Paul Faure 6 months ago
parent
commit
3a4f2e256f

+ 9
- 0
.gitignore View File

@@ -0,0 +1,9 @@
1
+rondoudou_gcc
2
+output.txt
3
+Tables/Symboles/*.o
4
+Tables/Symboles/test
5
+Tables/Instructions/*.o
6
+Tables/Instructions/test
7
+Lex_Yacc/as.output 
8
+Lex_Yacc/as.tab.* 
9
+Lex_Yacc/lex.yy.*

BIN
Analyse_Lexicale/a.out View File


+ 0
- 44
Analyse_Lexicale/al.lex View File

@@ -1,44 +0,0 @@
1
-%{
2
-#include "as.tab.h"
3
-int yywrap(void){return 1;}
4
-%}
5
-
6
-%%
7
-
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; }
40
-.				{ return tERROR; }
41
-
42
-%%
43
-
44
-

+ 0
- 1621
Analyse_Lexicale/as.tab.c
File diff suppressed because it is too large
View File


+ 0
- 101
Analyse_Lexicale/as.tab.h View File

@@ -1,101 +0,0 @@
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_AS_TAB_H_INCLUDED
34
-# define YY_YY_AS_TAB_H_INCLUDED
35
-/* Debug traces.  */
36
-#ifndef YYDEBUG
37
-# define YYDEBUG 0
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
-    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
75
-  };
76
-#endif
77
-
78
-/* Value type.  */
79
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
80
-
81
-union YYSTYPE
82
-{
83
-#line 1 "as.y" /* yacc.c:1909  */
84
-
85
-	int nombre;
86
-    char id[30];
87
-
88
-#line 89 "as.tab.h" /* yacc.c:1909  */
89
-};
90
-
91
-typedef union YYSTYPE YYSTYPE;
92
-# define YYSTYPE_IS_TRIVIAL 1
93
-# define YYSTYPE_IS_DECLARED 1
94
-#endif
95
-
96
-
97
-extern YYSTYPE yylval;
98
-
99
-int yyparse (void);
100
-
101
-#endif /* !YY_YY_AS_TAB_H_INCLUDED  */

+ 0
- 102
Analyse_Lexicale/as.y View File

@@ -1,102 +0,0 @@
1
-%union {
2
-	int nombre;
3
-    char id[30];
4
-}
5
-%{
6
-#include <stdio.h>
7
-%}
8
-
9
-%token tMAIN
10
-%token tOBRACKET tCBRACKET
11
-%token tOBRACE tCBRACE
12
-%token tINT
13
-%token tCONST
14
-%token tPV tCOMA
15
-%token tMUL tDIV tADD tSUB tEQ
16
-%token<nombre> tNB tNBEXP
17
-%token<id> tID
18
-%token tPRINTF
19
-%token tERROR
20
-%token tIF tWHILE tELSE
21
-%token tLT tGT tEQCOND
22
-%token tAND tOR
23
-
24
-//%type<nombre> E
25
-
26
-%%
27
-
28
-Main : tINT tMAIN tOBRACE Params tCBRACE Body { printf("Main reconnu\n"); } ; 
29
-
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;
58
-
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
87
-						{ printf("RES: %d\n", $1); }
88
-		S
89
-	|					{ printf("END\n"); }
90
-	;
91
-
92
-E : E tADD E	{ $$ = $1 + $3; }
93
-	| E tSUB E	{ $$ = $1 - $3; }
94
-	| tOB E tCB	{ $$ = $2; }
95
-	| tNB				{ $$ = $1; }
96
-	;*/
97
-
98
-%%
99
-#include <stdio.h> 
100
-void main(void) {
101
-	yyparse();
102
-}

+ 0
- 5
Analyse_Lexicale/comp.sh View File

@@ -1,5 +0,0 @@
1
-bison -d as.y
2
-flex al.lex 
3
-gcc *.c -ly
4
-cat progC | ./a.out 
5
-

+ 0
- 52
Analyse_Lexicale/grammaire_c_minimaliste View File

@@ -1,52 +0,0 @@
1
-les fonctions (avec parametres)
2
-le if
3
-le while
4
-les declarations
5
-les affectations
6
-les operations arith.
7
-le retour de fonction
8
-l'invocation de fonctions
9
-
10
-
11
-C : Fonctions ;
12
-Fonctions : Fonction Fonctions | Fonction ;
13
-
14
-Fonction : tInt tID tPO Params tPF Body ;
15
-
16
-Params : | Param SuiteParams ;
17
-Param : tInt tID ;
18
-
19
-SuiteParams : tVirgule Param SuiteParams | ;
20
-
21
-// Ps : P Ps | ;
22
-// P : tInt tID tVirgule
23
-// Ps =>* tInt tID tVirgule tInt tID tVirgule
24
-// Ps => P Ps => P P Ps ...
25
-
26
-Body : tAO Instructions tAF ;
27
-
28
-Instructions : Instruction Instructions | ;
29
-
30
-Instruction : Aff | If | While | Return | Decl | Invocation tPV ;
31
-
32
-Aff : tID tEQ E tPV ;
33
-
34
-E : tNB | tID | E tADD E | E tMUL E | E tMINUS E | E tDIV E | Invocation | tPO E tPF | tMINUS E ;
35
-
36
-// E : tID tADD tID | ...
37
-
38
-If : tIF tPO Cond tPF Body ;
39
-
40
-Cond : Cond tAND Cond | Cond tOR Cond | E tEQ2 E | E tINF E | tNOT Cond ;
41
-
42
-Invocation : tID tPO  Args  tPF ;
43
-
44
-Args : .... cf params
45
-
46
-Return : tRET E tPV ;
47
-
48
-
49
-
50
-
51
-
52
-

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


+ 0
- 17
Analyse_Lexicale/progC View File

@@ -1,17 +0,0 @@
1
-int main(int x, int i){
2
-    const int a = 4; 
3
-    const int a, b, c = 2 + a - 5 * (7 / 8); 
4
-    printf(coucou);
5
-    int y = 7e8;
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);
17
-}

+ 0
- 109
Analyse_Lexicale/table_symboles.c View File

@@ -1,109 +0,0 @@
1
-/* TABLE DES SYMBOLE DU COMPILATEUR (PILE)
2
-
3
------------------------------------------------------
4
-|  symbole   |  adresse   |    type    | initialisé |
5
------------------------------------------------------
6
-|            |            |            |            |
7
-|            |            |            |            |
8
-|            |            |            |            |
9
-|      i     | 0x777756b8 |     int    |    false   |
10
-|    size    | 0x777756b8 |     int    |    true    |
11
------------------------------------------------------
12
-
13
-Types pour l'implémentation : 
14
-	- enum type_t : [int]
15
-	- struct symbole : {
16
-			char nom[30];
17
-			uintptr_t adresse;
18
-			enum type_t type;
19
-			char initialized;
20
-		}
21
-
22
-Opérations possible : 
23
-	- init -> pile * -> void
24
-	- push -> symbole -> pile * -> void
25
-	- pop -> pile * -> symbole
26
-	- exist -> pile * -> symbole -> char
27
-	- initialized -> pile * -> symbole -> char					*/
28
-
29
-#include "table_symboles.h"
30
-#include <stdlib.h>
31
-#include <string.h>
32
-#include <stdio.h>
33
-
34
-struct element_t {
35
-	struct symbole_t symbole;
36
-	struct element_t * suivant;
37
-};
38
-
39
-struct pile_t {
40
-	int taille;
41
-	struct element_t * first;
42
-};
43
-
44
-char * type_to_string(enum type_t type) {
45
-	if (type == INT) {
46
-		return "int";
47
-	} else {
48
-		return "unknown";	
49
-	}
50
-}
51
-
52
-void init(struct pile_t * pile) {
53
-	pile->first = NULL;
54
-	pile->taille = 0;
55
-}
56
-
57
-void push(struct symbole_t symbole, struct pile_t * pile) {
58
-	struct element_t * aux = malloc(sizeof(struct element_t));
59
-	aux->symbole = symbole;
60
-	aux->suivant = pile->first;
61
-	pile->first = aux;
62
-	pile->taille++;
63
-}
64
-
65
-struct symbole_t pop(struct pile_t * pile) {
66
-	struct symbole_t retour = {"", 0, UNKNOWN, -1};
67
-	struct element_t * aux;
68
-	if (pile->taille > 0) {
69
-		aux = pile->first;
70
-		pile->first = pile->first->suivant;
71
-		retour = aux->symbole;
72
-		free(aux);
73
-		pile->taille--;
74
-	}
75
-	return retour;
76
-}
77
-		
78
-char status(char * nom, struct pile_t pile) {
79
-	char retour = 0;
80
-	struct element_t * aux = pile.first;
81
-	int i;
82
-	for (i=0; i < pile.taille; i++) {
83
-		if (!strcmp(nom, aux->symbole.nom)) {
84
-			if (aux->symbole.initialized) {
85
-				retour = 1;
86
-			} else {
87
-				retour = 2;
88
-			}
89
-			break;
90
-		} else {
91
-			aux = aux->suivant;
92
-		}
93
-	}
94
-	return retour;
95
-}
96
-
97
-void print(struct pile_t pile) {
98
-	printf("Affichage de la Table des Symboles\n\tSize : %d\n\tContenu : \n", pile.taille);
99
-	struct element_t * aux = pile.first;
100
-	int i;
101
-	for (i=0; i < pile.taille; i++) {
102
-		if (aux->symbole.initialized) {
103
-			printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:OUI}\n", aux->symbole.nom, (void *)(aux->symbole.adresse), type_to_string(aux->symbole.type));
104
-		} else {
105
-			printf("\t\t{nom:%s, adresse:%p, type:%s, initialized:NON}\n", aux->symbole.nom, (void *)(aux->symbole.adresse), type_to_string(aux->symbole.type));
106
-		}
107
-		aux = aux->suivant;
108
-	}
109
-}

+ 0
- 48
Analyse_Lexicale/table_symboles.h View File

@@ -1,48 +0,0 @@
1
-/* TABLE DES SYMBOLE DU COMPILATEUR (PILE)
2
-
3
------------------------------------------------------
4
-|  symbole   |  adresse   |    type    | initialisé |
5
------------------------------------------------------
6
-|            |            |            |            |
7
-|            |            |            |            |
8
-|            |            |            |            |
9
-|      i     | 0x777756b8 |     int    |    false   |
10
-|    size    | 0x777756b8 |     int    |    true    |
11
------------------------------------------------------
12
-
13
-Types pour l'implémentation : 
14
-	- enum type_t : [int]
15
-	- struct symbole : {
16
-			char nom[30];
17
-			uintptr_t adresse;
18
-			enum type_t type;
19
-			char initialized;
20
-		}
21
-
22
-Opérations possible : 
23
-	- init -> pile * -> void
24
-	- push -> symbole -> pile * -> void
25
-	- pop -> pile * -> symbole
26
-	- status -> nom -> pile -> char					*/
27
-
28
-#include <stdint.h>
29
-
30
-enum type_t {UNKNOWN, INT};
31
-
32
-struct symbole_t {
33
-	char nom[30];
34
-	uintptr_t adresse;
35
-	enum type_t type;
36
-	char initialized;
37
-};
38
-
39
-struct pile_t;
40
-
41
-
42
-
43
-void init(struct pile_t * pile);
44
-void push(struct symbole_t symbole, struct pile_t * pile);
45
-struct symbole_t pop(struct pile_t * pile);
46
-// renvoi 0 si nom n'existe pas, 2 si nom existe sans etre initialisée, 1 sinon
47
-char status(char * nom, struct pile_t pile);
48
-void print(struct pile_t pile);

BIN
Analyse_Lexicale/test View File


+ 0
- 0
Analyse_Lexicale/truc View File


+ 2
- 14
Fichiers_Tests/progC View File

@@ -1,15 +1,3 @@
1
-int main(int x, int i){
2
-    const int a = 4; 
3
-    const int a, b, c = 2 + a - 5 * (7 / 8) + 5; 
4
-    printf(coucou);
5
-    int y = 7e8;
6
-    int res_2 = x + y;
7
-    if ( (a == 2) && b || c > (7*8)) {
8
-    }
9
-    else if (a) {
10
-        int x = 90;
11
-    } else {
12
-        int a = b;
13
-    }
14
-    printf(i);
1
+int main(){
2
+    int a = 4; 
15 3
 }

+ 0
- 4
Lex_Yacc/ProgC View File

@@ -1,4 +0,0 @@
1
-int main(int a, int b)
2
-{
3
-	int c;
4
-}

BIN
Lex_Yacc/a.exe View File


+ 0
- 1367
Lex_Yacc/as.output
File diff suppressed because it is too large
View File


+ 0
- 1853
Lex_Yacc/as.tab.c
File diff suppressed because it is too large
View File


+ 0
- 105
Lex_Yacc/as.tab.h View File

@@ -1,105 +0,0 @@
1
-/* A Bison parser, made by GNU Bison 3.5.1.  */
2
-
3
-/* Bison interface for Yacc-like parsers in C
4
-
5
-   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6
-   Inc.
7
-
8
-   This program is free software: you can redistribute it and/or modify
9
-   it under the terms of the GNU General Public License as published by
10
-   the Free Software Foundation, either version 3 of the License, or
11
-   (at your option) any later version.
12
-
13
-   This program is distributed in the hope that it will be useful,
14
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
-   GNU General Public License for more details.
17
-
18
-   You should have received a copy of the GNU General Public License
19
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
-
21
-/* As a special exception, you may create a larger work that contains
22
-   part or all of the Bison parser skeleton and distribute that work
23
-   under terms of your choice, so long as that work isn't itself a
24
-   parser generator using the skeleton or a modified version thereof
25
-   as a parser skeleton.  Alternatively, if you modify or redistribute
26
-   the parser skeleton itself, you may (at your option) remove this
27
-   special exception, which will cause the skeleton and the resulting
28
-   Bison output files to be licensed under the GNU General Public
29
-   License without this special exception.
30
-
31
-   This special exception was added by the Free Software Foundation in
32
-   version 2.2 of Bison.  */
33
-
34
-/* Undocumented macros, especially those whose name start with YY_,
35
-   are private implementation details.  Do not rely on them.  */
36
-
37
-#ifndef YY_YY_AS_TAB_H_INCLUDED
38
-# define YY_YY_AS_TAB_H_INCLUDED
39
-/* Debug traces.  */
40
-#ifndef YYDEBUG
41
-# define YYDEBUG 1
42
-#endif
43
-#if YYDEBUG
44
-extern int yydebug;
45
-#endif
46
-
47
-/* Token type.  */
48
-#ifndef YYTOKENTYPE
49
-# define YYTOKENTYPE
50
-  enum yytokentype
51
-  {
52
-    tMAIN = 258,
53
-    tOBRACKET = 259,
54
-    tCBRACKET = 260,
55
-    tOBRACE = 261,
56
-    tCBRACE = 262,
57
-    tINT = 263,
58
-    tCONST = 264,
59
-    tPV = 265,
60
-    tCOMA = 266,
61
-    tMUL = 267,
62
-    tDIV = 268,
63
-    tADD = 269,
64
-    tSUB = 270,
65
-    tEQ = 271,
66
-    tNB = 272,
67
-    tNBEXP = 273,
68
-    tID = 274,
69
-    tPRINTF = 275,
70
-    tERROR = 276,
71
-    tIF = 277,
72
-    tWHILE = 278,
73
-    tELSE = 279,
74
-    tLT = 280,
75
-    tGT = 281,
76
-    tEQCOND = 282,
77
-    tAND = 283,
78
-    tOR = 284,
79
-    tNOT = 285
80
-  };
81
-#endif
82
-
83
-/* Value type.  */
84
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
85
-union YYSTYPE
86
-{
87
-#line 1 "as.y"
88
-
89
-	int nombre;
90
-    char id[30];
91
-
92
-#line 93 "as.tab.h"
93
-
94
-};
95
-typedef union YYSTYPE YYSTYPE;
96
-# define YYSTYPE_IS_TRIVIAL 1
97
-# define YYSTYPE_IS_DECLARED 1
98
-#endif
99
-
100
-
101
-extern YYSTYPE yylval;
102
-
103
-int yyparse (void);
104
-
105
-#endif /* !YY_YY_AS_TAB_H_INCLUDED  */

+ 6
- 6
Lex_Yacc/as.y View File

@@ -3,11 +3,11 @@
3 3
     char id[30];
4 4
 }
5 5
 %{
6
-#include "../Symboles/table_symboles.h"
6
+#include "../Tables/Symboles/table_symboles.h"
7 7
 #include <stdio.h> 
8 8
 #include <string.h>
9 9
 #include <stdlib.h>
10
-#include "../Symboles/tab_instruc.h"
10
+#include "../Tables/Instructions/tab_instruc.h"
11 11
 #define TAILLE 1024
12 12
 
13 13
 enum type_t type_courant;
@@ -84,10 +84,10 @@ E : tNB { int addr = allocate_mem_temp_var(INT); add_operation(AFC, addr,$1,0);
84 84
 
85 85
 E : tNBEXP { printf("Nombre exp\n"); int addr = allocate_mem_temp_var(INT); add_operation(AFC, addr,$1,0); $$ = addr;};
86 86
 E : tID { printf("Id\n"); /*Faire un get_address sur la pile*/};
87
-E : E tMUL E { printf("Mul\n"); int addr = allocate_mem_temp_var(INT); add_operation(MUL, addr,$1,$2); $$ = addr;};
88
-E : E tDIV E { printf("Div\n"); int addr = allocate_mem_temp_var(INT); add_operation(DIV, addr,$1,$2); $$ = addr;};
89
-E : E tSUB E { printf("Sub\n"); int addr = allocate_mem_temp_var(INT); add_operation(SOU, addr,$1,$2); $$ = addr;};
90
-E : E tADD E { printf("Add\n"); int addr = allocate_mem_temp_var(INT); add_operation(ADD, addr,$1,$2); $$ = addr;};
87
+E : E tMUL E { printf("Mul\n"); int addr = allocate_mem_temp_var(INT); add_operation(MUL, addr,$1,$3); $$ = addr;};
88
+E : E tDIV E { printf("Div\n"); int addr = allocate_mem_temp_var(INT); add_operation(DIV, addr,$1,$3); $$ = addr;};
89
+E : E tSUB E { printf("Sub\n"); int addr = allocate_mem_temp_var(INT); add_operation(SOU, addr,$1,$3); $$ = addr;};
90
+E : E tADD E { printf("Add\n"); int addr = allocate_mem_temp_var(INT); add_operation(ADD, addr,$1,$3); $$ = addr;};
91 91
 E : Invocation { printf("Invoc\n"); int addr = allocate_mem_temp_var(INT); add_operation(AFC, addr,$1,0); $$ = addr;};
92 92
 E : tOBRACE E tCBRACE { printf("Parentheses\n"); $$=$2;};
93 93
 E : tSUB E { printf("Moins\n"); int addr = allocate_mem_temp_var(INT); add_operation(SOU, 0,addr,0); $$ = addr;};

+ 0
- 4
Lex_Yacc/comp.sh View File

@@ -1,4 +0,0 @@
1
-bison -d -t as.y -v
2
-flex al.lex 
3
-gcc as.tab.c lex.yy.c ../Symboles/tab_instruc.c ../Symboles/table_symboles.c -ll -o a.exe
4
-cat ./ProgC | ./a.exe

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


BIN
Lex_Yacc/lex.yy.o View File


+ 0
- 0
Lex_Yacc/output.txt View File


+ 59
- 0
Makefile View File

@@ -0,0 +1,59 @@
1
+default : 
2
+	@echo "Spécifiez une cible"
3
+
4
+clean : clean_Symboles clean_Instructions clean_Lex_Yacc
5
+	@rm -f rondoudou_gcc
6
+	@rm -f output.txt
7
+
8
+clean_Symboles:
9
+	@rm -f Tables/Symboles/*.o
10
+	@rm -f Tables/Symboles/test
11
+
12
+clean_Instructions:
13
+	@rm -f Tables/Instructions/*.o
14
+	@rm -f Tables/Instructions/test
15
+
16
+clean_Lex_Yacc:
17
+	@rm -f Lex_Yacc/as.output Lex_Yacc/as.tab.* Lex_Yacc/lex.yy.*
18
+
19
+build : clean build_Symboles build_Instructions build_Lex_Yacc
20
+	gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/Instructions/tab_instruc.o Tables/Symboles/table_symboles.o -ll -o rondoudou_gcc
21
+
22
+build_Symboles: clean_Symboles
23
+	gcc -c Tables/Symboles/table_symboles.c -o Tables/Symboles/table_symboles.o
24
+
25
+build_Instructions: clean_Instructions
26
+	gcc -c Tables/Instructions/tab_instruc.c -o Tables/Instructions/tab_instruc.o
27
+
28
+build_Lex_Yacc: clean_Lex_Yacc
29
+	bison -d -t -b Lex_Yacc/as Lex_Yacc/as.y
30
+	flex -o Lex_Yacc/lex.yy.c Lex_Yacc/al.lex
31
+	gcc -c Lex_Yacc/as.tab.c -o Lex_Yacc/as.tab.o
32
+	gcc -c Lex_Yacc/lex.yy.c -o Lex_Yacc/lex.yy.o
33
+
34
+test_Symboles: build_Symboles
35
+	gcc -c Tables/Symboles/test.c -o Tables/Symboles/test.o
36
+	gcc Tables/Symboles/test.o Tables/Symboles/table_symboles.o -o Tables/Symboles/test
37
+	Tables/Symboles/test
38
+
39
+test_Instructions: build_Instructions
40
+	gcc -c Tables/Instructions/test.c -o Tables/Instructions/test.o
41
+	gcc Tables/Instructions/test.o Tables/Instructions/tab_instruc.o -o Tables/Instructions/test
42
+	Tables/Instructions/test
43
+
44
+test: build
45
+	cat Fichiers_Tests/progC | ./rondoudou_gcc 
46
+
47
+edit_Lex_Yacc: 
48
+	pluma Lex_Yacc/al.lex Lex_Yacc/as.y &
49
+
50
+edit_Symboles: 
51
+	pluma Tables/Symboles/table_symboles.c Tables/Symboles/table_symboles.h &
52
+
53
+edit_Instructions: 
54
+	pluma Tables/Instructions/tab_instruc.c Tables/Instructions/tab_instruc.h &
55
+
56
+edit_Progs: 
57
+	pluma Fichiers_Tests/progC &
58
+
59
+edit: edit_Lex_Yacc edit_Symboles edit_Instructions edit_Progs

BIN
Symboles/tab_instruc.o View File


BIN
Symboles/table_symboles.o View File


BIN
Symboles/test_table_symbole View File


BIN
Symboles/test_table_symbole.o View File


Symboles/tab_instruc.c → Tables/Instructions/tab_instruc.c View File


Symboles/tab_instruc.h → Tables/Instructions/tab_instruc.h View File


Symboles/table_symboles.c → Tables/Symboles/table_symboles.c View File


Symboles/table_symboles.h → Tables/Symboles/table_symboles.h View File


Symboles/test_table_symbole.c → Tables/Symboles/test.c View File


Loading…
Cancel
Save