From 3b37a00a4be251f87e543d269489cb7a989425d5 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 28 Apr 2001 21:40:25 +0000 Subject: Hop, gros bordel, plein de fichiers ajoutes et supprimes :) --- include/Makefile.am | 1 + include/exceptions.h | 13 +++++++++++++ include/hash.h | 41 +++++++++++++++++++++++++++++++++++++++++ include/main.h | 9 +++++++++ include/numbers.h | 7 +++++++ include/parser.h | 25 +++++++++++++++++++++++++ include/pile.h | 36 ++++++++++++++++++++++++++++++++++++ include/polynom.h | 37 +++++++++++++++++++++++++++++++++++++ include/scalaires.h | 24 ++++++++++++++++++++++++ 9 files changed, 193 insertions(+) create mode 100644 include/Makefile.am create mode 100644 include/exceptions.h create mode 100644 include/hash.h create mode 100644 include/main.h create mode 100644 include/numbers.h create mode 100644 include/parser.h create mode 100644 include/pile.h create mode 100644 include/polynom.h create mode 100644 include/scalaires.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..77cdc01 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +include_HEADERS = exceptions.h hash.h main.h numbers.h parser.h pile.h polynom.h scalaires.h diff --git a/include/exceptions.h b/include/exceptions.h new file mode 100644 index 0000000..6f6e8c4 --- /dev/null +++ b/include/exceptions.h @@ -0,0 +1,13 @@ +#ifndef __EXCEPTIONS_H__ +#define __EXCEPTIONS_H__ + +#include + +char *Estrdup(char *); +void *Emalloc(size_t); +void exception(int, char *); +void pushcontext(char *); +void popcontext(void); +void flushcontext(void); + +#endif diff --git a/include/hash.h b/include/hash.h new file mode 100644 index 0000000..4f40659 --- /dev/null +++ b/include/hash.h @@ -0,0 +1,41 @@ +#ifndef __HASH_H__ +#define __HASH_H__ + +#define TAILLECHAINEHACHAGE (26*2+1) + +typedef void *_TypeVariable; + +typedef struct { + char *NomVar; + _TypeVariable Variable; +} _Element; + +typedef struct _LstChn { + _Element Elem; + struct _LstChn *Suivant; +} *_ListeChaine; + +typedef _ListeChaine *_TableauVariable; + +/* Initialise une table de hachage */ +int Initialise(_TableauVariable * t); + +/* Crée un élement à insérer dans la table de hachage */ +_Element CreerElement(char *Nom, _TypeVariable Var); + +/* Insert un element(Nom de la variable,variable) dans une table de hachage + la fonction renvoit 0 en cas d'erreur */ +char InsererVarDansTab(_TableauVariable * t, _Element e); + +/* Renvoie la variable de la table de hachage qui porte le nom Nom + si la variable n'existe pas trouve est égal à 0 */ +_TypeVariable NomVarToVar(char *Nom, _TableauVariable t, char *trouve); + +/* Supprime la variable de nom Nom + la fonction renvoit 0 en cas d'erreur */ +char SupprimerDansTab(_TableauVariable * t, char *Nom); + +/* Detruit le tableau */ +void DetruitTab(_TableauVariable * t); + +#endif diff --git a/include/main.h b/include/main.h new file mode 100644 index 0000000..e7a730b --- /dev/null +++ b/include/main.h @@ -0,0 +1,9 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ +#include "hash.h" + +extern _TableauVariable variables; +extern char mute; + + +#endif diff --git a/include/numbers.h b/include/numbers.h new file mode 100644 index 0000000..343ca0e --- /dev/null +++ b/include/numbers.h @@ -0,0 +1,7 @@ +#ifndef __NUMBERS_H__ +#define __NUMBERS_H__ + +int char_to_number(char *st, int *valid); +double char_to_double(char *st, int *valid); + +#endif diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..1e7c0fd --- /dev/null +++ b/include/parser.h @@ -0,0 +1,25 @@ +#ifndef __PARSER_H__ +#define __PARSER_H__ + +#define PILEOP_MAX 50 +#define PILECALL_MAX 50 + +enum { + OP_NEST, + OP_PLUS, + OP_MOINS, + OP_EXP, + OP_PLUS_UNARY, + OP_MOINS_UNARY, + OP_DIV, + OP_MOD, + OP_MUL, + OP_ASSIGN, + OP_LPAREN, + OP_FUNC_CALL +}; + + +void parse_line(char *); + +#endif diff --git a/include/pile.h b/include/pile.h new file mode 100644 index 0000000..02ad149 --- /dev/null +++ b/include/pile.h @@ -0,0 +1,36 @@ +#ifndef __PILE_H__ +#define __PILE_H__ +#include "polynom.h" + +#define PILE_MAX 100 + +typedef enum type_elem { + T_POLY, + T_STRING, + T_INT +} type_elem; + +typedef struct pile_elem { + type_elem type; + polynome poly; + char *label; + int val; +} pile_elem; + +void push_pile(char *st); + +void push_pile_poly(polynome poly); + +void push_pile_int(int val); + +void push_pile_string(char *st); + +pile_elem pop_pile(unsigned int count); + +char *affichage_level_1(void); + +int is_mute(char *st); + +void act_pile(int func); + +#endif diff --git a/include/polynom.h b/include/polynom.h new file mode 100644 index 0000000..64a9273 --- /dev/null +++ b/include/polynom.h @@ -0,0 +1,37 @@ +#ifndef __POLYNOM_H__ +#define __POLYNOM_H__ +#include "scalaires.h" + +typedef struct monome { + rationnel coef; + unsigned int degre; + struct monome *suiv; +} monome; + +typedef monome *polynome; + +polynome ply_constr(rationnel coef, int degre); /* constructeur monome */ + +polynome ply_vide(void); /* cree un polynome */ + +void ply_destruct(polynome poly); /* destructeur */ + +polynome ply_copy(polynome poly); /* recopie */ + +polynome ply_addition(polynome poly1, polynome poly2); /* addition de deux polynomes */ + +polynome ply_soustraction(polynome poly1, polynome poly2); /* soustraction de deux polynomes */ + +polynome ply_multiplication(polynome poly1, polynome poly2); /* multiplication de deux polynomes */ + +polynome ply_division(polynome poly1, polynome poly2); /* division de deux polynomes */ + +polynome ply_modulo(polynome poly1, polynome poly2); /* reste de la division de deux polynomes */ + +polynome ply_exposant(polynome poly, unsigned int exp); /* exponentiation d'un polynome */ + +double ply_valuation(polynome poly, double point); /* valuation d'un polynome en un point */ + +char *ply_affichage(polynome poly); /* routine d'affichage d'un polynome */ + +#endif diff --git a/include/scalaires.h b/include/scalaires.h new file mode 100644 index 0000000..a13b96a --- /dev/null +++ b/include/scalaires.h @@ -0,0 +1,24 @@ +#ifndef __SCALAIRES_H__ +#define __SCALAIRES_H__ + +typedef struct { + int num; + unsigned int denom; +} rationnel; + +rationnel rat_constr_zero(void); /* renvoie 0 */ + + +rationnel rat_constr(int num, int denom); /* cree une fraction */ + +rationnel rat_constr_from_double(double flt); /* cree une fraction a partir d un double */ + +void rat_destruct(rationnel rat); /* destructeur */ +double rat_to_double(rationnel rat); /* obtention du double correspondant a un rationnel */ +rationnel rat_addition(rationnel rat1, rationnel rat2); /* addition */ +rationnel rat_soustraction(rationnel rat1, rationnel rat2); /* soustraction */ +rationnel rat_moinsunaire(rationnel rat1); /* moins unaire */ +rationnel rat_multiplication(rationnel rat1, rationnel rat2); /* multiplication */ +rationnel rat_division(rationnel rat, rationnel rat2); /* division */ + +#endif -- cgit v1.2.3