ne compile pas mais on sait jamais
This commit is contained in:
parent
32829d36a3
commit
d6ce6585f1
5 changed files with 36 additions and 16 deletions
BIN
forth
BIN
forth
Binary file not shown.
BIN
main
BIN
main
Binary file not shown.
13
main.c
13
main.c
|
@ -8,12 +8,12 @@ int main(int argc, char * argv[])
|
|||
{
|
||||
/*struct Pile P;
|
||||
Init_Pile(&P);
|
||||
Empiler(&P, 4);
|
||||
Empiler(&P, 5);
|
||||
Empiler(&P, '4');
|
||||
Empiler(&P, '5');
|
||||
struct Cell * res = Depiler(&P);
|
||||
//Supprimer(&P);
|
||||
Affichage(P.Pil);
|
||||
printf("%d \n", res->Ent);
|
||||
Affiche_Nombre(res->Ent);*/
|
||||
|
||||
Programme * P;
|
||||
P = lexer(argv[1]);
|
||||
|
@ -21,13 +21,14 @@ int main(int argc, char * argv[])
|
|||
for(int i=0; i<P->taille; i++)
|
||||
{
|
||||
printf("TOKEN : %s \n", P->tokens[i]);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*for(int i=0; i<E->Prog->taille; i++)
|
||||
{
|
||||
printf("TOKEN : %s \n", E->Prog->tokens[i]);
|
||||
}*/
|
||||
|
||||
Etat * E;
|
||||
/*Etat * E;
|
||||
E= malloc(sizeof(Etat));
|
||||
E->Donnee = malloc(sizeof(struct Pile));
|
||||
Init_Pile(E->Donnee);
|
||||
|
@ -35,5 +36,5 @@ int main(int argc, char * argv[])
|
|||
E->Prog = lexer(argv[1]);
|
||||
|
||||
|
||||
Executer(E);
|
||||
Executer(E);*/
|
||||
}
|
32
pile.c
32
pile.c
|
@ -12,7 +12,7 @@ void Init_Pile(struct Pile *new)
|
|||
//return new;
|
||||
}
|
||||
|
||||
struct Nombre Typenum(string C)
|
||||
struct Nombre Typenum(char * C)
|
||||
{
|
||||
struct Nombre k;
|
||||
//enum Numtype type;
|
||||
|
@ -35,14 +35,19 @@ struct Nombre Typenum(string C)
|
|||
k.nombr.ValReel = atof(C);
|
||||
}
|
||||
|
||||
return k;
|
||||
|
||||
}
|
||||
void Empiler(struct Pile * P, struct Nombre i)
|
||||
|
||||
void Empiler(struct Pile * P, char * nb)
|
||||
{
|
||||
struct Cell * cel= malloc(sizeof(struct Cell));
|
||||
struct Nombre i = Typenum(nb);
|
||||
|
||||
if (i.typ == Entier)
|
||||
cel->Ent.ValEntier = i;
|
||||
cel->Ent.nombr.ValEntier = i.nombr.ValEntier;
|
||||
else if (i.typ == Reel)
|
||||
cel->Ent.ValReel = i;
|
||||
cel->Ent.nombr.ValReel = i.nombr.ValReel;
|
||||
cel->Suiv = P->Pil;
|
||||
P->Pil = cel;
|
||||
P->nbElements +=1;
|
||||
|
@ -80,6 +85,19 @@ void Supprimer(struct Pile *P){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Affiche_Nombre(struct Nombre nb)
|
||||
{
|
||||
if(nb.typ == Entier)
|
||||
{
|
||||
printf("%d \n", nb.nombr.ValEntier);
|
||||
}
|
||||
else if(nb.typ == Reel)
|
||||
{
|
||||
printf("%f \n", nb.nombr.ValReel);
|
||||
}
|
||||
}
|
||||
|
||||
void Affichage(struct Cell * C)
|
||||
{
|
||||
if(C == NULL)
|
||||
|
@ -88,7 +106,7 @@ void Affichage(struct Cell * C)
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("%d \n", C->Ent.ValEntier);
|
||||
Affiche_Nombre(C->Ent);
|
||||
Affichage(C->Suiv);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +138,7 @@ Programme* lexer(char* chaine) {
|
|||
return retour;
|
||||
}
|
||||
|
||||
void Executer(Etat * etat){
|
||||
/*void Executer(Etat * etat){
|
||||
//struct Pile P = etat->Donnee;
|
||||
//Programme Program = etat->Prog;
|
||||
struct Cell *C1, *C2;
|
||||
|
@ -199,4 +217,4 @@ void Executer(Etat * etat){
|
|||
}
|
||||
|
||||
printf("SORTIE : %d \n", etat->Donnee->Pil->Ent.ValEntier);
|
||||
}
|
||||
}*/
|
7
pile.h
7
pile.h
|
@ -33,14 +33,15 @@ typedef struct Etat{
|
|||
Programme * Prog;
|
||||
} Etat;
|
||||
|
||||
struct Nombre Typenum(string C);
|
||||
struct Nombre Typenum(char * C);
|
||||
void Init_Pile(struct Pile * new);
|
||||
void Empiler(struct Pile * P, int i);
|
||||
void Empiler(struct Pile * P, char * nb);
|
||||
struct Cell * Depiler(struct Pile * P);
|
||||
void Affiche_Nombre(struct Nombre nb);
|
||||
void Affichage(struct Cell * C);
|
||||
|
||||
int numberOfDelimiters(char* string);
|
||||
Programme* lexer(char* chaine);
|
||||
Programme* lexer(char * chaine);
|
||||
|
||||
void Executer(Etat * etat);
|
||||
|
||||
|
|
Loading…
Reference in a new issue