Skip to content
Extraits de code Groupes Projets
Valider 77e038d6 rédigé par Anteunis Charles's avatar Anteunis Charles
Parcourir les fichiers

tests OK sur fichiers du prof

parent 67b2b204
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
15 5
&>=1-=v v *_;.v
^ _;>$=^ [
@,*< 5
2 =
\
\ No newline at end of file
26 12
64+[
" @_,4#2!=;6'
! 6
d "
l H
r e
o l
W l
o
" ,
0 "
/
\ No newline at end of file
26 1
64+"!dlroW ,olleH">=2#2,_@
\ No newline at end of file
...@@ -17,6 +17,7 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -17,6 +17,7 @@ void interpreteur(char **matrix, int height, int width) {
time_t t; time_t t;
int string_mode = 0; int string_mode = 0;
int bridge = 0; int bridge = 0;
char buf[256];
char *endptr; char *endptr;
/* initialise le module random */ /* initialise le module random */
...@@ -25,24 +26,33 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -25,24 +26,33 @@ void interpreteur(char **matrix, int height, int width) {
cur.x = 0; cur.x = 0;
cur.y = 0; cur.y = 0;
cur.current_char = matrix[0][0]; cur.current_char = matrix[0][0];
cur.current_dir = E;
while (cur.current_char != '@') { 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 */ /* 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 */ /* Si on est sur un pont, on ne lit pas l'instruction et on avance sur le pont */
if (bridge) if (bridge)
{ {
bridge--; bridge--;
break;
} }
/* Si on est en mode chaine de caractere on empile ce qu'on lit */ /* Si on est en mode chaine de caractere on empile ce qu'on lit */
if (string_mode) { else if (string_mode == 1) {
if (cur.current_char == '"')
string_mode = 1 - string_mode;
else
push(cur.current_char, &pile); push(cur.current_char, &pile);
break;
} }
else {
switch (cur.current_char)
{
case '+': case '+':
a = pop(&pile); a = pop(&pile);
...@@ -167,7 +177,13 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -167,7 +177,13 @@ void interpreteur(char **matrix, int height, int width) {
break; break;
case '$': case '$':
if (is_empty(pile))
a = 0;
else
a = pop(&pile); a = pop(&pile);
if (is_empty(pile))
b = 0;
else
b = pop(&pile); b = pop(&pile);
push(a, &pile); push(a, &pile);
push(b, &pile); push(b, &pile);
...@@ -210,16 +226,16 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -210,16 +226,16 @@ void interpreteur(char **matrix, int height, int width) {
break; break;
case '&': case '&':
char buf[256];
printf("Veuillez entrer un entier\n"); printf("Veuillez entrer un entier\n");
fgets(buf, 256, stdin); fgets(buf, 256, stdin);
a = strtol(buf, NULL, 10); a = strtol(buf, &endptr, 10);
while (buf == endptr) while (buf == endptr)
{ {
printf("Erreur, veuillez saisir un nombre\n"); printf("Erreur, veuillez saisir un nombre\n");
fgets(buf, 256, stdin); fgets(buf, 256, stdin);
a = strtol(buf, endptr, 10); a = strtol(buf, &endptr, 10);
} }
push(a, &pile);
break; break;
case '~': case '~':
...@@ -244,6 +260,7 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -244,6 +260,7 @@ void interpreteur(char **matrix, int height, int width) {
default: default:
break; break;
} }
}
/* Déplacement du curseur et lecture du prochain caractère */ /* Déplacement du curseur et lecture du prochain caractère */
switch (cur.current_dir) switch (cur.current_dir)
...@@ -291,6 +308,10 @@ void interpreteur(char **matrix, int height, int width) { ...@@ -291,6 +308,10 @@ void interpreteur(char **matrix, int height, int width) {
} }
cur.current_char = matrix[cur.y][cur.x]; 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"); printf("Contenu de la pile :\n");
......
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
#include "list.h" #include "list.h"
#include "affichage.h" #include "affichage.h"
#include "interpreteur.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -64,5 +65,7 @@ int main(int argc, char const *argv[]) ...@@ -64,5 +65,7 @@ int main(int argc, char const *argv[])
j++; j++;
} }
interpreteur(matrix, height, width);
return 0; return 0;
} }
80 4
2>=3g" "-!v$ g30 <
|!`"O"=+1_=.=03p>03g+="O"`|
@ ^ p3$" "=<
2 234567890123456789012345678901234567890123456789012345678901234567890123456789
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter