From 41b370324543a21ea3c7679def617356878fe441 Mon Sep 17 00:00:00 2001 From: Axel O Date: Thu, 1 Dec 2022 23:42:05 +0100 Subject: [PATCH] mes fichiers locaux --- main.c | 22 +++++++++++++++++ pile.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pile.h | 31 ++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 main.c create mode 100644 pile.c create mode 100644 pile.h diff --git a/main.c b/main.c new file mode 100644 index 0000000..0c343f9 --- /dev/null +++ b/main.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include "pile.h" + +int main(int argc, char * argv[]) +{ + /*struct Pile P; + Init_Pile(&P); + Empiler(&P, 4); + Empiler(&P, 5); + Affichage(P.Pil);*/ + + Programme * P; + P = lexer(argv[1]); + + for(int i=0; itaille; i++) + { + printf("TOKEN : %s \n", P->tokens[i]); + } +} \ No newline at end of file diff --git a/pile.c b/pile.c new file mode 100644 index 0000000..2b602d7 --- /dev/null +++ b/pile.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include "pile.h" + +void Init_Pile(struct Pile *new) +{ + //struct Pile new; + new->Pil=NULL; + new->nbElements=0; + //return new; +} + +void Empiler(struct Pile * P, int i) +{ + struct Cell * cel= malloc(sizeof(struct Cell)); + cel->Ent = i; + cel->Suiv = P->Pil; + P->Pil = cel; + P->nbElements +=1; +} + +struct Cell * Depiler(struct Pile * P) +{ + struct Cell * res; + if (P->nbElements != 0) + { + res = P->Pil; + P->Pil= P->Pil->Suiv; + + } + + return res; +} + +void Affichage(struct Cell * C) +{ + if(C == NULL) + { + //printf("Rien a afficher"); + } + else + { + printf("%d \n", C->Ent); + Affichage(C->Suiv); + } +} + +int numberOfDelimiters(char* string) { + int count = 0; + for (int i=0;itokens = programme; + retour->taille = i; + return retour; +} \ No newline at end of file diff --git a/pile.h b/pile.h new file mode 100644 index 0000000..ab9e6b3 --- /dev/null +++ b/pile.h @@ -0,0 +1,31 @@ +#ifndef PILE_H +#define PILE_H + + + +struct Cell; + +struct Cell{ + int Ent; + struct Cell * Suiv; +}; + +struct Pile{ + int nbElements; + struct Cell * Pil; +}; + +typedef struct Programme { + char **tokens; + int taille; +} Programme; + +void Init_Pile(struct Pile * new); +void Empiler(struct Pile * P, int i); +struct Cell * Depiler(struct Pile * P); +void Affichage(struct Cell * C); + +int numberOfDelimiters(char* string); +Programme* lexer(char* chaine); + +#endif \ No newline at end of file