diff --git a/fact.txt b/fact.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7d3a2a69031a26b681d435b07a96756c6a58b80 --- /dev/null +++ b/fact.txt @@ -0,0 +1,6 @@ +15 5 +&>=1-=v v *_;.v + ^ _;>$=^ [ + @,*< 5 + 2 = + \ \ No newline at end of file diff --git a/hellodiag.txt b/hellodiag.txt new file mode 100644 index 0000000000000000000000000000000000000000..f20a2c0544a885e0cf3278d5ea7e2245aae7c438 --- /dev/null +++ b/hellodiag.txt @@ -0,0 +1,13 @@ +26 12 +64+[ + " @_,4#2!=;6' + ! 6 + d " + l H + r e + o l + W l + o + " , + 0 " + / \ No newline at end of file diff --git a/helloworld.txt b/helloworld.txt new file mode 100644 index 0000000000000000000000000000000000000000..46d9a19bcdcf8e9fff1d5d43fb8edd410c0b9d5e --- /dev/null +++ b/helloworld.txt @@ -0,0 +1,2 @@ +26 1 +64+"!dlroW ,olleH">=2#2,_@ \ No newline at end of file diff --git a/interpreteur.c b/interpreteur.c index 061f6c6cea8a34776f8a9a0bed8c1461aed472da..99a76c9823fc4ee3fd312766fd10d45ce15bd923 100644 --- a/interpreteur.c +++ b/interpreteur.c @@ -17,6 +17,7 @@ void interpreteur(char **matrix, int height, int width) { time_t t; int string_mode = 0; int bridge = 0; + char buf[256]; char *endptr; /* initialise le module random */ @@ -25,24 +26,33 @@ void interpreteur(char **matrix, int height, int width) { cur.x = 0; cur.y = 0; cur.current_char = matrix[0][0]; + cur.current_dir = E; while (cur.current_char != '@') { + printf("=-=-=-=-=-=-=\n"); + printf("current char: %i = %c\n", cur.current_char, cur.current_char); /* Action en fonction du caractère lu */ - switch (cur.current_char) + + /* Si on est sur un pont, on ne lit pas l'instruction et on avance sur le pont */ + if (bridge) { - /* Si on est sur un pont, on ne lit pas l'instruction et on avance sur le pont */ - if (bridge) - { - bridge--; - break; - } + bridge--; + + } - /* Si on est en mode chaine de caractere on empile ce qu'on lit */ - if (string_mode) { + /* Si on est en mode chaine de caractere on empile ce qu'on lit */ + else if (string_mode == 1) { + if (cur.current_char == '"') + string_mode = 1 - string_mode; + else push(cur.current_char, &pile); - break; - } + + } + else { + switch (cur.current_char) + { + case '+': a = pop(&pile); @@ -167,8 +177,14 @@ void interpreteur(char **matrix, int height, int width) { break; case '$': - a = pop(&pile); - b = pop(&pile); + if (is_empty(pile)) + a = 0; + else + a = pop(&pile); + if (is_empty(pile)) + b = 0; + else + b = pop(&pile); push(a, &pile); push(b, &pile); break; @@ -210,16 +226,16 @@ void interpreteur(char **matrix, int height, int width) { break; case '&': - char buf[256]; printf("Veuillez entrer un entier\n"); fgets(buf, 256, stdin); - a = strtol(buf, NULL, 10); + a = strtol(buf, &endptr, 10); while (buf == endptr) { printf("Erreur, veuillez saisir un nombre\n"); fgets(buf, 256, stdin); - a = strtol(buf, endptr, 10); + a = strtol(buf, &endptr, 10); } + push(a, &pile); break; case '~': @@ -244,6 +260,7 @@ void interpreteur(char **matrix, int height, int width) { default: break; } + } /* Déplacement du curseur et lecture du prochain caractère */ switch (cur.current_dir) @@ -291,6 +308,10 @@ void interpreteur(char **matrix, int height, int width) { } cur.current_char = matrix[cur.y][cur.x]; + + print_list(pile); + //printf("string_mode: %i\n", string_mode); + //printf("bridge: %i\n", bridge); } printf("Contenu de la pile :\n"); diff --git a/lessmore.txt b/lessmore.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f6b991ab3a3318fe7534b6ac6549251484453df --- /dev/null +++ b/lessmore.txt @@ -0,0 +1,25 @@ +77 24 +vv < < + 2 + >^v v< + v1<?>3v4 + >^< ^< +> >?> ?>5^ + >v< v< + v9<?>7v6 + >v< v< + 8 + > > ^ + vv < < + 2 + >^v v< + v1<?>3v4 + >^< ^< + > >?> ?>5^ + >v< v< v ,*25 << + v9<?>7v6 ,, + >v< v< "" + 8 >< + > > ^ ""v + >*=.>0"!rebmun tupnI">=2#2,_;25*,=&=99p`|^< _0"!niw uoY">=2#2,_;25*,@ + ^ < >=99g01-*+^ \ No newline at end of file diff --git a/main.c b/main.c index e0cc210ac784f17acb3a80f3e15733fd90c45ff2..aa40014e780c869e42d99ece6a8ffc53f05bcd84 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include "list.h" #include "affichage.h" +#include "interpreteur.h" #include <stdio.h> #include <stdlib.h> @@ -63,6 +64,8 @@ int main(int argc, char const *argv[]) matrix[i][j] = c; j++; } + + interpreteur(matrix, height, width); return 0; } diff --git a/sieve.txt b/sieve.txt new file mode 100644 index 0000000000000000000000000000000000000000..88ee4cf7af4c5d279594da302e6596161f7994a4 --- /dev/null +++ b/sieve.txt @@ -0,0 +1,5 @@ +80 4 +2>=3g" "-!v$ g30 < + |!`"O"=+1_=.=03p>03g+="O"`| + @ ^ p3$" "=< +2 234567890123456789012345678901234567890123456789012345678901234567890123456789 \ No newline at end of file