trafi

Transducteurs finis
git clone git://git.asteride.xyz/trafi.git
Journaux | Fichiers | Références

commit 03ca6b6c5a2318d1d03e1fc62b50b993f652a632
parent 0d2886009331d132e05cfbe92968c3bc466edab5
Auteur: Loïc Daignault-Pichette <loic@asteride.xyz>
Date:   Thu,  2 Apr 2026 15:06:40 -0400

Ajouter quelques fonctions à tfm.h

Ce sont des fonctions qui permettent d’accéder à des informations des
structures tfm, etat et trans.

Diffstat:
Mtfm.c | 42++++++++++++++++++++++++++++++++++++++++++
Mtfm.h | 12++++++++++++
2 fichiers modifiés, 54 insertions(+), 0 suppressions(-)

diff --git a/tfm.c b/tfm.c @@ -205,6 +205,48 @@ tfm_tfinal(struct tfm *tfm, size_t ietat) return etat.final; } +ssize_t +tfm_ntrans(struct tfm *tfm, size_t ietat) +{ + struct etat etat; + + TFM_COHERENT(tfm); + + /* Obtenir l’état. */ + if (tampinf_obt(tfm->etats, ietat, 1, &etat) < 0) + return -1; + + return etat.ntrans; +} + +ssize_t +tfm_trans(struct tfm *tfm, size_t ietat) +{ + struct etat etat; + + TFM_COHERENT(tfm); + + /* Obtenir l’état. */ + if (tampinf_obt(tfm->etats, ietat, 1, &etat) < 0) + return -1; + + return etat.trans; +} + +ssize_t +tfm_trans_prch(struct tfm *tfm, size_t itrans) +{ + struct trans trans; + + TFM_COHERENT(tfm); + + /* Obtenir la transition. */ + if (tampinf_obt(tfm->trans, itrans, 1, &trans) < 0) + return -1; + + return trans.prch; +} + static ssize_t tfm_symb_chercher(struct tampinf *ti, char *symb, size_t lngr) { diff --git a/tfm.h b/tfm.h @@ -92,4 +92,16 @@ int tfm_mfinal(struct tfm *tfm, size_t ietat); * Renvoie un booléen, ou -1 en cas d’erreur. */ int tfm_tfinal(struct tfm *tfm, size_t ietat); +/* Obtenir le nombre de transitions sortantes de l’était ietat. + * Renvoie ce nombre, ou -1 en cas d’erreur. */ +ssize_t tfm_ntrans(struct tfm *tfm, size_t ietat); + +/* Obtenir l’identifiant de la première transition sortante d’ietat. + * Renvoie cet identifiant, ou -1 en cas d’erreur. */ +ssize_t tfm_trans(struct tfm *tfm, size_t ietat); + +/* Obtenir l’identifiant de la transition suivant la transition itrans. + * Renvoie cet identifiant, ou -1 en cas d’erreur. */ +ssize_t tfm_trans_prch(struct tfm *tfm, size_t itrans); + #endif