trafi

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

commit 9f9e5d60a3cd3fb5eebb1335e8324a5d52ef9d76
parent 668222941762ea1e06d56cb0e4b3e3739ef8ce6d
Auteur: Loïc Daignault-Pichette <loic@asteride.xyz>
Date:   Mon, 16 Feb 2026 12:26:00 -0500

Parcourir les symboles

Diffstat:
Mtfm.c | 21+++++++++++++++++++++
Mtfm.h | 8++++++++
2 fichiers modifiés, 29 insertions(+), 0 suppressions(-)

diff --git a/tfm.c b/tfm.c @@ -151,6 +151,27 @@ tfm_symb_obt(struct tfm *tfm, size_t id, char *symb, size_t max) return lngr; } +ssize_t +tfm_parc_symbs(struct tfm *tfm, size_t *id, char *symb, size_t max) +{ + ssize_t lngr; + + TFM_COHERENT(tfm); + assert(id); + assert(symb); + assert(max > 0); + + if (!tampinf_dedans(tfm->symbs, *id)) + return 0; + + if ((lngr = tfm_symb_obt(tfm, *id, symb, max)) < 0) + return lngr; + + *id += lngr + 1; + + return lngr; +} + int tfm_mfinal(struct tfm *tfm, size_t ietat) { diff --git a/tfm.h b/tfm.h @@ -75,6 +75,14 @@ int tfm_symb_id(struct tfm *tfm, char *symb, size_t lngr, ssize_t *id); * spéciaux. Renvoie la taille du symbole, ou -1 en cas d’erreur. */ ssize_t tfm_symb_obt(struct tfm *tfm, size_t id, char *symb, size_t max); +/* Parcourir les symboles du transducteurs tfm. + * Un symbole est placé dans le tampon symb, de taille max, à chaque appel. + * L’identifiant id est un pointeur vers l’identifiant du prochain symbole à + * lire. Il est normalement initialisé à 0 avant le parcours. N’exporte que les + * symboles non-spéciaux. Renvoie la taille du symbole, 0 s’il ne reste plus de + * symbole à lire, ou -1 en cas d’erreur. */ +ssize_t tfm_parc_symbs(struct tfm *tfm, size_t *id, char *symb, size_t max); + /* Marquer un état comme final. * Renvoie 0, ou -1 en cas d’erreur. */ int tfm_mfinal(struct tfm *tfm, size_t ietat);