French
Clemylia commited on
Commit
547f904
ยท
verified ยท
1 Parent(s): 8a8a6de

Upload main-1.c

Browse files
Files changed (1) hide show
  1. main-1.c +2153 -0
main-1.c ADDED
@@ -0,0 +1,2153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #define _GNU_SOURCE
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+ #include <string.h>
5
+ #include <time.h>
6
+ #include <math.h>
7
+ #include <unistd.h>
8
+ #include <sys/stat.h>
9
+ #include <ctype.h>
10
+ #include <termios.h>
11
+
12
+ #define MAX_VARIABLES 100
13
+ #define MAX_ARRAYS 50
14
+ #define MAX_PACKAGES 50
15
+ #define MAX_PACKAGE_FUNCTIONS 200
16
+ #define MAX_LINE_LENGTH 1000
17
+ #define MAX_CANVAS_WIDTH 80
18
+ #define MAX_CANVAS_HEIGHT 30
19
+ #define MAX_LISTS 50
20
+ #define MAX_DICTS 50
21
+ #define MAX_LIST_SIZE 1000
22
+ #define MAX_DICT_SIZE 500
23
+ #define MAX_STORIES 20
24
+ #define MAX_STORY_CHOICES 10
25
+ #define MAX_VAR_NAME 100
26
+ #define MAX_VAR_VALUE 500
27
+ #define MAX_ARRAY_SIZE 100
28
+ #define MAX_LOOPS 20
29
+ #define MAX_FUNCTIONS 50
30
+
31
+ // Structure pour les packages
32
+ typedef struct {
33
+ char name[MAX_VAR_NAME];
34
+ char language[10];
35
+ char file_path[200];
36
+ int is_loaded;
37
+ } Package;
38
+
39
+ // Structure pour les fonctions de packages
40
+ typedef struct {
41
+ char name[MAX_VAR_NAME];
42
+ char package_name[MAX_VAR_NAME];
43
+ char language[10];
44
+ char file_path[200];
45
+ char parameters[500];
46
+ int param_count;
47
+ } PackageFunction;
48
+
49
+ // Structure pour les variables
50
+ typedef struct {
51
+ char name[MAX_VAR_NAME];
52
+ char value[MAX_VAR_VALUE];
53
+ double num_value;
54
+ int is_number;
55
+ int is_array;
56
+ double array_values[MAX_ARRAY_SIZE];
57
+ int array_size;
58
+ } Variable;
59
+
60
+ // Structure pour les boucles
61
+ typedef struct {
62
+ int start_line;
63
+ int current_iteration;
64
+ int max_iterations;
65
+ char condition[MAX_LINE_LENGTH];
66
+ int is_active;
67
+ } Loop;
68
+
69
+ // Structure pour les fonctions
70
+ typedef struct {
71
+ char name[MAX_VAR_NAME];
72
+ int start_line;
73
+ int end_line;
74
+ char parameters[10][MAX_VAR_NAME];
75
+ int param_count;
76
+ } Function;
77
+
78
+ typedef struct {
79
+ char name[100];
80
+ char elements[1000];
81
+ } Array;
82
+
83
+ // Nouvelles structures pour listes avancรฉes
84
+ typedef struct {
85
+ char name[100];
86
+ char elements[MAX_LIST_SIZE][200];
87
+ int size;
88
+ } List;
89
+
90
+ // Structure pour dictionnaires (NECTAR)
91
+ typedef struct {
92
+ char key[100];
93
+ char value[500];
94
+ } DictEntry;
95
+
96
+ typedef struct {
97
+ char name[100];
98
+ DictEntry entries[MAX_DICT_SIZE];
99
+ int size;
100
+ } Dictionary;
101
+
102
+ // Structure pour histoires interactives
103
+ typedef struct {
104
+ char question[500];
105
+ char choices[MAX_STORY_CHOICES][200];
106
+ int next_scenes[MAX_STORY_CHOICES];
107
+ int choice_count;
108
+ } StoryScene;
109
+
110
+ typedef struct {
111
+ char name[100];
112
+ StoryScene scenes[50];
113
+ int scene_count;
114
+ int current_scene;
115
+ } Story;
116
+
117
+ // Variables globales
118
+ Variable variables[MAX_VARIABLES];
119
+ Loop loops[MAX_LOOPS];
120
+ Function functions[MAX_FUNCTIONS];
121
+ Array arrays[MAX_ARRAYS];
122
+ List lists[MAX_LISTS];
123
+ Dictionary dictionaries[MAX_DICTS];
124
+ Story stories[MAX_STORIES];
125
+ Package packages[MAX_PACKAGES];
126
+ PackageFunction package_functions[MAX_PACKAGE_FUNCTIONS];
127
+ int var_count = 0;
128
+ int loop_count = 0;
129
+ int function_count = 0;
130
+ int array_count = 0;
131
+ int list_count = 0;
132
+ int dict_count = 0;
133
+ int story_count = 0;
134
+ int package_count = 0;
135
+ int package_function_count = 0;
136
+ int current_line = 0;
137
+ char program_lines[1000][MAX_LINE_LENGTH];
138
+ int total_lines = 0;
139
+ int skip_until_end = 0;
140
+ int in_function_definition = 0;
141
+ char current_canvas[20][50];
142
+ int canvas_width = 50;
143
+ int canvas_height = 20;
144
+
145
+ // Couleurs ANSI
146
+ void set_color(const char* color) {
147
+ if (strcmp(color, "rouge") == 0 || strcmp(color, "red") == 0) {
148
+ printf("\033[31m");
149
+ } else if (strcmp(color, "vert") == 0 || strcmp(color, "green") == 0) {
150
+ printf("\033[32m");
151
+ } else if (strcmp(color, "jaune") == 0 || strcmp(color, "yellow") == 0) {
152
+ printf("\033[33m");
153
+ } else if (strcmp(color, "bleu") == 0 || strcmp(color, "blue") == 0) {
154
+ printf("\033[34m");
155
+ } else if (strcmp(color, "magenta") == 0) {
156
+ printf("\033[35m");
157
+ } else if (strcmp(color, "cyan") == 0) {
158
+ printf("\033[36m");
159
+ } else if (strcmp(color, "blanc") == 0 || strcmp(color, "white") == 0) {
160
+ printf("\033[37m");
161
+ } else {
162
+ printf("\033[0m");
163
+ }
164
+ }
165
+
166
+ void reset_color() {
167
+ printf("\033[0m");
168
+ }
169
+
170
+ // Fonction pour enlever les espaces en dรฉbut et fin
171
+ char* trim(char* str) {
172
+ char* end;
173
+ while(isspace((unsigned char)*str)) str++;
174
+ if(*str == 0) return str;
175
+ end = str + strlen(str) - 1;
176
+ while(end > str && isspace((unsigned char)*end)) end--;
177
+ end[1] = '\0';
178
+ return str;
179
+ }
180
+
181
+ // Fonction pour enlever les guillemets
182
+ char* remove_quotes(char* str) {
183
+ str = trim(str);
184
+ if (str[0] == '"' && str[strlen(str)-1] == '"') {
185
+ str[strlen(str)-1] = '\0';
186
+ return str + 1;
187
+ }
188
+ return str;
189
+ }
190
+
191
+ // Fonction pour trouver une variable
192
+ Variable* find_variable(const char* name) {
193
+ for (int i = 0; i < var_count; i++) {
194
+ if (strcmp(variables[i].name, name) == 0) {
195
+ return &variables[i];
196
+ }
197
+ }
198
+ return NULL;
199
+ }
200
+
201
+ // Fonction pour crรฉer ou modifier une variable
202
+ void set_variable(const char* name, const char* value) {
203
+ Variable* var = find_variable(name);
204
+ if (var == NULL) {
205
+ if (var_count < MAX_VARIABLES) {
206
+ var = &variables[var_count++];
207
+ strcpy(var->name, name);
208
+ var->is_array = 0;
209
+ var->array_size = 0;
210
+ } else {
211
+ printf("Erreur: Trop de variables!\n");
212
+ return;
213
+ }
214
+ }
215
+
216
+ strcpy(var->value, remove_quotes((char*)value));
217
+ var->num_value = atof(var->value);
218
+ var->is_number = (var->num_value != 0.0 || strcmp(var->value, "0") == 0 || strcmp(var->value, "0.0") == 0);
219
+ }
220
+
221
+ // Nouvelle fonction pour crรฉer des tableaux
222
+ void create_array(const char* name, const char* values) {
223
+ Variable* var = find_variable(name);
224
+ if (var == NULL) {
225
+ if (var_count < MAX_VARIABLES) {
226
+ var = &variables[var_count++];
227
+ strcpy(var->name, name);
228
+ } else {
229
+ printf("Erreur: Trop de variables!\n");
230
+ return;
231
+ }
232
+ }
233
+
234
+ var->is_array = 1;
235
+ var->array_size = 0;
236
+
237
+ char values_copy[500];
238
+ strncpy(values_copy, values, sizeof(values_copy) - 1);
239
+ values_copy[sizeof(values_copy) - 1] = '\0';
240
+
241
+ char* token = strtok(values_copy, ",");
242
+ while (token && var->array_size < MAX_ARRAY_SIZE) {
243
+ var->array_values[var->array_size] = atof(trim(token));
244
+ var->array_size++;
245
+ token = strtok(NULL, ",");
246
+ }
247
+ printf("Tableau %s crรฉรฉ avec %d รฉlรฉments!\n", name, var->array_size);
248
+ }
249
+
250
+ // Fonction pour initialiser le canvas
251
+ void init_canvas() {
252
+ for (int i = 0; i < canvas_height; i++) {
253
+ for (int j = 0; j < canvas_width; j++) {
254
+ current_canvas[i][j] = ' ';
255
+ }
256
+ }
257
+ }
258
+
259
+ // Fonction pour afficher le canvas
260
+ void display_canvas() {
261
+ printf("โ”Œ");
262
+ for (int j = 0; j < canvas_width; j++) printf("โ”€");
263
+ printf("โ”\n");
264
+
265
+ for (int i = 0; i < canvas_height; i++) {
266
+ printf("โ”‚");
267
+ for (int j = 0; j < canvas_width; j++) {
268
+ printf("%c", current_canvas[i][j]);
269
+ }
270
+ printf("โ”‚\n");
271
+ }
272
+
273
+ printf("โ””");
274
+ for (int j = 0; j < canvas_width; j++) printf("โ”€");
275
+ printf("โ”˜\n");
276
+ }
277
+
278
+ // Fonction pour dessiner sur le canvas
279
+ void draw_pixel(int x, int y, char pixel) {
280
+ if (x >= 0 && x < canvas_width && y >= 0 && y < canvas_height) {
281
+ current_canvas[y][x] = pixel;
282
+ }
283
+ }
284
+
285
+ // Fonction pour jouer des notes de musique
286
+ void play_note(const char* note, int duration) {
287
+ int frequency = 440; // A4 par dรฉfaut
288
+
289
+ if (strcmp(note, "do") == 0 || strcmp(note, "C") == 0) frequency = 261;
290
+ else if (strcmp(note, "re") == 0 || strcmp(note, "D") == 0) frequency = 293;
291
+ else if (strcmp(note, "mi") == 0 || strcmp(note, "E") == 0) frequency = 329;
292
+ else if (strcmp(note, "fa") == 0 || strcmp(note, "F") == 0) frequency = 349;
293
+ else if (strcmp(note, "sol") == 0 || strcmp(note, "G") == 0) frequency = 392;
294
+ else if (strcmp(note, "la") == 0 || strcmp(note, "A") == 0) frequency = 440;
295
+ else if (strcmp(note, "si") == 0 || strcmp(note, "B") == 0) frequency = 493;
296
+
297
+ printf("โ™ช Note %s (%dHz) jouรฉe pendant %dms โ™ช\n", note, frequency, duration);
298
+ usleep(duration * 1000);
299
+ }
300
+
301
+ // Fonction pour gรฉnรฉrer des nombres alรฉatoires
302
+ int random_number(int min, int max) {
303
+ return min + rand() % (max - min + 1);
304
+ }
305
+
306
+ // Dรฉclarations de fonctions
307
+ void scan_bzz_functions(const char* file_path);
308
+ int execute_package_code(const char* language, const char* file_path, const char* params);
309
+
310
+ // Fonction pour vรฉrifier si un langage est disponible
311
+ int check_language_availability(const char* language) {
312
+ char command[500];
313
+ char temp_check[300];
314
+ snprintf(temp_check, sizeof(temp_check), "/tmp/bzzbee_check_%d.txt", getpid());
315
+
316
+ if (strcmp(language, "js") == 0) {
317
+ snprintf(command, sizeof(command), "which node > '%s' 2>&1", temp_check);
318
+ } else if (strcmp(language, "py") == 0) {
319
+ snprintf(command, sizeof(command), "which python3 > '%s' 2>&1", temp_check);
320
+ } else if (strcmp(language, "jl") == 0) {
321
+ snprintf(command, sizeof(command), "which julia > '%s' 2>&1", temp_check);
322
+ } else if (strcmp(language, "rb") == 0 || strcmp(language, "rub") == 0) {
323
+ snprintf(command, sizeof(command), "which ruby > '%s' 2>&1", temp_check);
324
+ } else if (strcmp(language, "c") == 0 || strcmp(language, "C") == 0) {
325
+ snprintf(command, sizeof(command), "which gcc > '%s' 2>&1", temp_check);
326
+ } else if (strcmp(language, "bzz") == 0) {
327
+ return 1; // BzzBee est toujours disponible
328
+ } else {
329
+ return 0;
330
+ }
331
+
332
+ int result = system(command);
333
+ remove(temp_check);
334
+ return (result == 0);
335
+ }
336
+
337
+ // Fonction pour charger un package
338
+ int load_package(const char* language, const char* file_path) {
339
+ if (package_count >= MAX_PACKAGES) {
340
+ printf("โŒ Erreur: Trop de packages chargรฉs (maximum: %d)!\n", MAX_PACKAGES);
341
+ return 0;
342
+ }
343
+
344
+ // Vรฉrifier si le langage est disponible
345
+ if (!check_language_availability(language)) {
346
+ printf("โŒ Erreur: Langage '%s' non disponible sur ce systรจme!\n", language);
347
+ printf("๐Ÿ’ก Langages dรฉtectรฉs: ");
348
+ if (check_language_availability("js")) printf("js ");
349
+ if (check_language_availability("py")) printf("py ");
350
+ if (check_language_availability("jl")) printf("jl ");
351
+ if (check_language_availability("rb")) printf("rb ");
352
+ if (check_language_availability("c")) printf("c ");
353
+ printf("bzz\n");
354
+ return 0;
355
+ }
356
+
357
+ // Vรฉrifier si le fichier existe
358
+ FILE* file = fopen(file_path, "r");
359
+ if (!file) {
360
+ printf("โŒ Erreur: Fichier package '%s' introuvable!\n", file_path);
361
+ printf("๐Ÿ’ก Assurez-vous que le chemin est correct et que le fichier existe.\n");
362
+ return 0;
363
+ }
364
+ fclose(file);
365
+
366
+ // Vรฉrifier si le package n'est pas dรฉjร  chargรฉ
367
+ for (int i = 0; i < package_count; i++) {
368
+ if (strcmp(packages[i].file_path, file_path) == 0) {
369
+ printf("โš ๏ธ Package '%s' dรฉjร  chargรฉ, rechargement...\n", file_path);
370
+ packages[i].is_loaded = 1;
371
+ return 1;
372
+ }
373
+ }
374
+
375
+ Package* pkg = &packages[package_count];
376
+ sprintf(pkg->name, "package_%s_%d", language, package_count);
377
+ strcpy(pkg->language, language);
378
+ strcpy(pkg->file_path, file_path);
379
+ pkg->is_loaded = 1;
380
+
381
+ package_count++;
382
+ printf("๐Ÿ Package %s (%s) chargรฉ avec succรจs! [%d/%d]\n", file_path, language, package_count, MAX_PACKAGES);
383
+
384
+ // Test rapide du package
385
+ printf("๐Ÿงช Test du package...\n");
386
+ if (strcmp(language, "bzz") == 0) {
387
+ scan_bzz_functions(file_path);
388
+ printf("โœ… Package BzzBee analysรฉ avec succรจs!\n");
389
+ } else {
390
+ // Pour les autres langages, on teste juste la disponibilitรฉ
391
+ printf("โœ… Package %s prรชt ร  l'utilisation!\n", language);
392
+ }
393
+
394
+ return 1;
395
+ }
396
+
397
+ // Fonction pour exรฉcuter du code selon le langage et capturer la sortie
398
+ int execute_package_code(const char* language, const char* file_path, const char* params) {
399
+ char command[2000];
400
+ char temp_output[300];
401
+ snprintf(temp_output, sizeof(temp_output), "/tmp/bzzbee_output_%d.txt", getpid());
402
+
403
+ // Nettoyer les paramรจtres pour รฉviter les injections
404
+ char safe_params[500] = "";
405
+ if (params && strlen(params) > 0) {
406
+ strncpy(safe_params, params, sizeof(safe_params) - 1);
407
+ safe_params[sizeof(safe_params) - 1] = '\0';
408
+ }
409
+
410
+ if (strcmp(language, "js") == 0) {
411
+ snprintf(command, sizeof(command), "timeout 10 node '%s' %s > '%s' 2>&1", file_path, safe_params, temp_output);
412
+ } else if (strcmp(language, "py") == 0) {
413
+ snprintf(command, sizeof(command), "timeout 10 python3 '%s' %s > '%s' 2>&1", file_path, safe_params, temp_output);
414
+ } else if (strcmp(language, "jl") == 0) {
415
+ snprintf(command, sizeof(command), "timeout 10 julia '%s' %s > '%s' 2>&1", file_path, safe_params, temp_output);
416
+ } else if (strcmp(language, "rb") == 0 || strcmp(language, "rub") == 0) {
417
+ snprintf(command, sizeof(command), "timeout 10 ruby '%s' %s > '%s' 2>&1", file_path, safe_params, temp_output);
418
+ } else if (strcmp(language, "c") == 0 || strcmp(language, "C") == 0) {
419
+ // Compiler et exรฉcuter le C avec timeout
420
+ char exe_name[300];
421
+ snprintf(exe_name, sizeof(exe_name), "/tmp/bzzbee_c_%d", getpid());
422
+ snprintf(command, sizeof(command), "gcc -o '%s' '%s' -lm 2>/dev/null && timeout 10 '%s' %s > '%s' 2>&1; rm -f '%s'",
423
+ exe_name, file_path, exe_name, safe_params, temp_output, exe_name);
424
+ } else if (strcmp(language, "bzz") == 0) {
425
+ // Exรฉcuter un autre fichier BzzBee
426
+ snprintf(command, sizeof(command), "timeout 10 ./main run '%s' > '%s' 2>&1", file_path, temp_output);
427
+ } else {
428
+ printf("โŒ Langage '%s' non supportรฉ!\n", language);
429
+ return 0;
430
+ }
431
+
432
+ printf("๐Ÿ”ง Exรฉcution: %s %s\n", file_path, safe_params);
433
+ system(command);
434
+
435
+ // Lire et afficher la sortie du programme
436
+ FILE* output_file = fopen(temp_output, "r");
437
+ if (output_file) {
438
+ char line[1000];
439
+ int line_count = 0;
440
+ int has_output = 0;
441
+ while (fgets(line, sizeof(line), output_file) && line_count < 50) {
442
+ printf("%s", line);
443
+ line_count++;
444
+ has_output = 1;
445
+ }
446
+ if (line_count >= 50) {
447
+ printf("... (sortie tronquรฉe)\n");
448
+ }
449
+ if (!has_output) {
450
+ printf("โœ… Exรฉcution terminรฉe sans sortie.\n");
451
+ }
452
+ fclose(output_file);
453
+ remove(temp_output);
454
+ }
455
+
456
+ return 1; // Considรฉrer l'exรฉcution comme rรฉussie
457
+ }
458
+
459
+ // Fonction pour scanner les fonctions dans un package BzzBee
460
+ void scan_bzz_functions(const char* file_path) {
461
+ FILE* file = fopen(file_path, "r");
462
+ if (!file) return;
463
+
464
+ char line[MAX_LINE_LENGTH];
465
+ while (fgets(line, sizeof(line), file)) {
466
+ line[strcspn(line, "\n")] = 0;
467
+
468
+ // Chercher les fonctions avec le pattern pollen -> ... : miel
469
+ if (strstr(line, "pollen ->") && strstr(line, ": miel")) {
470
+ if (package_function_count < MAX_PACKAGE_FUNCTIONS) {
471
+ PackageFunction* func = &package_functions[package_function_count];
472
+ sprintf(func->name, "function_%d", package_function_count);
473
+ strcpy(func->language, "bzz");
474
+ strcpy(func->file_path, file_path);
475
+ strcpy(func->parameters, line);
476
+ package_function_count++;
477
+ printf("๐Ÿ“ Fonction BzzBee dรฉtectรฉe: %s\n", line);
478
+ }
479
+ }
480
+ }
481
+ fclose(file);
482
+ }
483
+
484
+ // Fonction pour exรฉcuter une fonction de package
485
+ int execute_package_function(const char* function_call) {
486
+ // Parser le format pollen -> params : miel [langage fichier]
487
+ char* pollen_start = strstr(function_call, "pollen ->");
488
+ char* miel_end = strstr(function_call, ": miel");
489
+
490
+ if (!pollen_start || !miel_end) {
491
+ printf("โŒ Format de fonction package incorrect!\n");
492
+ printf("๐Ÿ“ Format 1: pollen -> params : miel (utilise tous les packages)\n");
493
+ printf("๐Ÿ“ Format 2: pollen -> params : miel [langage fichier] (utilise un package spรฉcifique)\n");
494
+ return 0;
495
+ }
496
+
497
+ // Extraire les paramรจtres
498
+ char params[500];
499
+ char* param_start = pollen_start + 9; // aprรจs "pollen ->"
500
+ int param_len = miel_end - param_start;
501
+ strncpy(params, param_start, param_len);
502
+ params[param_len] = '\0';
503
+
504
+ char* trimmed_params = trim(params);
505
+
506
+ if (strlen(trimmed_params) == 0) {
507
+ printf("โŒ Aucun paramรจtre fourni pour la fonction package!\n");
508
+ return 0;
509
+ }
510
+
511
+ // Vรฉrifier s'il y a une spรฉcification de langage et fichier aprรจs ": miel"
512
+ char* spec_start = miel_end + 6; // aprรจs ": miel"
513
+ char specified_language[20] = "";
514
+ char specified_file[200] = "";
515
+ int has_specification = 0;
516
+
517
+ // Parser [langage fichier] si prรฉsent
518
+ char* bracket_open = strchr(spec_start, '[');
519
+ char* bracket_close = strchr(spec_start, ']');
520
+
521
+ if (bracket_open && bracket_close && bracket_close > bracket_open) {
522
+ has_specification = 1;
523
+ char spec_content[300];
524
+ int spec_len = bracket_close - bracket_open - 1;
525
+ strncpy(spec_content, bracket_open + 1, spec_len);
526
+ spec_content[spec_len] = '\0';
527
+
528
+ // Sรฉparer langage et fichier
529
+ char* space_pos = strchr(spec_content, ' ');
530
+ if (space_pos) {
531
+ *space_pos = '\0';
532
+ strcpy(specified_language, spec_content);
533
+ strcpy(specified_file, space_pos + 1);
534
+
535
+ // Nettoyer les espaces
536
+ char* lang_trimmed = trim(specified_language);
537
+ char* file_trimmed = trim(specified_file);
538
+ strcpy(specified_language, lang_trimmed);
539
+ strcpy(specified_file, file_trimmed);
540
+
541
+ printf("๐ŸŽฏ Langage spรฉcifiรฉ: '%s', Fichier: '%s'\n", specified_language, specified_file);
542
+ } else {
543
+ printf("โŒ Format de spรฉcification incorrect! Utilisez: [langage fichier]\n");
544
+ return 0;
545
+ }
546
+ }
547
+
548
+ printf("๐Ÿฏ Appel de fonction package: %s\n", trimmed_params);
549
+
550
+ int executed = 0;
551
+
552
+ if (has_specification) {
553
+ // Exรฉcuter avec le langage et fichier spรฉcifiรฉs
554
+ if (strlen(specified_language) > 0 && strlen(specified_file) > 0) {
555
+ // Vรฉrifier si le langage est disponible
556
+ if (!check_language_availability(specified_language)) {
557
+ printf("โŒ Langage '%s' non disponible sur ce systรจme!\n", specified_language);
558
+ return 0;
559
+ }
560
+
561
+ // Vรฉrifier si le fichier existe
562
+ FILE* file = fopen(specified_file, "r");
563
+ if (!file) {
564
+ printf("โŒ Fichier '%s' introuvable!\n", specified_file);
565
+ return 0;
566
+ }
567
+ fclose(file);
568
+
569
+ printf("๐Ÿ”ง Exรฉcution avec %s -> %s\n", specified_language, specified_file);
570
+ executed = execute_package_code(specified_language, specified_file, trimmed_params);
571
+ }
572
+ } else {
573
+ // Exรฉcuter sur tous les packages chargรฉs jusqu'ร  ce qu'un fonctionne
574
+ for (int i = 0; i < package_count; i++) {
575
+ Package* pkg = &packages[i];
576
+ if (pkg->is_loaded) {
577
+ printf("๐Ÿ” Tentative avec package %s (%s)...\n", pkg->file_path, pkg->language);
578
+ if (execute_package_code(pkg->language, pkg->file_path, trimmed_params)) {
579
+ executed = 1;
580
+ break; // Arrรชter aprรจs la premiรจre exรฉcution rรฉussie
581
+ }
582
+ }
583
+ }
584
+ }
585
+
586
+ if (!executed) {
587
+ if (has_specification) {
588
+ printf("โŒ Impossible d'exรฉcuter avec %s -> %s!\n", specified_language, specified_file);
589
+ } else if (package_count == 0) {
590
+ printf("โŒ Aucun package chargรฉ! Utilisez 'bzz PACKAGE langage -> fichier' d'abord.\n");
591
+ } else {
592
+ printf("โŒ Aucun package n'a pu exรฉcuter cette fonction!\n");
593
+ printf("๐Ÿ’ก Packages chargรฉs: ");
594
+ for (int i = 0; i < package_count; i++) {
595
+ if (packages[i].is_loaded) {
596
+ printf("%s(%s) ", packages[i].file_path, packages[i].language);
597
+ }
598
+ }
599
+ printf("\n");
600
+ }
601
+ }
602
+
603
+ return executed;
604
+ }
605
+
606
+ // Fonction pour รฉvaluer une expression mathรฉmatique avancรฉe
607
+ double evaluate_expression(const char* expr) {
608
+ char expr_copy[500];
609
+ strncpy(expr_copy, expr, sizeof(expr_copy) - 1);
610
+ expr_copy[sizeof(expr_copy) - 1] = '\0';
611
+
612
+ char* token;
613
+ double result = 0;
614
+ char operation = '+';
615
+ int first = 1;
616
+
617
+ // Support des parenthรจses simple
618
+ if (strchr(expr_copy, '(')) {
619
+ char* start = strchr(expr_copy, '(');
620
+ char* end = strchr(expr_copy, ')');
621
+ if (start && end && end > start) {
622
+ *end = '\0';
623
+ double sub_result = evaluate_expression(start + 1);
624
+ char temp[100];
625
+ sprintf(temp, "%.2f", sub_result);
626
+ strcpy(start, temp);
627
+ memmove(start + strlen(temp), end + 1, strlen(end + 1) + 1);
628
+ }
629
+ }
630
+
631
+ // Support des fonctions mathรฉmatiques
632
+ if (strstr(expr_copy, "sin(")) {
633
+ char* start = strstr(expr_copy, "sin(");
634
+ char* end = strchr(start, ')');
635
+ if (end) {
636
+ *end = '\0';
637
+ double angle = atof(start + 4);
638
+ double result_sin = sin(angle * M_PI / 180.0);
639
+ sprintf(start, "%.4f", result_sin);
640
+ memmove(start + strlen(start), end + 1, strlen(end + 1) + 1);
641
+ }
642
+ }
643
+
644
+ if (strstr(expr_copy, "cos(")) {
645
+ char* start = strstr(expr_copy, "cos(");
646
+ char* end = strchr(start, ')');
647
+ if (end) {
648
+ *end = '\0';
649
+ double angle = atof(start + 4);
650
+ double result_cos = cos(angle * M_PI / 180.0);
651
+ sprintf(start, "%.4f", result_cos);
652
+ memmove(start + strlen(start), end + 1, strlen(end + 1) + 1);
653
+ }
654
+ }
655
+
656
+ if (strstr(expr_copy, "sqrt(")) {
657
+ char* start = strstr(expr_copy, "sqrt(");
658
+ char* end = strchr(start, ')');
659
+ if (end) {
660
+ *end = '\0';
661
+ double value = atof(start + 5);
662
+ double result_sqrt = sqrt(value);
663
+ sprintf(start, "%.4f", result_sqrt);
664
+ memmove(start + strlen(start), end + 1, strlen(end + 1) + 1);
665
+ }
666
+ }
667
+
668
+ token = strtok(expr_copy, " ");
669
+ while (token != NULL) {
670
+ if (strcmp(token, "+") == 0) {
671
+ operation = '+';
672
+ } else if (strcmp(token, "-") == 0) {
673
+ operation = '-';
674
+ } else if (strcmp(token, "*") == 0) {
675
+ operation = '*';
676
+ } else if (strcmp(token, "/") == 0) {
677
+ operation = '/';
678
+ } else if (strcmp(token, "^") == 0 || strcmp(token, "**") == 0) {
679
+ operation = '^';
680
+ } else if (strcmp(token, "%") == 0) {
681
+ operation = '%';
682
+ } else {
683
+ double value;
684
+ Variable* var = find_variable(token);
685
+ if (var && var->is_number) {
686
+ value = var->num_value;
687
+ } else {
688
+ value = atof(token);
689
+ }
690
+
691
+ if (first) {
692
+ result = value;
693
+ first = 0;
694
+ } else {
695
+ switch (operation) {
696
+ case '+': result += value; break;
697
+ case '-': result -= value; break;
698
+ case '*': result *= value; break;
699
+ case '/':
700
+ if (value != 0) result /= value;
701
+ else printf("Erreur: Division par zรฉro!\n");
702
+ break;
703
+ case '^': result = pow(result, value); break;
704
+ case '%': result = fmod(result, value); break;
705
+ }
706
+ }
707
+ }
708
+ token = strtok(NULL, " ");
709
+ }
710
+ return result;
711
+ }
712
+
713
+ // Fonction pour รฉvaluer une condition
714
+ int evaluate_condition(const char* condition) {
715
+ char cond_copy[500];
716
+ strncpy(cond_copy, condition, sizeof(cond_copy) - 1);
717
+ cond_copy[sizeof(cond_copy) - 1] = '\0';
718
+ char* var_name = strtok(cond_copy, " ");
719
+ char* operator = strtok(NULL, " ");
720
+ char* value = strtok(NULL, " ");
721
+
722
+ if (!var_name || !operator || !value) {
723
+ return 0;
724
+ }
725
+
726
+ Variable* var = find_variable(var_name);
727
+ if (!var) {
728
+ return 0;
729
+ }
730
+
731
+ int result = 0;
732
+ if (strcmp(operator, "==") == 0) {
733
+ result = (strcmp(var->value, value) == 0);
734
+ } else if (strcmp(operator, "!=") == 0) {
735
+ result = (strcmp(var->value, value) != 0);
736
+ } else if (strcmp(operator, ">") == 0 && var->is_number) {
737
+ result = (var->num_value > atof(value));
738
+ } else if (strcmp(operator, "<") == 0 && var->is_number) {
739
+ result = (var->num_value < atof(value));
740
+ } else if (strcmp(operator, ">=") == 0 && var->is_number) {
741
+ result = (var->num_value >= atof(value));
742
+ } else if (strcmp(operator, "<=") == 0 && var->is_number) {
743
+ result = (var->num_value <= atof(value));
744
+ }
745
+
746
+ return result;
747
+ }
748
+
749
+ // Fonction pour dessiner des formes ASCII
750
+ void draw_ascii(const char* shape) {
751
+ if (strcmp(shape, "abeille") == 0) {
752
+ printf(" ___\n");
753
+ printf(" / \\\n");
754
+ printf(" | () () |\n");
755
+ printf(" \\ ^ /\n");
756
+ printf(" ||||||\n");
757
+ printf(" ||||||\n");
758
+ printf(" /_____\\\n");
759
+ } else if (strcmp(shape, "ruche") == 0) {
760
+ printf(" /\\_/\\_/\\\n");
761
+ printf(" / \\\n");
762
+ printf(" | RUCHE |\n");
763
+ printf(" |_________|\n");
764
+ printf(" \\_______/\n");
765
+ } else if (strcmp(shape, "fleur") == 0) {
766
+ printf(" .-'~~~'-.\n");
767
+ printf(" / \\\n");
768
+ printf(" | () () () |\n");
769
+ printf(" \\ ^ /\n");
770
+ printf(" | | |\n");
771
+ printf(" | | |\n");
772
+ } else if (strcmp(shape, "hexagone") == 0) {
773
+ printf(" ___\n");
774
+ printf(" / \\\n");
775
+ printf(" | |\n");
776
+ printf(" | |\n");
777
+ printf(" \\___/\n");
778
+ } else if (strcmp(shape, "soleil") == 0) {
779
+ printf(" \\ | /\n");
780
+ printf(" \\ | /\n");
781
+ printf(" --- \\(o)/ ---\n");
782
+ printf(" / | \\\n");
783
+ printf(" / | /\n");
784
+ } else if (strcmp(shape, "nuage") == 0) {
785
+ printf(" .-~~~-.\n");
786
+ printf(" .-~ ~-.\n");
787
+ printf(" ( )\n");
788
+ printf(" '-.._____..-'\n");
789
+ } else if (strcmp(shape, "coeur") == 0) {
790
+ printf(" โ™ฅโ™ฅ โ™ฅโ™ฅ\n");
791
+ printf(" โ™ฅโ™ฅโ™ฅโ™ฅ โ™ฅโ™ฅโ™ฅโ™ฅ\n");
792
+ printf("โ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅ\n");
793
+ printf(" โ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅ\n");
794
+ printf(" โ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅโ™ฅ\n");
795
+ printf(" โ™ฅโ™ฅโ™ฅโ™ฅโ™ฅ\n");
796
+ printf(" โ™ฅโ™ฅโ™ฅ\n");
797
+ printf(" โ™ฅ\n");
798
+ } else {
799
+ printf("Forme '%s' non reconnue.\n", shape);
800
+ printf("Formes disponibles: abeille, ruche, fleur, hexagone, soleil, nuage, coeur\n");
801
+ }
802
+ }
803
+
804
+ // Fonction pour lire un seul caractรจre sans echo
805
+ int getch() {
806
+ struct termios oldattr, newattr;
807
+ int ch;
808
+ tcgetattr( STDIN_FILENO, &oldattr );
809
+ newattr = oldattr;
810
+ newattr.c_lflag &= ~( ICANON | ECHO );
811
+ tcsetattr( STDIN_FILENO, TCSANOW, &newattr );
812
+ ch = getchar();
813
+ tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );
814
+ return ch;
815
+ }
816
+
817
+ // Fonction pour interprรฉter une ligne
818
+ int interpret_line(char* line) {
819
+ line = trim(line);
820
+
821
+ // Ignorer les lignes vides et les commentaires
822
+ if (strlen(line) == 0 || line[0] == '#') {
823
+ return 0;
824
+ }
825
+
826
+ // bzz R console -> message
827
+ if (strncmp(line, "bzz R console ->", 16) == 0) {
828
+ char* message = line + 16;
829
+ message = trim(message);
830
+ printf("%s\n", remove_quotes(message));
831
+ }
832
+
833
+ // bzz R couleur -> texte
834
+ else if (strncmp(line, "bzz R couleur", 13) == 0) {
835
+ char* rest = line + 13;
836
+ char* arrow = strstr(rest, "->");
837
+ if (arrow) {
838
+ *arrow = '\0';
839
+ char* color = trim(rest);
840
+ char* text = trim(arrow + 2);
841
+ set_color(color);
842
+ printf("%s\n", remove_quotes(text));
843
+ reset_color();
844
+ }
845
+ }
846
+
847
+ // bzz STOCK variable -> valeur
848
+ else if (strncmp(line, "bzz STOCK", 9) == 0) {
849
+ char* rest = line + 9;
850
+ char* arrow = strstr(rest, "->");
851
+ if (arrow) {
852
+ *arrow = '\0';
853
+ char* var_name = trim(rest);
854
+ char* value = trim(arrow + 2);
855
+ set_variable(var_name, value);
856
+ printf("Variable %s = %s stockรฉe dans la ruche!\n", var_name, remove_quotes(value));
857
+ }
858
+ }
859
+
860
+ // bzz TABLEAU nom -> valeur1,valeur2,valeur3
861
+ else if (strncmp(line, "bzz TABLEAU", 11) == 0) {
862
+ char* rest = line + 11;
863
+ char* arrow = strstr(rest, "->");
864
+ if (arrow) {
865
+ *arrow = '\0';
866
+ char* array_name = trim(rest);
867
+ char* values = trim(arrow + 2);
868
+ create_array(array_name, remove_quotes(values));
869
+ }
870
+ }
871
+
872
+ // bzz LISTE AJOUTER <liste> <รฉlรฉment>
873
+ else if (strncmp(line, "bzz LISTE AJOUTER", 16) == 0) {
874
+ char* rest = line + 16;
875
+ char* list_name = strtok(rest, " ");
876
+ char* element = strtok(NULL, "");
877
+ if (list_name && element) {
878
+ List* list = NULL;
879
+ for (int i = 0; i < list_count; i++) {
880
+ if (strcmp(lists[i].name, list_name) == 0) {
881
+ list = &lists[i];
882
+ break;
883
+ }
884
+ }
885
+ if (!list) {
886
+ if (list_count < MAX_LISTS) {
887
+ list = &lists[list_count++];
888
+ strcpy(list->name, list_name);
889
+ list->size = 0;
890
+ } else {
891
+ printf("Erreur: Trop de listes!\n");
892
+ return 0;
893
+ }
894
+ }
895
+ if (list->size < MAX_LIST_SIZE) {
896
+ strcpy(list->elements[list->size], remove_quotes(trim(element)));
897
+ list->size++;
898
+ printf("ร‰lรฉment '%s' ajoutรฉ ร  la liste '%s' (taille: %d)\n", remove_quotes(trim(element)), list_name, list->size);
899
+ } else {
900
+ printf("Erreur: Liste pleine!\n");
901
+ }
902
+ } else {
903
+ printf("Format: bzz LISTE AJOUTER <liste> <รฉlรฉment>\n");
904
+ }
905
+ }
906
+
907
+ // bzz LISTE RETIRER <liste> <รฉlรฉment>
908
+ else if (strncmp(line, "bzz LISTE RETIRER", 16) == 0) {
909
+ char* rest = line + 16;
910
+ char* list_name = strtok(rest, " ");
911
+ char* element = strtok(NULL, "");
912
+ if (list_name && element) {
913
+ List* list = NULL;
914
+ for (int i = 0; i < list_count; i++) {
915
+ if (strcmp(lists[i].name, list_name) == 0) {
916
+ list = &lists[i];
917
+ break;
918
+ }
919
+ }
920
+ if (!list) {
921
+ printf("Erreur: Liste non trouvรฉe!\n");
922
+ return 0;
923
+ }
924
+
925
+ int found = 0;
926
+ for (int i = 0; i < list->size; i++) {
927
+ if (strcmp(list->elements[i], remove_quotes(trim(element))) == 0) {
928
+ // Dรฉcaler les รฉlรฉments suivants
929
+ for (int j = i; j < list->size - 1; j++) {
930
+ strcpy(list->elements[j], list->elements[j + 1]);
931
+ }
932
+ list->size--;
933
+ found = 1;
934
+ printf("ร‰lรฉment '%s' retirรฉ de la liste '%s' (taille: %d)\n", remove_quotes(trim(element)), list_name, list->size);
935
+ break;
936
+ }
937
+ }
938
+ if (!found) {
939
+ printf("Erreur: ร‰lรฉment non trouvรฉ dans la liste!\n");
940
+ }
941
+ } else {
942
+ printf("Format: bzz LISTE RETIRER <liste> <รฉlรฉment>\n");
943
+ }
944
+ }
945
+
946
+ // bzz LISTE TAILLE <liste>
947
+ else if (strncmp(line, "bzz LISTE TAILLE", 15) == 0) {
948
+ char* list_name = trim(line + 15);
949
+ List* list = NULL;
950
+ for (int i = 0; i < list_count; i++) {
951
+ if (strcmp(lists[i].name, list_name) == 0) {
952
+ list = &lists[i];
953
+ break;
954
+ }
955
+ }
956
+ if (!list) {
957
+ printf("Erreur: Liste non trouvรฉe!\n");
958
+ return 0;
959
+ }
960
+ printf("Taille de la liste '%s': %d\n", list_name, list->size);
961
+ }
962
+
963
+ // bzz LISTE INDEX <liste> <รฉlรฉment>
964
+ else if (strncmp(line, "bzz LISTE INDEX", 14) == 0) {
965
+ char* rest = line + 14;
966
+ char* list_name = strtok(rest, " ");
967
+ char* element = strtok(NULL, "");
968
+ if (list_name && element) {
969
+ List* list = NULL;
970
+ for (int i = 0; i < list_count; i++) {
971
+ if (strcmp(lists[i].name, list_name) == 0) {
972
+ list = &lists[i];
973
+ break;
974
+ }
975
+ }
976
+ if (!list) {
977
+ printf("Erreur: Liste non trouvรฉe!\n");
978
+ return 0;
979
+ }
980
+
981
+ int index = -1;
982
+ for (int i = 0; i < list->size; i++) {
983
+ if (strcmp(list->elements[i], remove_quotes(trim(element))) == 0) {
984
+ index = i;
985
+ break;
986
+ }
987
+ }
988
+
989
+ if (index != -1) {
990
+ printf("Index de l'รฉlรฉment '%s' dans la liste '%s': %d\n", remove_quotes(trim(element)), list_name, index);
991
+ } else {
992
+ printf("Erreur: ร‰lรฉment non trouvรฉ dans la liste!\n");
993
+ }
994
+ } else {
995
+ printf("Format: bzz LISTE INDEX <liste> <รฉlรฉment>\n");
996
+ }
997
+ }
998
+
999
+ // bzz LISTE TRIER <liste>
1000
+ else if (strncmp(line, "bzz LISTE TRIER", 14) == 0) {
1001
+ char* list_name = trim(line + 14);
1002
+ List* list = NULL;
1003
+ for (int i = 0; i < list_count; i++) {
1004
+ if (strcmp(lists[i].name, list_name) == 0) {
1005
+ list = &lists[i];
1006
+ break;
1007
+ }
1008
+ }
1009
+ if (!list) {
1010
+ printf("Erreur: Liste non trouvรฉe!\n");
1011
+ return 0;
1012
+ }
1013
+
1014
+ // Tri ร  bulles (simple pour l'exemple)
1015
+ for (int i = 0; i < list->size - 1; i++) {
1016
+ for (int j = 0; j < list->size - i - 1; j++) {
1017
+ if (strcmp(list->elements[j], list->elements[j + 1]) > 0) {
1018
+ char temp[200];
1019
+ strcpy(temp, list->elements[j]);
1020
+ strcpy(list->elements[j], list->elements[j + 1]);
1021
+ strcpy(list->elements[j + 1], temp);
1022
+ }
1023
+ }
1024
+ }
1025
+ printf("Liste '%s' triรฉe!\n", list_name);
1026
+ }
1027
+
1028
+ // bzz NECTAR AJOUTER <pot> <clรฉ> <valeur>
1029
+ else if (strncmp(line, "bzz NECTAR AJOUTER", 18) == 0) {
1030
+ char* rest = line + 18;
1031
+ char* dict_name = strtok(rest, " ");
1032
+ char* key = strtok(NULL, " ");
1033
+ char* value = strtok(NULL, "");
1034
+
1035
+ if (dict_name && key && value) {
1036
+ Dictionary* dict = NULL;
1037
+ for (int i = 0; i < dict_count; i++) {
1038
+ if (strcmp(dictionaries[i].name, dict_name) == 0) {
1039
+ dict = &dictionaries[i];
1040
+ break;
1041
+ }
1042
+ }
1043
+ if (!dict) {
1044
+ if (dict_count < MAX_DICTS) {
1045
+ dict = &dictionaries[dict_count++];
1046
+ strcpy(dict->name, dict_name);
1047
+ dict->size = 0;
1048
+ } else {
1049
+ printf("Erreur: Trop de dictionnaires!\n");
1050
+ return 0;
1051
+ }
1052
+ }
1053
+
1054
+ if (dict->size < MAX_DICT_SIZE) {
1055
+ strcpy(dict->entries[dict->size].key, remove_quotes(trim(key)));
1056
+ strcpy(dict->entries[dict->size].value, remove_quotes(trim(value)));
1057
+ dict->size++;
1058
+ printf("Ajoutรฉ: %s -> %s dans le dictionnaire '%s'\n", remove_quotes(trim(key)), remove_quotes(trim(value)), dict_name);
1059
+ } else {
1060
+ printf("Erreur: Dictionnaire plein!\n");
1061
+ }
1062
+ } else {
1063
+ printf("Format: bzz NECTAR AJOUTER <pot> <clรฉ> <valeur>\n");
1064
+ }
1065
+ }
1066
+
1067
+ // bzz NECTAR LIRE <pot> <clรฉ>
1068
+ else if (strncmp(line, "bzz NECTAR LIRE", 15) == 0) {
1069
+ char* rest = line + 15;
1070
+ char* dict_name = strtok(rest, " ");
1071
+ char* key = strtok(NULL, "");
1072
+
1073
+ if (dict_name && key) {
1074
+ Dictionary* dict = NULL;
1075
+ for (int i = 0; i < dict_count; i++) {
1076
+ if (strcmp(dictionaries[i].name, dict_name) == 0) {
1077
+ dict = &dictionaries[i];
1078
+ break;
1079
+ }
1080
+ }
1081
+ if (!dict) {
1082
+ printf("Erreur: Dictionnaire non trouvรฉ!\n");
1083
+ return 0;
1084
+ }
1085
+
1086
+ int found = 0;
1087
+ for (int i = 0; i < dict->size; i++) {
1088
+ if (strcmp(dict->entries[i].key, remove_quotes(trim(key))) == 0) {
1089
+ printf("Valeur de '%s' dans '%s': %s\n", remove_quotes(trim(key)), dict_name, dict->entries[i].value);
1090
+ found = 1;
1091
+ break;
1092
+ }
1093
+ }
1094
+
1095
+ if (!found) {
1096
+ printf("Erreur: Clรฉ non trouvรฉe dans le dictionnaire!\n");
1097
+ }
1098
+ } else {
1099
+ printf("Format: bzz NECTAR LIRE <pot> <clรฉ>\n");
1100
+ }
1101
+ }
1102
+
1103
+ // bzz NECTAR SUPPRIMER <pot> <clรฉ>
1104
+ else if (strncmp(line, "bzz NECTAR SUPPRIMER", 20) == 0) {
1105
+ char* rest = line + 20;
1106
+ char* dict_name = strtok(rest, " ");
1107
+ char* key = strtok(NULL, "");
1108
+
1109
+ if (dict_name && key) {
1110
+ Dictionary* dict = NULL;
1111
+ for (int i = 0; i < dict_count; i++) {
1112
+ if (strcmp(dictionaries[i].name, dict_name) == 0) {
1113
+ dict = &dictionaries[i];
1114
+ break;
1115
+ }
1116
+ }
1117
+ if (!dict) {
1118
+ printf("Erreur: Dictionnaire non trouvรฉ!\n");
1119
+ return 0;
1120
+ }
1121
+
1122
+ int found = 0;
1123
+ for (int i = 0; i < dict->size; i++) {
1124
+ if (strcmp(dict->entries[i].key, remove_quotes(trim(key))) == 0) {
1125
+ // Dรฉcaler les รฉlรฉments suivants
1126
+ for (int j = i; j < dict->size - 1; j++) {
1127
+ strcpy(dict->entries[j].key, dict->entries[j + 1].key);
1128
+ strcpy(dict->entries[j].value, dict->entries[j + 1].value);
1129
+ }
1130
+ dict->size--;
1131
+ found = 1;
1132
+ printf("Clรฉ '%s' supprimรฉe du dictionnaire '%s'\n", remove_quotes(trim(key)), dict_name);
1133
+ break;
1134
+ }
1135
+ }
1136
+
1137
+ if (!found) {
1138
+ printf("Erreur: Clรฉ non trouvรฉe dans le dictionnaire!\n");
1139
+ }
1140
+ } else {
1141
+ printf("Format: bzz NECTAR SUPPRIMER <pot> <clรฉ>\n");
1142
+ }
1143
+ }
1144
+
1145
+ // bzz MONTRE variable
1146
+ else if (strncmp(line, "bzz MONTRE", 10) == 0) {
1147
+ char* var_name = trim(line + 10);
1148
+ Variable* var = find_variable(var_name);
1149
+ if (var) {
1150
+ if (var->is_array) {
1151
+ printf("Tableau %s: [", var_name);
1152
+ for (int i = 0; i < var->array_size; i++) {
1153
+ printf("%.2f", var->array_values[i]);
1154
+ if (i < var->array_size - 1) printf(", ");
1155
+ }
1156
+ printf("]\n");
1157
+ } else {
1158
+ printf("%s\n", var->value);
1159
+ }
1160
+ } else {
1161
+ printf("Variable %s non trouvรฉe dans la ruche!\n", var_name);
1162
+ }
1163
+ }
1164
+
1165
+ // bzz CALCUL expression
1166
+ else if (strncmp(line, "bzz CALCUL", 10) == 0) {
1167
+ char* expr = trim(line + 10);
1168
+ double result = evaluate_expression(expr);
1169
+ if (result == (int)result) {
1170
+ printf("%.0f\n", result);
1171
+ } else {
1172
+ printf("%.2f\n", result);
1173
+ }
1174
+ }
1175
+
1176
+ // bzz HASARD min max
1177
+ else if (strncmp(line, "bzz HASARD", 10) == 0) {
1178
+ char* rest = trim(line + 10);
1179
+ char* min_str = strtok(rest, " ");
1180
+ char* max_str = strtok(NULL, " ");
1181
+ if (min_str && max_str) {
1182
+ int min = atoi(min_str);
1183
+ int max = atoi(max_str);
1184
+ int result = random_number(min, max);
1185
+ printf("Nombre alรฉatoire entre %d et %d: %d\n", min, max, result);
1186
+ }
1187
+ }
1188
+
1189
+ // bzz MUSIQUE note durรฉe
1190
+ else if (strncmp(line, "bzz MUSIQUE", 11) == 0) {
1191
+ char* rest = trim(line + 11);
1192
+ char* note = strtok(rest, " ");
1193
+ char* duration_str = strtok(NULL, " ");
1194
+ if (note && duration_str) {
1195
+ int duration = atoi(duration_str);
1196
+ play_note(note, duration);
1197
+ }
1198
+ }
1199
+
1200
+ // bzz TOILE INIT
1201
+ else if (strcmp(line, "bzz TOILE INIT") == 0) {
1202
+ init_canvas();
1203
+ printf("Canvas initialisรฉ (%dx%d)!\n", canvas_width, canvas_height);
1204
+ }
1205
+
1206
+ // bzz TOILE MONTRE
1207
+ else if (strcmp(line, "bzz TOILE MONTRE") == 0) {
1208
+ display_canvas();
1209
+ }
1210
+
1211
+ // bzz PIXEL x y caractรจre
1212
+ else if (strncmp(line, "bzz PIXEL", 9) == 0) {
1213
+ char* rest = trim(line + 9);
1214
+ char* x_str = strtok(rest, " ");
1215
+ char* y_str = strtok(NULL, " ");
1216
+ char* pixel_str = strtok(NULL, " ");
1217
+ if (x_str && y_str && pixel_str) {
1218
+ int x = atoi(x_str);
1219
+ int y = atoi(y_str);
1220
+ char pixel = pixel_str[0];
1221
+ draw_pixel(x, y, pixel);
1222
+ printf("Pixel (%d,%d) = '%c' dessinรฉ!\n", x, y, pixel);
1223
+ }
1224
+ }
1225
+
1226
+ // bzz TEXTE x y message
1227
+ else if (strncmp(line, "bzz TEXTE", 9) == 0) {
1228
+ char* rest = trim(line + 9);
1229
+ char* x_str = strtok(rest, " ");
1230
+ char* y_str = strtok(NULL, " ");
1231
+ char* text = strtok(NULL, "");
1232
+ if (x_str && y_str && text) {
1233
+ int x = atoi(x_str);
1234
+ int y = atoi(y_str);
1235
+ text = remove_quotes(trim(text));
1236
+ int text_len = strlen(text);
1237
+ for (int i = 0; i < text_len && x + i < canvas_width; i++) {
1238
+ draw_pixel(x + i, y, text[i]);
1239
+ }
1240
+ printf("Texte '%s' dessinรฉ ร  (%d,%d)!\n", text, x, y);
1241
+ }
1242
+ }
1243
+
1244
+ // bzz LIGNE x1 y1 x2 y2 caractรจre
1245
+ else if (strncmp(line, "bzz LIGNE", 9) == 0) {
1246
+ char* rest = trim(line + 9);
1247
+ char* x1_str = strtok(rest, " ");
1248
+ char* y1_str = strtok(NULL, " ");
1249
+ char* x2_str = strtok(NULL, " ");
1250
+ char* y2_str = strtok(NULL, " ");
1251
+ char* pixel_str = strtok(NULL, " ");
1252
+
1253
+ if (x1_str && y1_str && x2_str && y2_str && pixel_str) {
1254
+ int x1 = atoi(x1_str), y1 = atoi(y1_str);
1255
+ int x2 = atoi(x2_str), y2 = atoi(y2_str);
1256
+ char pixel = pixel_str[0];
1257
+
1258
+ // Algorithme de Bresenham simplifiรฉ
1259
+ int dx = abs(x2 - x1);
1260
+ int dy = abs(y2 - y1);
1261
+ int x = x1, y = y1;
1262
+ int x_inc = (x1 < x2) ? 1 : -1;
1263
+ int y_inc = (y1 < y2) ? 1 : -1;
1264
+ int error = dx - dy;
1265
+
1266
+ while (1) {
1267
+ draw_pixel(x, y, pixel);
1268
+ if (x == x2 && y == y2) break;
1269
+ int e2 = 2 * error;
1270
+ if (e2 > -dy) { error -= dy; x += x_inc; }
1271
+ if (e2 < dx) { error += dx; y += y_inc; }
1272
+ }
1273
+ printf("Ligne de (%d,%d) ร  (%d,%d) dessinรฉe!\n", x1, y1, x2, y2);
1274
+ }
1275
+ }
1276
+
1277
+ // bzz DESSINE forme
1278
+ else if (strncmp(line, "bzz DESSINE", 11) == 0) {
1279
+ char* shape = trim(line + 11);
1280
+ draw_ascii(shape);
1281
+ }
1282
+
1283
+ // bzz DORT millisecondes
1284
+ else if (strncmp(line, "bzz DORT", 8) == 0) {
1285
+ char* time_str = trim(line + 8);
1286
+ int milliseconds = atoi(time_str);
1287
+ usleep(milliseconds * 1000);
1288
+ printf("L'abeille a dormi %d ms... Bzzzz\n", milliseconds);
1289
+ }
1290
+
1291
+ // bzz SI condition ALORS
1292
+ else if (strncmp(line, "bzz SI", 6) == 0) {
1293
+ char* condition = line + 6;
1294
+ char* alors = strstr(condition, "ALORS");
1295
+ if (alors) {
1296
+ *alors = '\0';
1297
+ condition = trim(condition);
1298
+ if (evaluate_condition(condition)) {
1299
+ printf("Condition vraie! Bzzzz!\n");
1300
+ skip_until_end = 0;
1301
+ } else {
1302
+ printf("Condition fausse! Bzzzz...\n");
1303
+ skip_until_end = 1;
1304
+ }
1305
+ }
1306
+ }
1307
+
1308
+ // bzz SINON
1309
+ else if (strcmp(line, "bzz SINON") == 0) {
1310
+ skip_until_end = !skip_until_end;
1311
+ if (!skip_until_end) {
1312
+ printf("Branche SINON exรฉcutรฉe! Bzzzz!\n");
1313
+ }
1314
+ }
1315
+
1316
+ // bzz FIN
1317
+ else if (strcmp(line, "bzz FIN") == 0) {
1318
+ skip_until_end = 0;
1319
+ }
1320
+
1321
+ // bzz POUR variable DE valeur A valeur
1322
+ else if (strncmp(line, "bzz POUR", 8) == 0) {
1323
+ char* rest = line + 8;
1324
+ char* var_name = strtok(rest, " ");
1325
+ char* de = strtok(NULL, " ");
1326
+ char* start_val = strtok(NULL, " ");
1327
+ char* a = strtok(NULL, " ");
1328
+ char* end_val = strtok(NULL, " ");
1329
+
1330
+ if (var_name && de && start_val && a && end_val &&
1331
+ strcmp(de, "DE") == 0 && strcmp(a, "A") == 0) {
1332
+ int start = atoi(start_val);
1333
+ int end = atoi(end_val);
1334
+
1335
+ if (loop_count < MAX_LOOPS) {
1336
+ loops[loop_count].start_line = current_line;
1337
+ loops[loop_count].current_iteration = start;
1338
+ loops[loop_count].max_iterations = end;
1339
+ strcpy(loops[loop_count].condition, var_name);
1340
+ loops[loop_count].is_active = 1;
1341
+
1342
+ char val_str[20];
1343
+ sprintf(val_str, "%d", start);
1344
+ set_variable(var_name, val_str);
1345
+
1346
+ loop_count++;
1347
+ printf("Dรฉbut de boucle POUR %s de %d ร  %d\n", var_name, start, end);
1348
+ }
1349
+ }
1350
+ }
1351
+
1352
+ // bzz SUIVANT
1353
+ else if (strcmp(line, "bzz SUIVANT") == 0) {
1354
+ if (loop_count > 0) {
1355
+ Loop* current_loop = &loops[loop_count - 1];
1356
+ current_loop->current_iteration++;
1357
+
1358
+ if (current_loop->current_iteration <= current_loop->max_iterations) {
1359
+ char val_str[20];
1360
+ sprintf(val_str, "%d", current_loop->current_iteration);
1361
+ set_variable(current_loop->condition, val_str);
1362
+
1363
+ current_line = current_loop->start_line;
1364
+ return 1;
1365
+ } else {
1366
+ printf("Fin de boucle POUR\n");
1367
+ loop_count--;
1368
+ }
1369
+ }
1370
+ }
1371
+
1372
+ // bzz QUIZ question -> reponse
1373
+ else if (strncmp(line, "bzz QUIZ", 8) == 0) {
1374
+ char* rest = line + 8;
1375
+ char* arrow = strstr(rest, "->");
1376
+ if (arrow) {
1377
+ *arrow = '\0';
1378
+ char* question = trim(rest);
1379
+ char* answer = trim(arrow + 2);
1380
+ printf("Question: %s\n", remove_quotes(question));
1381
+ printf("Votre rรฉponse: ");
1382
+ char user_answer[100];
1383
+ if (fgets(user_answer, sizeof(user_answer), stdin)) {
1384
+ user_answer[strcspn(user_answer, "\n")] = 0;
1385
+
1386
+ if (strcmp(trim(user_answer), remove_quotes(answer)) == 0) {
1387
+ printf("Bzzzz! Bonne rรฉponse!\n");
1388
+ } else {
1389
+ printf("Bzzzz... Mauvaise rรฉponse. La bonne rรฉponse รฉtait: %s\n", remove_quotes(answer));
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+
1395
+ // bzz FICHIER LIRE <chemin_fichier> : contenu_variable
1396
+ else if (strncmp(line, "bzz FICHIER LIRE", 16) == 0) {
1397
+ char* rest = line + 16;
1398
+ char* file_path = strtok(rest, " :");
1399
+ char* var_name = strtok(NULL, "");
1400
+
1401
+ if (file_path && var_name) {
1402
+ file_path = trim(file_path);
1403
+ var_name = trim(var_name);
1404
+
1405
+ FILE* file = fopen(remove_quotes(file_path), "r");
1406
+ if (!file) {
1407
+ printf("Erreur: Fichier '%s' introuvable!\n", remove_quotes(file_path));
1408
+ } else {
1409
+ char buffer[MAX_VAR_VALUE];
1410
+ size_t bytes_read = fread(buffer, 1, sizeof(buffer) - 1, file);
1411
+ buffer[bytes_read] = '\0';
1412
+ fclose(file);
1413
+
1414
+ set_variable(var_name, buffer);
1415
+ printf("Contenu du fichier '%s' lu (%zu octets) et stockรฉ dans '%s'\n", remove_quotes(file_path), bytes_read, var_name);
1416
+ }
1417
+ } else {
1418
+ printf("Format: bzz FICHIER LIRE <chemin_fichier> : contenu_variable\n");
1419
+ }
1420
+ }
1421
+
1422
+ // bzz FICHIER ร‰CRIRE <chemin_fichier> <contenu>
1423
+ else if (strncmp(line, "bzz FICHIER ร‰CRIRE", 18) == 0) {
1424
+ char* rest = line + 18;
1425
+ char* file_path = strtok(rest, " ");
1426
+ char* content = strtok(NULL, "");
1427
+
1428
+ if (file_path && content) {
1429
+ file_path = trim(file_path);
1430
+ content = trim(content);
1431
+
1432
+ FILE* file = fopen(remove_quotes(file_path), "w");
1433
+ if (!file) {
1434
+ printf("Erreur: Impossible d'ouvrir le fichier '%s' pour รฉcriture!\n", remove_quotes(file_path));
1435
+ } else {
1436
+ fprintf(file, "%s", remove_quotes(content));
1437
+ fclose(file);
1438
+ printf("Contenu รฉcrit dans le fichier '%s'\n", remove_quotes(file_path));
1439
+ }
1440
+ } else {
1441
+ printf("Format: bzz FICHIER ร‰CRIRE <chemin_fichier> <contenu>\n");
1442
+ }
1443
+ }
1444
+
1445
+ // bzz FICHIER EXISTE <chemin_fichier> : bool_variable
1446
+ else if (strncmp(line, "bzz FICHIER EXISTE", 18) == 0) {
1447
+ char* rest = line + 18;
1448
+ char* file_path = strtok(rest, " :");
1449
+ char* var_name = strtok(NULL, "");
1450
+
1451
+ if (file_path && var_name) {
1452
+ file_path = trim(file_path);
1453
+ var_name = trim(var_name);
1454
+
1455
+ if (access(remove_quotes(file_path), F_OK) != -1) {
1456
+ set_variable(var_name, "true");
1457
+ printf("Le fichier '%s' existe. Variable '%s' mise ร  'true'\n", remove_quotes(file_path), var_name);
1458
+ } else {
1459
+ set_variable(var_name, "false");
1460
+ printf("Le fichier '%s' n'existe pas. Variable '%s' mise ร  'false'\n", remove_quotes(file_path), var_name);
1461
+ }
1462
+ } else {
1463
+ printf("Format: bzz FICHIER EXISTE <chemin_fichier> : bool_variable\n");
1464
+ }
1465
+ }
1466
+
1467
+ // bzz FICHIER SUPPRIMER <chemin_fichier>
1468
+ else if (strncmp(line, "bzz FICHIER SUPPRIMER", 21) == 0) {
1469
+ char* file_path = trim(line + 21);
1470
+
1471
+ if (file_path) {
1472
+ if (remove(remove_quotes(file_path)) == 0) {
1473
+ printf("Fichier '%s' supprimรฉ avec succรจs\n", remove_quotes(file_path));
1474
+ } else {
1475
+ printf("Erreur: Impossible de supprimer le fichier '%s'\n", remove_quotes(file_path));
1476
+ }
1477
+ } else {
1478
+ printf("Format: bzz FICHIER SUPPRIMER <chemin_fichier>\n");
1479
+ }
1480
+ }
1481
+
1482
+ // bzz ESSAI ... CAPTURE ... FIN_ESSAI
1483
+ else if (strncmp(line, "bzz ESSAI", 9) == 0) {
1484
+ int essai_start_line = current_line;
1485
+ int capture_start_line = -1;
1486
+ int fin_essai_line = -1;
1487
+
1488
+ // Trouver les lignes CAPTURE et FIN_ESSAI
1489
+ for (int i = current_line + 1; i < total_lines; i++) {
1490
+ if (strncmp(program_lines[i], "bzz CAPTURE", 11) == 0) {
1491
+ capture_start_line = i;
1492
+ } else if (strncmp(program_lines[i], "bzz FIN_ESSAI", 11) == 0) {
1493
+ fin_essai_line = i;
1494
+ break;
1495
+ }
1496
+ }
1497
+
1498
+ if (capture_start_line == -1 || fin_essai_line == -1) {
1499
+ printf("Erreur: Structure ESSAI...CAPTURE...FIN_ESSAI incomplรจte!\n");
1500
+ return 0;
1501
+ }
1502
+
1503
+ // Exรฉcuter le bloc ESSAI
1504
+ int error_occurred = 0;
1505
+ for (int i = essai_start_line + 1; i < capture_start_line; i++) {
1506
+ int result = interpret_line(program_lines[i]);
1507
+ if (result == -1) break;
1508
+ if (result != 0) {
1509
+ error_occurred = 1;
1510
+ break;
1511
+ }
1512
+ }
1513
+
1514
+ // Si une erreur s'est produite, exรฉcuter le bloc CAPTURE
1515
+ if (error_occurred) {
1516
+ printf("Erreur dรฉtectรฉe! Exรฉcution du bloc CAPTURE...\n");
1517
+ for (int i = capture_start_line + 1; i < fin_essai_line; i++) {
1518
+ int result = interpret_line(program_lines[i]);
1519
+ if (result == -1) break;
1520
+ if (result != 0) break;
1521
+ }
1522
+ }
1523
+
1524
+ // Sauter jusqu'ร  la fin du bloc ESSAI
1525
+ current_line = fin_essai_line;
1526
+ return 1;
1527
+ }
1528
+
1529
+ // bzz RUCHE LIRE NOMBRE : ma_variable_nombre
1530
+ else if (strncmp(line, "bzz RUCHE LIRE NOMBRE", 21) == 0) {
1531
+ char* var_name = trim(line + 21);
1532
+ printf("Entrez un nombre pour %s: ", var_name);
1533
+ char input[MAX_VAR_VALUE];
1534
+ if (fgets(input, sizeof(input), stdin)) {
1535
+ input[strcspn(input, "\n")] = 0;
1536
+ // Vรฉrifier si l'entrรฉe est un nombre
1537
+ char* endptr;
1538
+ double num = strtod(input, &endptr);
1539
+ if (*endptr == '\0') {
1540
+ set_variable(var_name, input);
1541
+ printf("Nombre %.2f stockรฉ dans la variable '%s'\n", num, var_name);
1542
+ } else {
1543
+ printf("Erreur: Entrรฉe non valide. Veuillez entrer un nombre.\n");
1544
+ }
1545
+ }
1546
+ }
1547
+
1548
+ // bzz RUCHE LIRE OUI_NON : ma_variable_booleenne
1549
+ else if (strncmp(line, "bzz RUCHE LIRE OUI_NON", 22) == 0) {
1550
+ char* var_name = trim(line + 22);
1551
+ printf("Entrez OUI ou NON pour %s: ", var_name);
1552
+ char input[MAX_VAR_VALUE];
1553
+ if (fgets(input, sizeof(input), stdin)) {
1554
+ input[strcspn(input, "\n")] = 0;
1555
+ for (int i = 0; input[i]; i++) {
1556
+ input[i] = toupper(input[i]);
1557
+ }
1558
+ if (strcmp(input, "OUI") == 0) {
1559
+ set_variable(var_name, "true");
1560
+ printf("Valeur 'true' stockรฉe dans la variable '%s'\n", var_name);
1561
+ } else if (strcmp(input, "NON") == 0) {
1562
+ set_variable(var_name, "false");
1563
+ printf("Valeur 'false' stockรฉe dans la variable '%s'\n", var_name);
1564
+ } else {
1565
+ printf("Erreur: Entrรฉe non valide. Veuillez entrer OUI ou NON.\n");
1566
+ }
1567
+ }
1568
+ }
1569
+
1570
+ // bzz RUCHE LIRE CARACTERE : mon_caractere
1571
+ else if (strncmp(line, "bzz RUCHE LIRE CARACTERE", 24) == 0) {
1572
+ char* var_name = trim(line + 24);
1573
+ printf("Entrez un caractรจre pour %s: ", var_name);
1574
+ int ch = getch(); // Lire un caractรจre sans echo
1575
+ printf("\n");
1576
+ char input[2];
1577
+ input[0] = (char)ch;
1578
+ input[1] = '\0';
1579
+ set_variable(var_name, input);
1580
+ }
1581
+
1582
+ // bzz TEMPS HEURE_ACTUELLE : heure
1583
+ else if (strncmp(line, "bzz TEMPS HEURE_ACTUELLE", 23) == 0) {
1584
+ char* var_name = trim(line + 23);
1585
+ time_t now = time(NULL);
1586
+ struct tm *tm_struct = localtime(&now);
1587
+ char time_str[20];
1588
+ strftime(time_str, sizeof(time_str), "%H:%M:%S", tm_struct);
1589
+ set_variable(var_name, time_str);
1590
+ printf("Heure actuelle stockรฉe dans la variable '%s'\n", var_name);
1591
+ }
1592
+
1593
+ // bzz TEMPS DATE_ACTUELLE : date
1594
+ else if (strncmp(line, "bzz TEMPS DATE_ACTUELLE", 23) == 0) {
1595
+ char* var_name = trim(line + 23);
1596
+ time_t now = time(NULL);
1597
+ struct tm *tm_struct = localtime(&now);
1598
+ char date_str[20];
1599
+ strftime(date_str, sizeof(date_str), "%Y-%m-%d", tm_struct);
1600
+ set_variable(var_name, date_str);
1601
+ printf("Date actuelle stockรฉe dans la variable '%s'\n", var_name);
1602
+ }
1603
+
1604
+ // bzz CURSEUR X Y
1605
+ else if (strncmp(line, "bzz CURSEUR", 11) == 0) {
1606
+ char* rest = trim(line + 11);
1607
+ char* x_str = strtok(rest, " ");
1608
+ char* y_str = strtok(NULL, " ");
1609
+
1610
+ if (x_str && y_str) {
1611
+ int x = atoi(x_str);
1612
+ int y = atoi(y_str);
1613
+ printf("\033[%d;%dH", y, x); // ANSI code pour positionner le curseur
1614
+ } else {
1615
+ printf("Format: bzz CURSEUR X Y\n");
1616
+ }
1617
+ }
1618
+
1619
+ // bzz CONSOLE EFFACER
1620
+ else if (strcmp(line, "bzz CONSOLE EFFACER") == 0) {
1621
+ printf("\033[2J"); // ANSI code pour effacer l'รฉcran
1622
+ printf("\033[H"); // ANSI code pour repositionner le curseur en haut ร  gauche
1623
+ }
1624
+
1625
+ // bzz HISTOIRE INIT <nom_histoire>
1626
+ else if (strncmp(line, "bzz HISTOIRE INIT", 17) == 0) {
1627
+ char* story_name = trim(line + 17);
1628
+ Story* story = NULL;
1629
+ for (int i = 0; i < story_count; i++) {
1630
+ if (strcmp(stories[i].name, story_name) == 0) {
1631
+ story = &stories[i];
1632
+ break;
1633
+ }
1634
+ }
1635
+ if (!story) {
1636
+ if (story_count < MAX_STORIES) {
1637
+ story = &stories[story_count++];
1638
+ strcpy(story->name, story_name);
1639
+ story->scene_count = 0;
1640
+ story->current_scene = 0;
1641
+ printf("Histoire '%s' initialisรฉe.\n", story_name);
1642
+ } else {
1643
+ printf("Erreur: Trop d'histoires!\n");
1644
+ }
1645
+ } else {
1646
+ printf("Erreur: Une histoire avec ce nom existe dรฉjร .\n");
1647
+ }
1648
+ }
1649
+
1650
+ // bzz HISTOIRE SCENE <nom_histoire> <question>
1651
+ else if (strncmp(line, "bzz HISTOIRE SCENE", 18) == 0) {
1652
+ char* rest = line + 18;
1653
+ char* story_name = strtok(rest, " ");
1654
+ char* question = strtok(NULL, "");
1655
+
1656
+ if (story_name && question) {
1657
+ Story* story = NULL;
1658
+ for (int i = 0; i < story_count; i++) {
1659
+ if (strcmp(stories[i].name, story_name) == 0) {
1660
+ story = &stories[i];
1661
+ break;
1662
+ }
1663
+ }
1664
+ if (!story) {
1665
+ printf("Erreur: Histoire non trouvรฉe!\n");
1666
+ return 0;
1667
+ }
1668
+
1669
+ if (story->scene_count < 50) {
1670
+ StoryScene* scene = &story->scenes[story->scene_count++];
1671
+ strcpy(scene->question, remove_quotes(trim(question)));
1672
+ scene->choice_count = 0;
1673
+ printf("Scรจne ajoutรฉe ร  l'histoire '%s': %s\n", story_name, remove_quotes(trim(question)));
1674
+ } else {
1675
+ printf("Erreur: Trop de scรจnes dans l'histoire!\n");
1676
+ }
1677
+ } else {
1678
+ printf("Format: bzz HISTOIRE SCENE <nom_histoire> <question>\n");
1679
+ }
1680
+ }
1681
+
1682
+ // bzz HISTOIRE CHOIX <nom_histoire> <numero_scene> <choix> <prochaine_scene>
1683
+ else if (strncmp(line, "bzz HISTOIRE CHOIX", 19) == 0) {
1684
+ char* rest = line + 19;
1685
+ char* story_name = strtok(rest, " ");
1686
+ char* scene_num_str = strtok(NULL, " ");
1687
+ char* choice = strtok(NULL, " ");
1688
+ char* next_scene_str = strtok(NULL, "");
1689
+
1690
+ if (story_name && scene_num_str && choice && next_scene_str) {
1691
+ Story* story = NULL;
1692
+ for (int i = 0; i < story_count; i++) {
1693
+ if (strcmp(stories[i].name, story_name) == 0) {
1694
+ story = &stories[i];
1695
+ break;
1696
+ }
1697
+ }
1698
+ if (!story) {
1699
+ printf("Erreur: Histoire non trouvรฉe!\n");
1700
+ return 0;
1701
+ }
1702
+
1703
+ int scene_num = atoi(scene_num_str);
1704
+ int next_scene = atoi(next_scene_str);
1705
+
1706
+ if (scene_num >= 0 && scene_num < story->scene_count) {
1707
+ StoryScene* scene = &story->scenes[scene_num];
1708
+ if (scene->choice_count < MAX_STORY_CHOICES) {
1709
+ strcpy(scene->choices[scene->choice_count], remove_quotes(trim(choice)));
1710
+ scene->next_scenes[scene->choice_count] = next_scene;
1711
+ scene->choice_count++;
1712
+ printf("Choix ajoutรฉ ร  la scรจne %d de l'histoire '%s': %s -> %d\n", scene_num, story_name, remove_quotes(trim(choice)), next_scene);
1713
+ } else {
1714
+ printf("Erreur: Trop de choix pour cette scรจne!\n");
1715
+ }
1716
+ } else {
1717
+ printf("Erreur: Numรฉro de scรจne invalide!\n");
1718
+ }
1719
+ } else {
1720
+ printf("Format: bzz HISTOIRE CHOIX <nom_histoire> <numero_scene> <choix> <prochaine_scene>\n");
1721
+ }
1722
+ }
1723
+
1724
+ // bzz HISTOIRE JOUER <nom_histoire>
1725
+ else if (strncmp(line, "bzz HISTOIRE JOUER", 18) == 0) {
1726
+ char* story_name = trim(line + 18);
1727
+ Story* story = NULL;
1728
+ for (int i = 0; i < story_count; i++) {
1729
+ if (strcmp(stories[i].name, story_name) == 0) {
1730
+ story = &stories[i];
1731
+ break;
1732
+ }
1733
+ }
1734
+ if (!story) {
1735
+ printf("Erreur: Histoire non trouvรฉe!\n");
1736
+ return 0;
1737
+ }
1738
+
1739
+ story->current_scene = 0;
1740
+ while (story->current_scene >= 0 && story->current_scene < story->scene_count) {
1741
+ StoryScene* scene = &story->scenes[story->current_scene];
1742
+ printf("%s\n", scene->question);
1743
+
1744
+ for (int i = 0; i < scene->choice_count; i++) {
1745
+ printf("%d. %s\n", i + 1, scene->choices[i]);
1746
+ }
1747
+
1748
+ if (scene->choice_count > 0) {
1749
+ printf("Choisissez une option (1-%d): ", scene->choice_count);
1750
+ char input[10];
1751
+ if (fgets(input, sizeof(input), stdin)) {
1752
+ int choice = atoi(input);
1753
+ if (choice >= 1 && choice <= scene->choice_count) {
1754
+ story->current_scene = scene->next_scenes[choice - 1];
1755
+ } else {
1756
+ printf("Choix invalide!\n");
1757
+ break;
1758
+ }
1759
+ }
1760
+ } else {
1761
+ break; // Fin de l'histoire
1762
+ }
1763
+ }
1764
+ printf("Fin de l'histoire '%s'!\n", story_name);
1765
+ }
1766
+
1767
+ // bzz LIRE variable
1768
+ else if (strncmp(line, "bzz LIRE", 8) == 0) {
1769
+ char* var_name = trim(line + 8);
1770
+ printf("Entrez une valeur pour %s: ", var_name);
1771
+ char input[MAX_VAR_VALUE];
1772
+ if (fgets(input, sizeof(input), stdin)) {
1773
+ input[strcspn(input, "\n")] = 0;
1774
+ set_variable(var_name, input);
1775
+ printf("Valeur '%s' stockรฉe dans la variable '%s'\n", input, var_name);
1776
+ }
1777
+ }
1778
+
1779
+ // bzz LISTE AFFICHER <liste>
1780
+ else if (strncmp(line, "bzz LISTE AFFICHER", 18) == 0) {
1781
+ char* list_name = trim(line + 18);
1782
+ List* list = NULL;
1783
+ for (int i = 0; i < list_count; i++) {
1784
+ if (strcmp(lists[i].name, list_name) == 0) {
1785
+ list = &lists[i];
1786
+ break;
1787
+ }
1788
+ }
1789
+ if (!list) {
1790
+ printf("Erreur: Liste non trouvรฉe!\n");
1791
+ return 0;
1792
+ }
1793
+ printf("Liste '%s' (%d รฉlรฉments): [", list_name, list->size);
1794
+ for (int i = 0; i < list->size; i++) {
1795
+ printf("'%s'", list->elements[i]);
1796
+ if (i < list->size - 1) printf(", ");
1797
+ }
1798
+ printf("]\n");
1799
+ }
1800
+
1801
+ // bzz NECTAR AFFICHER <pot>
1802
+ else if (strncmp(line, "bzz NECTAR AFFICHER", 19) == 0) {
1803
+ char* dict_name = trim(line + 19);
1804
+ Dictionary* dict = NULL;
1805
+ for (int i = 0; i < dict_count; i++) {
1806
+ if (strcmp(dictionaries[i].name, dict_name) == 0) {
1807
+ dict = &dictionaries[i];
1808
+ break;
1809
+ }
1810
+ }
1811
+ if (!dict) {
1812
+ printf("Erreur: Dictionnaire non trouvรฉ!\n");
1813
+ return 0;
1814
+ }
1815
+ printf("Dictionnaire '%s' (%d entrรฉes):\n", dict_name, dict->size);
1816
+ for (int i = 0; i < dict->size; i++) {
1817
+ printf(" '%s' -> '%s'\n", dict->entries[i].key, dict->entries[i].value);
1818
+ }
1819
+ }
1820
+
1821
+ // bzz BANNIERE <texte>
1822
+ else if (strncmp(line, "bzz BANNIERE", 12) == 0) {
1823
+ char* text = trim(line + 12);
1824
+ text = remove_quotes(text);
1825
+ int len = strlen(text);
1826
+ printf("โ•”");
1827
+ for (int i = 0; i < len + 4; i++) printf("โ•");
1828
+ printf("โ•—\n");
1829
+ printf("โ•‘ %s โ•‘\n", text);
1830
+ printf("โ•š");
1831
+ for (int i = 0; i < len + 4; i++) printf("โ•");
1832
+ printf("โ•\n");
1833
+ }
1834
+
1835
+ // bzz TITRE <texte>
1836
+ else if (strncmp(line, "bzz TITRE", 9) == 0) {
1837
+ char* text = trim(line + 9);
1838
+ text = remove_quotes(text);
1839
+ printf("\n%s\n", text);
1840
+ for (int i = 0; i < (int)strlen(text); i++) printf("=");
1841
+ printf("\n");
1842
+ }
1843
+
1844
+ // bzz CADRE <texte>
1845
+ else if (strncmp(line, "bzz CADRE", 9) == 0) {
1846
+ char* text = trim(line + 9);
1847
+ text = remove_quotes(text);
1848
+ int len = strlen(text);
1849
+ printf("โ”Œ");
1850
+ for (int i = 0; i < len + 2; i++) printf("โ”€");
1851
+ printf("โ”\n");
1852
+ printf("โ”‚ %s โ”‚\n", text);
1853
+ printf("โ””");
1854
+ for (int i = 0; i < len + 2; i++) printf("โ”€");
1855
+ printf("โ”˜\n");
1856
+ }
1857
+
1858
+ // bzz ENCADRER <texte>
1859
+ else if (strncmp(line, "bzz ENCADRER", 12) == 0) {
1860
+ char* text = trim(line + 12);
1861
+ text = remove_quotes(text);
1862
+ int len = strlen(text);
1863
+ for (int i = 0; i < len + 4; i++) printf("*");
1864
+ printf("\n* %s *\n", text);
1865
+ for (int i = 0; i < len + 4; i++) printf("*");
1866
+ printf("\n");
1867
+ }
1868
+
1869
+ // bzz SEPARATEUR
1870
+ else if (strcmp(line, "bzz SEPARATEUR") == 0) {
1871
+ for (int i = 0; i < 50; i++) printf("-");
1872
+ printf("\n");
1873
+ }
1874
+
1875
+ // bzz BARRE_PROGRESSION <current> <total> <width>
1876
+ else if (strncmp(line, "bzz BARRE_PROGRESSION", 21) == 0) {
1877
+ char* rest = trim(line + 21);
1878
+ char* current_str = strtok(rest, " ");
1879
+ char* total_str = strtok(NULL, " ");
1880
+ char* width_str = strtok(NULL, " ");
1881
+ if (current_str && total_str && width_str) {
1882
+ int current = atoi(current_str);
1883
+ int total = atoi(total_str);
1884
+ int width = atoi(width_str);
1885
+ int filled = (current * width) / total;
1886
+ printf("[");
1887
+ for (int i = 0; i < width; i++) {
1888
+ if (i < filled) printf("โ–ˆ");
1889
+ else printf("โ–‘");
1890
+ }
1891
+ printf("] %d/%d (%d%%)\n", current, total, (current * 100) / total);
1892
+ }
1893
+ }
1894
+
1895
+ // bzz FLASH <texte>
1896
+ else if (strncmp(line, "bzz FLASH", 9) == 0) {
1897
+ char* text = trim(line + 9);
1898
+ text = remove_quotes(text);
1899
+ printf("\033[5m%s\033[0m\n", text); // ANSI blink
1900
+ }
1901
+
1902
+ // bzz GRADIENT <texte>
1903
+ else if (strncmp(line, "bzz GRADIENT", 12) == 0) {
1904
+ char* text = trim(line + 12);
1905
+ text = remove_quotes(text);
1906
+ int colors[] = {31, 32, 33, 34, 35, 36}; // Rouge, vert, jaune, bleu, magenta, cyan
1907
+ for (int i = 0; text[i]; i++) {
1908
+ printf("\033[%dm%c", colors[i % 6], text[i]);
1909
+ }
1910
+ printf("\033[0m\n");
1911
+ }
1912
+
1913
+ // Scรจnes thรฉmatiques
1914
+ else if (strcmp(line, "bzz JARDIN") == 0) {
1915
+ printf("๐ŸŒธ๐ŸŒป๐ŸŒบ Jardin fleuri avec des papillons ๐Ÿฆ‹๐ŸŒท๐ŸŒน\n");
1916
+ printf(" ๐ŸŒฑ ๐ŸŒผ ๐ŸŒพ ๐ŸŒฟ ๐ŸŒธ\n");
1917
+ printf("๐Ÿ› ๐ŸŒป ๐ŸŒบ ๐Ÿฆ‹\n");
1918
+ }
1919
+
1920
+ else if (strcmp(line, "bzz OCEAN") == 0) {
1921
+ printf("๐ŸŒŠ๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๐ŸŒŠ\n");
1922
+ printf(" ๐ŸŸ ๐Ÿ  ๐Ÿฆˆ ๐Ÿ™ ๐Ÿฆ‘\n");
1923
+ printf("๐ŸŒŠ๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๏ฝž๐ŸŒŠ\n");
1924
+ }
1925
+
1926
+ else if (strcmp(line, "bzz FORET") == 0) {
1927
+ printf("๐ŸŒฒ๐ŸŒณ๐ŸŒฒ๐Ÿฆ‰๐ŸŒฒ๐ŸฆŒ๐ŸŒณ๐Ÿฟ๏ธ๐ŸŒฒ๐ŸŒณ\n");
1928
+ printf(" ๐Ÿ„๐Ÿฆ” ๐Ÿป ๐Ÿฆ ๐ŸฆŠ ๐Ÿ‚\n");
1929
+ printf("๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ๐ŸŒฟ\n");
1930
+ }
1931
+
1932
+ else if (strcmp(line, "bzz CONSTELLATION") == 0) {
1933
+ printf("โœจ ยท โ˜… ยท ยท โœจ ยท โ˜… ยท โœจ\n");
1934
+ printf(" ยท โ˜… โœจ ยท โ˜… ยท \n");
1935
+ printf("โ˜… ยท โœจ ยท ยท โ˜… ยท โœจ ยท\n");
1936
+ }
1937
+
1938
+ else if (strcmp(line, "bzz GALAXIE") == 0) {
1939
+ printf(" โœจ ยท โ˜… ยท โœจ ๐ŸŒŒ โ˜… ยท โœจ ยท\n");
1940
+ printf(" โ˜… ยท โœจ ยท ๐Ÿช ยท โ˜… ยท โœจ ยท โ˜…\n");
1941
+ printf("โœจ ยท โ˜… ยท โœจ ยท โ˜… ยท โœจ ยท โ˜… ยท\n");
1942
+ }
1943
+
1944
+ else if (strcmp(line, "bzz CHATEAU") == 0) {
1945
+ printf(" ๐Ÿฐ \n");
1946
+ printf(" ๐Ÿฏ ๐Ÿ‘‘ ๐Ÿฏ \n");
1947
+ printf("๐Ÿ—ก๏ธ โš”๏ธ ๐Ÿ›ก๏ธ โš”๏ธ ๐Ÿ—ก๏ธ\n");
1948
+ }
1949
+
1950
+ else if (strcmp(line, "bzz LABORATOIRE") == 0) {
1951
+ printf("๐Ÿงชโš—๏ธ๐Ÿ”ฌ๐Ÿงซ๐Ÿ’Š\n");
1952
+ printf("โš›๏ธ ๐Ÿงฌ ๐Ÿ”ญ ๐ŸŒก๏ธ ๐Ÿ”\n");
1953
+ printf("๐Ÿฅฝ ๐Ÿงช โš—๏ธ ๐Ÿ”ฌ ๐Ÿงซ\n");
1954
+ }
1955
+
1956
+ else if (strcmp(line, "bzz VAISSEAU") == 0) {
1957
+ printf(" ๐Ÿš€ โœจ\n");
1958
+ printf("๐Ÿ›ธ ๐Ÿ‘ฝ ๐Ÿ›ฐ๏ธ ๐Ÿš€\n");
1959
+ printf(" โœจ ๐ŸŒŒ โญ\n");
1960
+ }
1961
+
1962
+ else if (strcmp(line, "bzz MONTAGNE") == 0) {
1963
+ printf(" ๐Ÿ”๏ธ โ›ฐ๏ธ ๐Ÿ—ป\n");
1964
+ printf(" ๐ŸŒฒโ›ฐ๏ธ๐ŸŒฒ ๐Ÿ”๏ธ ๐ŸŒฒโ›ฐ๏ธ๐ŸŒฒ\n");
1965
+ printf("๐ŸŒฟ๐ŸŒฒ๐ŸŒฟ๐ŸŒฒ๐ŸŒฟ๐ŸŒฒ๐ŸŒฟ๐ŸŒฒ๐ŸŒฟ\n");
1966
+ }
1967
+
1968
+ else if (strcmp(line, "bzz CITE_FUTUR") == 0) {
1969
+ printf("๐Ÿข๐ŸŒ†๐Ÿ—๏ธ๐Ÿ™๏ธ๐ŸŒƒ\n");
1970
+ printf("๐Ÿš—๐Ÿš•๐Ÿš™๐ŸšŒ๐ŸšŽ\n");
1971
+ printf("๐Ÿ›ฃ๏ธ๐Ÿ›ฃ๏ธ๐Ÿ›ฃ๏ธ๐Ÿ›ฃ๏ธ๐Ÿ›ฃ๏ธ\n");
1972
+ }
1973
+
1974
+ else if (strcmp(line, "bzz PIRATES") == 0) {
1975
+ printf("๐Ÿดโ€โ˜ ๏ธโš”๏ธ๐Ÿ’ฐ๐Ÿ—บ๏ธ๐Ÿ‘‘\n");
1976
+ printf("๐Ÿฆœ โ›ต ๐Ÿดโ€โ˜ ๏ธ ๐Ÿ๏ธ ๐Ÿ’Ž\n");
1977
+ printf("โš“ ๐Ÿ—ก๏ธ ๐Ÿ’ฐ โš”๏ธ ๐Ÿฆœ\n");
1978
+ }
1979
+
1980
+ else if (strcmp(line, "bzz MAGIE") == 0) {
1981
+ printf("โœจ๐Ÿ”ฎโญ๐ŸŒŸ๐Ÿ’ซ\n");
1982
+ printf("๐Ÿช„ โœจ ๐Ÿ”ฎ ๐ŸŒ™ โญ\n");
1983
+ printf("๐Ÿ’ซ ๐ŸŒŸ โœจ ๐Ÿช„ ๐Ÿ”ฎ\n");
1984
+ }
1985
+
1986
+ else if (strcmp(line, "bzz FESTIVAL") == 0) {
1987
+ printf("๐ŸŽŠ๐ŸŽ‰๐ŸŽˆ๐ŸŽ†๐ŸŽ‡\n");
1988
+ printf("๐ŸŽต ๐ŸŽถ ๐ŸŽค ๐ŸŽธ ๐Ÿฅ\n");
1989
+ printf("๐ŸŽช ๐ŸŽ  ๐ŸŽก ๐ŸŽข ๐ŸŽญ\n");
1990
+ }
1991
+
1992
+ // bzz ANIMATION <type>
1993
+ else if (strncmp(line, "bzz ANIMATION", 13) == 0) {
1994
+ char* type = trim(line + 13);
1995
+ type = remove_quotes(type);
1996
+ if (strcmp(type, "pluie") == 0) {
1997
+ printf("๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง\n");
1998
+ printf(" ๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง\n");
1999
+ printf("๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง ๐Ÿ’ง\n");
2000
+ } else if (strcmp(type, "feu") == 0) {
2001
+ printf("๐Ÿ”ฅ ๐Ÿ”ฅ๐Ÿ”ฅ ๐Ÿ”ฅ ๐Ÿ”ฅ๐Ÿ”ฅ\n");
2002
+ printf(" ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ \n");
2003
+ printf("๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ\n");
2004
+ }
2005
+ }
2006
+
2007
+ // bzz SON <type>
2008
+ else if (strncmp(line, "bzz SON", 7) == 0) {
2009
+ char* type = trim(line + 7);
2010
+ type = remove_quotes(type);
2011
+ if (strcmp(type, "explosion") == 0) {
2012
+ printf("๐Ÿ’ฅ BOOOOM! ๐Ÿ’ฅ\n");
2013
+ } else if (strcmp(type, "applaudissement") == 0) {
2014
+ printf("๐Ÿ‘ CLAP CLAP CLAP! ๐Ÿ‘\n");
2015
+ } else if (strcmp(type, "vent") == 0) {
2016
+ printf("๐Ÿ’จ Whoooosh... ๐Ÿ’จ\n");
2017
+ }
2018
+ }
2019
+
2020
+ // bzz TEMPS
2021
+ else if (strcmp(line, "bzz TEMPS") == 0) {
2022
+ time_t now = time(NULL);
2023
+ char* time_str = ctime(&now);
2024
+ time_str[strlen(time_str) - 1] = '\0'; // Enlever le \n
2025
+ printf("Temps actuel: %s\n", time_str);
2026
+ }
2027
+
2028
+ // bzz PACKAGE langage -> fichier
2029
+ else if (strncmp(line, "bzz PACKAGE", 11) == 0) {
2030
+ char* rest = line + 11;
2031
+ char* arrow = strstr(rest, "->");
2032
+ if (arrow) {
2033
+ *arrow = '\0';
2034
+ char* language = trim(rest);
2035
+ char* file_path = trim(arrow + 2);
2036
+ file_path = remove_quotes(file_path);
2037
+
2038
+ if (load_package(language, file_path)) {
2039
+ // Si c'est un package BzzBee, scanner les fonctions
2040
+ if (strcmp(language, "bzz") == 0) {
2041
+ scan_bzz_functions(file_path);
2042
+ }
2043
+ }
2044
+ } else {
2045
+ printf("โŒ Format incorrect! Utilisez: bzz PACKAGE langage -> fichier\n");
2046
+ printf("๐Ÿ“ Exemple: bzz PACKAGE js -> math_package.js\n");
2047
+ }
2048
+ }
2049
+
2050
+ // bzz PACKAGES (lister les packages chargรฉs)
2051
+ else if (strcmp(line, "bzz PACKAGES") == 0) {
2052
+ if (package_count == 0) {
2053
+ printf("๐Ÿ“ฆ Aucun package chargรฉ.\n");
2054
+ printf("๐Ÿ’ก Utilisez 'bzz PACKAGE langage -> fichier' pour charger un package.\n");
2055
+ } else {
2056
+ printf("๐Ÿ“ฆ Packages chargรฉs (%d/%d):\n", package_count, MAX_PACKAGES);
2057
+ for (int i = 0; i < package_count; i++) {
2058
+ Package* pkg = &packages[i];
2059
+ printf(" %d. %s (%s) - %s\n",
2060
+ i + 1,
2061
+ pkg->file_path,
2062
+ pkg->language,
2063
+ pkg->is_loaded ? "โœ… Actif" : "โŒ Inactif");
2064
+ }
2065
+ printf("๐Ÿ’ก Utilisez 'pollen -> fonction paramรจtres : miel' pour appeler une fonction.\n");
2066
+ }
2067
+ }
2068
+
2069
+ // pollen -> paramรจtres : miel (appel de fonction package)
2070
+ else if (strstr(line, "pollen ->") && strstr(line, ": miel")) {
2071
+ execute_package_function(line);
2072
+ }
2073
+
2074
+ // bzz EFFACE
2075
+ else if (strcmp(line, "bzz EFFACE") == 0) {
2076
+ int clear_result = system("clear");
2077
+ (void)clear_result; // Ignorer la valeur de retour
2078
+ printf("๐Ÿ ร‰cran effacรฉ! Bzzzz! ๐Ÿ\n");
2079
+ }
2080
+
2081
+ // bzz BONJOUR
2082
+ else if (strcmp(line, "bzz BONJOUR") == 0) {
2083
+ printf("Bzzzz! Bonjour de la ruche! ๐Ÿ\n");
2084
+ }
2085
+
2086
+ // bzz AU REVOIR
2087
+ else if (strcmp(line, "bzz AU REVOIR") == 0) {
2088
+ printf("Bzzzz! Au revoir de la ruche! ๐Ÿ๐Ÿฏ\n");
2089
+ return -1;
2090
+ }
2091
+
2092
+ else if (!skip_until_end) {
2093
+ printf("Commande non reconnue: %s\n", line);
2094
+ }
2095
+
2096
+ return 0;
2097
+ }
2098
+
2099
+ int main(int argc, char* argv[]) {
2100
+ srand(time(NULL)); // Initialiser le gรฉnรฉrateur alรฉatoire
2101
+
2102
+ printf("๐Ÿ BzzBee Interpreter v4.0 - Le langage des abeilles avec packages et histoires interactives! ๐Ÿ\n");
2103
+ printf("Nouvelles fonctionnalitรฉs: Structures de donnรฉes avancรฉes, gestion de fichiers, histoires interactives et plus!\n");
2104
+ printf("Langages supportรฉs: node.js, Python, Julia, Ruby, C, BzzBee\n");
2105
+ printf("Utilisez 'bzzbee run fichier.bzz' pour exรฉcuter un fichier\n");
2106
+ printf("Crรฉez des packages avec: bzz PACKAGE langage -> fichier\n");
2107
+ printf("Utilisez des fonctions avec: pollen -> paramรจtres : miel\n\n");
2108
+
2109
+ if (argc == 3 && strcmp(argv[1], "run") == 0) {
2110
+ FILE* file = fopen(argv[2], "r");
2111
+ if (!file) {
2112
+ printf("โŒ Erreur: Impossible d'ouvrir le fichier %s\n", argv[2]);
2113
+ return 1;
2114
+ }
2115
+
2116
+ char line[MAX_LINE_LENGTH];
2117
+ total_lines = 0;
2118
+ while (fgets(line, sizeof(line), file) && total_lines < 1000) {
2119
+ line[strcspn(line, "\n")] = 0;
2120
+ strcpy(program_lines[total_lines], line);
2121
+ total_lines++;
2122
+ }
2123
+ fclose(file);
2124
+
2125
+ current_line = 0;
2126
+ while (current_line < total_lines) {
2127
+ if (!skip_until_end || strncmp(program_lines[current_line], "bzz FIN", 7) == 0 ||
2128
+ strncmp(program_lines[current_line], "bzz SINON", 9) == 0) {
2129
+ int result = interpret_line(program_lines[current_line]);
2130
+ if (result == -1) break;
2131
+ if (result == 1) continue;
2132
+ }
2133
+ current_line++;
2134
+ }
2135
+
2136
+ } else {
2137
+ char line[MAX_LINE_LENGTH];
2138
+ printf("bzz> ");
2139
+ while (fgets(line, sizeof(line), stdin)) {
2140
+ line[strcspn(line, "\n")] = 0;
2141
+
2142
+ if (strcmp(line, "exit") == 0 || strcmp(line, "quit") == 0) {
2143
+ printf("Bzzzz! Au revoir! ๐Ÿ\n");
2144
+ break;
2145
+ }
2146
+
2147
+ if (interpret_line(line) == -1) break;
2148
+ printf("bzz> ");
2149
+ }
2150
+ }
2151
+
2152
+ return 0;
2153
+ }