tclex-1.2a1.orig/ 42755 0 0 0 6772443522 11653 5ustar rootroottclex-1.2a1.orig/AFAIRE.txt100644 0 0 3173 6763747176 13456 0ustar rootrootListe A FAIRE pour tcLex, dernière mise à jour le 20/07/1999 : (non triée) - Ajouter des types d'entrées variés : chaîne, variable, fichier, "channel". Ajouter les options correspondantes à eval et start. - Ajouter des tampons d'entrée multiples, en utilisant probablement la syntaxe suivante: # crée un tampon # equivalent à yy_create_buffer # le tampon original est appelé "initial" ou {} # option pourrait être -file, -channel... string par défaut buffer create ?option? # permute vers le tampon # equivalent à yy_switch_to_buffer buffer switch # demande la liste des tampons buffer list # renvoie le tampon courant buffer ?current? # détruit un tampon buffer delete - Ajouter la condition spéciale "eof" nécessaire avec les tampons multiples. - Ajouter l'option -append à continue et finish, pour ajouter de nouveaux caractères à la chaîne d'entrée courante plutôt que les remplacer. - Ajouter des fonctions d'introspection et de déboguage comme des traces d'actions, une commande à la info, ... - Finir d'écrire la documentation, et la traduire en français - Créer un fichier projet Metrowerks CodeWarrior Pro 4 pour Macintosh (et peut-être aussi pour Windows, pour du développement multi-plateforme), et fournir des binaires Macintosh - Peut-être ajouter une option aux lexeurs pour désactiver la pile de conditions (par exemple -nocs, pour "no conditions stack"), pour une meilleure compatibilité avec (f)lex. Il n'y a pas de réel équivalent aux piles de conditions dans (f)lex. tclex-1.2a1.orig/ANNONCE.txt100644 0 0 13350 6763747176 13626 0ustar rootrootJe suis heureux d'annoncer la nouvelle version corrigée de tcLex : tcLex v1.2a1: un générateur d'analyseur lexical pour Tcl Par Frédéric BONNET (frederic.bonnet@ciril.fr) Mis à jour le 3 septembre 1999, 15:08 La page Web dédiée à cette extension est : http://www.multimania.com/fbonnet/Tcl/tcLex/index.htm ************************************************************************ QUOI DE NEUF: - Adapté pour Tcl8.2. - Modifié le comportement de "lexer begin initial" pour qu'il vide la pile des conditions. - Supprimé les sources de la distribution Windows, qui devient une distribution exclusivement binaire. La distribution .tar.gz est multi-plateforme. Voir le fichier changements.txt pour les détails. ************************************************************************ INTRODUCTION tcLex est une extension Tcl servant à générer des lexeurs (analyseur lexical). Elle est inspirée des commandes Unix et GNU lex et flex, qui sont des "outils pour générer des programmes effectuant des 'pattern-matching' sur du texte". tcLex est très similaire à ces programmes, à part qu'elle utilise la philosophie et la syntaxe de Tcl, tandis que les autres utilisent leur propre syntaxe et sont utilisés en conjonction avec le langage C. Les personnes habituées à lex ou flex devraient donc se sentir familier avec tcLex. tcLex est une petite extension (la version compilée pour Windows fait environ 20ko, et le source environ 150ko), parce qu'il utilise au maximum la bibliothèque Tcl. Cependant, la présente n'utilise plus le code de regexp de Tcl, mais une version modifiée est maintenant incluse dans tcLex, ce qui la rend légèrement plus grosse (de quelques ko). tcLex devrait fonctionner avec Tcl 8.0 et ultérieurs. tcLex ne marchera JAMAIS avec des versions plus anciennes, parce qu'elle utilise le nouveau système d'"objets" de Tcl 8.0 pour des raisons de performance. Les caractéristiques les plus intéressantes sont : * support multi-plateforme, grâce à Tcl. Bien qu'elle ait été développée sur Windows et testée sur Windows et Unix, elle devrait fonctionner sur d'autres plateformes si une version de Tcl existe sur celles-ci. Les plateformes supportées par Tcl sont Windows 95/NT, Unix (Linux, Solaris...) et Macintosh. D'autres plateformes sont VMS, OS/2, NeXTStep, Amiga... * contrairement à lex et flex, qui génèrent uniquement des lexeurs statiques écrits en C et destinés à être compilés, tcLex génère dynamiquement des commandes Tcl qui peuvent être utilisées comme d'autes commandes C ou des procédures Tcl à partir de scripts Tcl ou de programmes C. * elle utilise les expressions régulières de Tcl. Ce qui signifie que vous n'avez pas à apprendre un nouveau langage de regexp. * elle fonctionne avec les "namespaces" de Tcl * les commandes générées peuvent être utilisées en une passe ou incrémentallement, car elles maintiennent des informations d'état. Ainsi, plusieurs instances du même lexeur (par exemple un parseur HTML) peuvent tourner simultanément dans des contextes distincts et maintenir des états également distincts (variables locales...). Les lexeurs n'ont pas besoin d'être spécialement conçus pour être utilisés incrémentallement, le même lexeur peut être utilisé en une passe ou incrémentallement de façon transparente. Cette caractéristique est particulièrement utile lors du traitement de texte issu d'un fichier ou d'une socket Internet (pages Web par exemple), quand les données ne sont pas nécessairement disponibles au début du traitement. VERSION La version actuelle de tcLex est 1.2a1. Le suffixe "a1" signifie "alpha 1", ce qui veut dire que cette version est une version incomplète par rapport aux fonctions de la future 1.2, qui étend et corrige la précédente. Le fichier changements.txt décrit les changements effectués entre la première version de tcLex et la version actuelle. Bien que ce soit une version alpha, elle apporte plus de corrections de bugs que de nouveaux ;-). Dans ce cas, alpha signifie que de nombreuses fonctions prévues ne sont pas encore implémentées, et la documentation peut être incomplête. La plupart des informations utiles sont dans le fichier changements.txt. Le fichier AFAIRE.txt contiens les fonctions prévues qui ne sont pas encore implémentées. OU OBTENIR TCLEX Page d'accueil : http://www.multimania.com/fbonnet/Tcl/tcLex/index.htm Fichiers de distribution : - http://www.multimania.com/fbonnet/pub/tcLex12a1.zip (binaires Windows pour Tcl8.0.5, Tcl8.1.1 et Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.tar.gz (sources Windows/Unix pour Tcl8.0.5, Tcl8.1.1 et Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.patch (fichier correctif pour la version 1.1.4) SUPPORT Depuis le 17/11/1998, tcLex dispose d'une liste de diffusion dédiée. Le site Web de cette liste est : http://www.eGroups.com/list/tclex . Pour souscrire a cette liste, envoyez un e-mail à l'adresse suivante : tclex-subscribe@egroups.com . J'essaie également de répondre à tous les messages que les utilisateurs m'envoient concernant tcLex. INSTALLATION, LICENSE, ETC. Le fichier LISEZMOI.txt de la distribution contient des informations importantes sur l'installation, la compilation et l'utilisation de tcLex. Lisez-le bien attentivement. Le fichier license.txt (en anglais uniquement) décrit la license qui couvre tcLex. Elle est très proche de celle de Tcl/Tk. J'aprécierai que chaque utilisateur de tcLex m'envoie un mail afin que je puisse comptabiliser le nombre d'utilisateurs de ce logiciel, dans un but purement informatif. Je n'en ferai aucun usage autre que statistique. N'hésitez par à envoyer des commentaires ou signaler des bugs à frederic.bonnet@ciril.fr. tcLex est succeptible d'être amélioré en fonction des remarques des utilisateurs. tclex-1.2a1.orig/ANNOUNCE.txt100644 0 0 11573 6763747176 13760 0ustar rootrootI am pleased to announce the new development version of tcLex: tcLex v1.2a1: a lexical analyzer generator for Tcl by Frédéric BONNET (frederic.bonnet@ciril.fr) Updated 3 September 1999, 15:08 The home page for this package is: http://www.multimania.com/fbonnet/Tcl/tcLex/index.en.htm ************************************************************************ WHAT'S NEW: - Adapted for Tcl8.2. - Modified the behavior of "lexer begin initial" so that it empties the conditions stack. - Removed sources from the Windows distribution, becoming a binary-only distribution. The .tar.gz distribution is cross-platform. See the file changes.txt for details ************************************************************************ INTRODUCTION tcLex is a lexer (lexical analyzer) generator extension to Tcl. It is inspired by Unix and GNU lex and flex, which are "tools for generating programs that perform pattern-matching on text". tcLex is very similar to these programs, except it uses Tcl philosophy and syntax, whereas the others use their own syntax and are used in conjunction with the C language. People used to lex or flex should then feel familiar with tcLex. tcLex is a small extension (the Windows compiled version is about 20kb, and the source is about 150kb), because it extensively uses the Tcl library. However, the current doesn't use Tcl's regexp code anymore but a patched version is now included in tcLex, which makes it slightly bigger (by a few KB). tcLex should work with Tcl 8.0 and later. tcLex will NEVER work with earlier versions, because it uses Tcl 8.0's "object" system for performance. The most interesting features are: * cross-platform support, thanks to Tcl. Though it has been developped on Windows and tested on Windows and Unix only, it should work on other platforms as long as Tcl exists on these platforms. Supported Tcl platforms are Windows 95/NT, Unix (Linux, Solaris...) and Macintosh. Other platforms are VMS, OS/2, NeXTStep, Amiga... * unlike lex and flex, which only generate static lexers written in C and intended to be compiled, tcLex dynamically generates Tcl commands that can be used like other C commands or Tcl procedures from within Tcl scripts or C programs. * it uses Tcl regular expressions. That means you don't have to learn another regexp language. * it works with Tcl namespaces * the generated lexer commands can be used in one pass or incrementally, because they maintain state information. That way, several instances of the same lexer (eg a HTML parser) can run at the same time in distinct call frames and maintain distinct states (local variables...). Lexer need not be specially designed in order to be used incrementally, the same lexer can transparently be used in one pass or incrementally. This feature is especially useful when processing text from a file or an Internet socket (Web pages for example), when data is not necessarily available at the beginning of the processing. VERSION The current tcLex version is 1.2a1. The suffix "a1" means "alpha 1", meaning that this version is the first fature-incomplete release of the future 1.2, extending and correcting the previous 1.1. The file changes.txt describes the changes made between the first version of tcLex and the current version. Although it is alpha software, it brings more bugs corrections than new ones ;-). In this case, alpha means that many planned features are not yet implemented, and documentation may be incomplete. Most of the useful info is in the file changes.txt. The file TODO.txt contains planned features that needs to be implemented. WHERE TO GET TCLEX Home Page: http://www.multimania.com/fbonnet/Tcl/tcLex/index.en.htm Distribution files: - http://www.multimania.com/fbonnet/pub/tcLex12a1.zip (Windows binaries for Tcl8.0.5, Tcl8.1.1 and Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.tar.gz (Windows/Unix sources for Tcl8.0.5, Tcl8.1.1 and Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.patch (patch file for version 1.1.4) SUPPORT Since 11/17/1998, tcLex has a dedicated mailing list. The Web site for this list is: http://www.eGroups.com/list/tclex . To subscribe, send a e-mail to the following address: tclex-subscribe@egroups.com . Also, I try to answer all the mails users send me regarding tcLex. INSTALLATION, LICENSE, ETC. The file README.txt of the distribution contains information about the installation, compilation and use of tcLex. Read it carefully. The file license.txt describes the license that covers tcLex. It is very close to the Tcl/Tk license. I'd appreciate that every tcLex user send me a mail so I can keep track of the number of users for this software, in a purely informative goal. I won't make any use of these other than statistic. Feel free to send any comment or bug report to frederic.bonnet@ciril.fr. tcLex is likely to be improved depending on users feedback. tclex-1.2a1.orig/changements.txt100644 0 0 32673 6763747176 15052 0ustar rootrootDernière modification: 20/07/1999, 11:04 -------- 01/08/1998 tcLex version 1.0 -------- -------- 02/09/1998 tcLex version 1.0p1 -------- 1. Bug potentiel corrigé quand un lexeur global était créé à partir d'un namespace. Par exemple : namespace eval foo { lexer ::bar::baz ... } La commande créée était ::foo::bar::baz au lieu de ::bar::baz. De plus, la valeur de retour est maintenant le nom complet (comme pour proc) et non le nom spécifié (relatif au namespace). 2. Bug majeur corrigé dans le traitement incrémental. Utilisé avec le rejet de règle, certaines règles étaient incorrectement ignorées. Cette correction apporte aussi une amélioration des performances lors du traitement incrémental. 3. Coquilles mineures corrigées dans la documentation : l'exemple montrant la différence entre conditions inclusive et exclusive était incorrect. 4. Erreur de syntaxe corrigée dans le fichier pkgIndex.tcl par défaut fourni avec la version précédente. Ce fichier ne marchait pas à cause d'accolades en trop :(. Heureusement "pkg_mkIndex" fonctionnait. 5. Ajout de fichiers de configuration pour Unix, grand merci à John Ellson de Lucent pour ces fichiers ! 6. Remplacement de "static const char*" par "static char*" à certains endroits pour éviter des avertissement de compilation sur Unix. Merci à John Ellson et Paul Vogel de me l'avoir fait remarquer. 7. Ajout de l'extension .txt à tous les fichiers texte de la distribution. Ceci facilite leur lecture sous Windows. 8. Ajout du présent fichier (changements.txt) -------- 11/11/1998 tcLex version 1.1a1 -------- 1. Réécriture complète de l'interface de regexp. Une version modifiée du moteur regexp de Tcl est maintenant incluse dans le code. Bien que le code soit ainsi légèrement plus gros, (le binaire fait quelques ko de plus), cela permet une meilleure gestion des cas de dépassement de chaîne, qui étaient une limite majeure des versions précédentes. Cela permet également les regexps sensibles aux lignes sous Tcl8.0 (voir ci-dessous). Ajout des fichiers tcLexRE.h et tcLexRE.c -- qui à son tour inclut RE80.c ou RE81.c (les moteurs de regexp modifiés) selon la version de Tcl. 2. Complètement retravaillé le code de manipulation de chaînes, afin de le rendre propre par rapport à Unicode sour Tcl8.1. Il stocke maintenant la chaîne au format Unicode au lieu de UTF-8, afin que l'utilisation d'indices soit plus facile (UTF-8 utilise des caractères de taille variable et donc nécessite des procédures de parcours spécifiques). Apporte également des améliorations significatives avec les grandes chaînes (avant, la chaîne UTF-8 entière était convertie en Unicode par le moteur regexp à chaque essai de règle). 3. Bug corrigé avec index sous Tcl8.1 (la correction est en rapport avec les changements ci-dessus). L'index retourné etait l'index en octets et non l'index en caractères. 4. Fichier tcLexPrivate.h renommé tcLexInt.h pour plus de cohérence avec Tcl. 5. Ajout de l'option -args pour permettre le passage d'arguments supplémentaires, en utilisant la même syntaxe que proc. Par exemple : lexer foo -args {a b {c 3}} ... foo eval $string 1 2; # a=1, b=2, c=3 par défaut 6. Ajout de l'option -lines pour le traitement sensible aux lignes. Ceci change le comportement de "^$" et "." dans les regexps, et procure une façon portable d'utiliser des regexps sensibles aux lignes (Tcl8.0 ne les supporte pas, et Tcl8.1 nécessite une syntaxe particulière). L'implémentation a été rendue possible par l'inclusion du code de regexp. 7. Ajout d'une structure TcLex_Buffer permettant des améliorations fututes : différents types d'entrées (chaîne, variable, fichier, "channel") ainsi que des tampons d'entrée multiples. 8. Réorganisation du code pour faciliter les améliorations futures. 9. La valeur de retour de "lexer" est maintenant une chaîne vide, comme avec proc (contrairement à ce que j'ai écrit précédemment). 10. Bug corrigé dû à des désallocations de mémoires excessives, merci à Claude BARRAS . 11. Ajout des sous-commandes "input" et "unput", suivant les suggestions de Neil Walker . Elles sont similaires à celles de flex, input() et unput(), sauf que unput ne peut pas réinjecter des caractères arbitraires dans la chaîne d'entrée (c'est un choix de conception, pas une limite technique). -------- 19/11/1998 tcLex version 1.1a2 -------- 1. Ajout de l'option -nocase pour l'insensibilité à la casse. Sous Tcl8.0, cela a nécessité une incursion plus profonde dans le code de regexp. 2. Ajout de l'option -longest pour choisir la plus longue identification (longest prefered matching) (comme flex) plutôt que la première identification (par défaut). 3. Retravaillé le code de rejet de règle afin qu'il marche correctement et efficacement avec -longest. Cela l'a aussi rendu plus sûr. -------- 25/11/1998 tcLex version 1.1a3 -------- 1. Bug majeur corrigé dans la modification du moteur regexp de Tcl8.0, causant l'échec de certaines regexps (particulièrement celles avec des sous-expressions marquées par ?). Par exemple, l'expression "a?b" reconnaissait la chaîne "b", mais pas la chaîne "ab". 2. Ajout de sous-commandes "create" et "current" à la commande lexer. La première est optionnelle et sert lors de la création des lexeurs : lexer ?create? ?args ... args? La seconde peut être utilisée pendant un traitement pour récupérer le nom du lexeur active courant, par exemple : [lexer current] index Cela évite d'utiliser le nom du lexeur partout, et est utile quand les lexeurs sont renommés, aliasés ou importés. Suggestion faite par Leo Schubert . Ces nouvelles sous-commandes introduisent une incompatibilité potentielle : les lexeurs ne peuvent plus être nommés "create" ou "current" (mais ça ne devrait pas être un problème). -------- 18/12/1998 tcLex version 1.1b1 -------- 1. TcLex est maintenant conçu pour être lié à Tcl8.0.4 ou Tcl8.1b1. Quelques changements ont été apportés aux fichiers sources pour prendre en compte de nouvelles directives d'importation quand on compile des DLLs Windows (introduites avec Tcl8.0.3). 2. Légère modification du makefile.vc de Windows pour compiler les fichiers objets dans des répertoires distincts en fonction de certains paramètres (debug, version de Tcl). 3. Le fichier RE81.c est maintenant basé sur le source de regexp de Tcl8.1b1. 4. Réécriture complète de la documentation. Elle inclut maintenant une comparaison avec flex ainsi qu'une page de manuel classique. Elle utilise HTML + CSS afin que les fureteurs récents puissent afficher une présentation améliorée tout en permettant aux fureteurs textuels d'afficher du texte formatté correctement. 5. Ajout de plusieurs exemples, certains de Neil Walker (thanks, Neil!), certains de moi (Frédéric BONNET). -------- 11/01/1999 tcLex version 1.1b2 -------- 1. Ajout du point d'entrée SafeTcl (Tclex_SafeInit). 2. Bug corrigé qui semblait arriver uniquement sur certains systèmes Unix (SGI et Solaris) mais affectait de même potentiellement d'autres systèmes. Certains lexeurs étaient incorrectement signalés comme inactifs même quand retournés par [lexer current]. La source de ce bug était l'absence d'une borne inférieure dans le désallateur d'état de lexeur (StateDelete) qui donnait aux états suivant un index négatif, causant l'erreur "inactive lexer". Bug rapporté par Claude BARRAS et Neil Walker. 3. Bug corrigé dans le moteur regexp corrigé de Tcl8.0, qui faisait que les retours chariot étaient traités comme des caractères quelconques même en mode sensible aux lignes lorsqu'ils étaient utilisés avec * ou +. Bug rapporté par Neil Walker. 4. Gestion de ^$ améliorée en mode sensible aux lignes sous Tcl8.0 afin qu'ils se comportent de la même façon que sous Tcl8.1. 5. Bug corrigé dans la gestion des chaînes vides: certaines actions étaient appelées deux fois, une pour la chaîne identifiée et une pour une chaîne vide à la fin de la précédente. 6. Avertissements corrigés sous Unix, précédemment rapportés par Claude BARRAS mais oubliés dans la version précédente: la structure regexec_state dans RE80.c (moteur regexp corrigé de Tcl8.0) était utilisée avant d'être définie. Ces avertissements étaient silencieux sous Windows (niveau d'avertissement trop bas ?). -------- 04/04/1999 tcLex version 1.1 finale -------- 1. Coquille mineure corrigée dans RE80.c : dans la fonction findChar, le paramètre c était déclaré comme int* au lieu de int. Cela n'avait pas d'influence (il était transformé en char de toute façon) mais générait des avertissements avec certains compilateurs (pas le mien malheureusement )-:. Rapporté par Volker Hetzer . 2. TcLex est maintenant conçu pour être lié à Tcl8.0.4 (ou patchlevel supérieur) ou Tcl8.1b2. Sur ce dernier, tcLex est configuré par défaut pour utiliser les nouvelles fonctions de stubs. Seules quelques modifications mineures du code ont été nécessaires. Tcl8.1b1 n'est plus du tout supporté. 3. Macros de compatibilité supprimées dans tcLexInt.h maintenant que les anciennes fonctions sont de retour dans Tcl8.1b2. 4. Bug majeur corrigé apparaissant avec les lexeurs préférant la plus longue chaîne reconnue ("longest-prefered matching lexers"). Quand plusieurs règles reconnaissaient le même nombre de caractères, la dernière règle définie était choisie au lieu de la première, à cause d'un mauvais opérateur de comparaison ('<' était utilisé à la place de '<=' dans RuleTry). Cela cassait l'exemple "pascal". 5. Code reformatté afin qu'il utilise des indentations de 4 espaces au lieu de 2, pour mieux se conformer aux conventions Tcl de codage en C. C'est assez cosmétique mais cela rend le code un peu plus lisible. -------- 30/04/1999 tcLex version 1.1.1 -------- 1. TcLex est maintenant conçu pour être lié à Tcl8.0.4 (ou patchlevel supérieur) ou Tcl8.1b3. Tcl8.1b2 n'est plus du tout supporté. 2. Suppression de la redéfinition de TclUtfToUniCharDString et TclUniCharToUtfDString dont on avait besoin avec la version stubs de Tcl8.1b2, maintenant que Tcl_UtfToUniCharDString et Tcl_UniCharToUtfDString sont disponibles publiquement dans Tcl8.1b3. 3. Suppression de la bidouille rendue nécessaire par la non-exportation de TclRegCompObj par la version stub de Tcl8.1b2. Tcl8.1b3 exporte maintenant la procédure publique Tcl_GetRegExpFromObj qui fait la même chose. 4. Incohérence de regexp corrigée entre Tcl8.0 et Tcl8.1 avec le traitement sensible aux lignes. Les regexps avec des champs négatifs ("negated ranges", désolé pour la traduction :) (comme [^a]) pouvaient recouvrir plusieurs lignes sous Tcl8.0 mais pas sous Tcl8.1 (le comportement correct). 5. Nettoyé le code regexp modifié et proposé sous forme de correctif pour le noyau Tcl. 6. Réécrit le code d'analyse d'arguments utilisant Tcl_GetIndexFromObj afin qu'il utilise des constantes symboliques plutôt que des index entiers. 7. Ajout de liens vers la page tcLex de Neil Walker's (thanks Neil!) à partir de la doc. -------- 25/04/1999 tcLex version 1.1.2 -------- 1. Bug corrigé dans le traitement sensible aux lignes sous Tcl8.0. Ce bug a été introduit par la modification précédente no. 4, et se situait dans le code de regexp traitant des champs négatifs dans certains cas. -------- 24/06/1999 tcLex version 1.1.3 -------- 1. Bug majeur corrigé avec Tcl 8.1.1. Le nouveau mécanisme de cache de regexp introduit par Tcl 8.1.1 entrait en conflit avec la façon dont tcLex stockait les regexps compilées. Le code de gestion de regexps a été complètement retravaillé. Bug rapporté par by Claude BARRAS. 2. Ajouté l'URL vers le regexp-HOWTO de chez Scriptics dans la doc (http://www.scriptics.com/support/howto/regexp81.html). -------- 20/07/1999 tcLex version 1.1.4 -------- 1. Bug majeur corrigé avec Tcl 8.1. Les fonctions BufferNotStarving() et BufferAtEnd() mélangeaient des index en caractères et en octets, ce qui entrainait des dépassements de chaîne. Bug rapporté par Neil Walker. Il est étonnant que ce bug ne se soit pas déclaré avant car les risques de dépassement étaient quasi systématiques, or il ne plantait tcLex que dans des cas bien précis (difficiles à reproduire sous Windows). -------- 03/09/1999 tcLex version 1.2a1 -------- 1. Ajouté le support pour Tcl8.2 et supérieur. Maintenant que le moteur regexp de Tcl8.2 procure les fonctions dont tcLex a besoin (cad. détection de dépassement de chaîne et recherche limitée au début chaîne), tcLex ne nécessite plus de modification de ce moteur. Ceci rend le code plus simple car il utilise maintenalnt les fonctions standard de la bibliothèque Tcl. Ajouté le fichier RE82.c 2. La chaîne d'entrée est maintenant stockée sous forme de Tcl_Obj et non plus de Tcl_DString. Retravaillé le code correspondant en conséquence (RuleTry(), RuleExec(), RuleGetRange()). Sous Tcl8.0, on utilise la chaîne 8bits de l'objet. Sous Tcl8.2, la chaîne Unicode (pas UTF-8) (en fait, on passe la chaîne aux procédures de bibliothèque Tcl, qui à leur tour utilisent la représentation Unicode de l'objet). Sous Tcl8.1, ajout d'un type d'objet Unicode et des procédures relatives (par exemple Tcl_NewUnicodeObj(), Tcl_GetUnicode() et Tcl_GetCharLength()) afin d'être compatible source avec Tcl8.2. Ces nouveaux objets Unicode utilisent des Tcl_DStrings Unicode comme représentation interne. 3. Modifié le comportement de "lexer begin initial" afin qu'il vide la pile de conditions au lieu d'empiler la condition "initial" à son sommet. Cela rend l'écriture de certains lexeurs plus facile (par exemple, les exemples flex de Neil Walker). tclex-1.2a1.orig/changes.txt100644 0 0 27205 6763747176 14161 0ustar rootrootLast updated: 07/20/1999, 11:04 -------- 08/01/1998 tcLex version 1.0 -------- -------- 09/02/1998 tcLex version 1.0p1 -------- 1. Corrected potential bug when a global lexer was created from within a namespace. For example: namespace eval foo { lexer ::bar::baz ... } The created commmand was ::foo::bar::baz instead of ::bar::baz. Also, the return value is now the fully qualified name (like with proc) and not the specified name (namespace-relative). 2. Corrected major bug with incremental processing. When used with rule rejection, some rules were incorrectly bypassed. This correction is also a performance enhancement for incremental processing. 3. Minor typos corrected in the man page: the example demonstrating the difference between inclusive and exclusive conditions was incorrect. 4. Corrected syntax error in the default pkgIndex.tcl file provided with the previous version. This file didn't work due to extra curly braces :(. Hopefully doing "pkg_mkIndex" worked. 5. Added configure files for Unix, many thanks to John Ellson of Lucent for these files! 6. Changed "static const char*" to "static char*" in some places to avoid compiler warnings on Unix. Thanks to John Ellson and Paul Vogel for pointing that out. 7. Added .txt extension to all text files in the distrib. This makes them easier to read them under Windows. 8. Added the current file (changes.txt) -------- 11/11/1998 tcLex version 1.1a1 -------- 1. Completely rewrote the regexp interface. A patched version of Tcl's regexp package is now included in the code. Although it makes the code a bit bigger (the binay is a few KB more), it allows for better handling of string overrun cases, which was a major limitation in previous versions. Also allows newline-sensitive regexps in Tcl8.0 (see below). Added files tcLexRE.h and tcLexRE.c -- which in turn includes RE80.c or RE81.c (modified regexp engines) depending on the Tcl version number. 2. Completely reworked the string handling code, so it is Unicode-clean now under Tcl8.1. Now it stores the Unicode string instead of UTF-8, so that using string indices is easier (UTF-8 uses variable-byte chars and thus needs special parsing procedures). Also brings significant performance enhancement with big strings (previously, the whole UTF-8 string was converted to Unicode by the regexp package every time a rule was tried). 3. Corrected bug with index under Tcl8.1 (the correction is related to the above changes). The returned index was the byte index and not the character index. 4. Renamed tcLexPrivate.h to tcLexInt.h for more consistency with Tcl. 5. Added -args option to allow extra arguments passing, using the same syntax as proc. For example: lexer foo -args {a b {c 3}} ... foo eval $string 1 2; # a=1, b=2, c defaults to 3 6. Added -lines flag for line-sensitive processing. This changes the behavior of "^$" and "." in regexps, and provides a portable way to use line-sensitive regexps (Tcl8.0 doesn't support them, and Tcl8.1 requires special syntax). This has been implemented thanks to the inclusion of the regexp code. 7. Added a TcLex_Buffer structure to allow future improvements: different types of inputs (string, variable, file, channel) as well as multiple input buffers. 8. Reorganized the code to make future improvements easier to implement. 9. The return value to "lexer" is now an empty string, like with proc (contrary to what I previous wrote) 10. Fixed bug due to overzealous memory deallocation, thanks to Claude BARRAS . 11. Added "input" and "unput" subcommands, following the suggestions of Neil Walker . They are similar to flex's input() and unput() functions, except that unput can't put arbitrary chars back into the input string (this is a design choice, not a technical limiation). -------- 11/19/1998 tcLex version 1.1a2 -------- 1. Added -nocase flag for case-insensitivity. Under Tcl8.0, it needed further incursion into the regexp code. 2. Added -longest flag to chose longest matching rule (as flex) instead of first matching rule (the default). 3. Reworked the rule rejection code so that it works correctly and efficiently with -longest. It also made it safer. -------- 11/25/1998 tcLex version 1.1a3 -------- 1. Corrected major bug in the modified Tcl8.0 regexp engine, which caused some regexps to fail (especially those with ?-marked subexpressions). For instance, the expression "a?b" matched the string "b", but not the string "ab". 2. Added "create" and "current" subcommands to the lexer command. The first is optional and is used when creating lexers: lexer ?create? ?args ... args? The second can be used during a processing to get the name of the currently active lexer, for example: [lexer current] index This avoids using the name of the lexer everywhere, and is useful when lexers are renamed, aliased or imported. Suggestion made by Leo Schubert . These new subcommands introduce a potential incompatibility: lexers cannot be named "create" or "current" anymore (but this shouldn't be a problem). -------- 12/18/1998 tcLex version 1.1b1 -------- 1. TcLex is now intended to be linked against Tcl8.0.4 or Tcl8.1b1. Some changes have been made in the source files to take the new import directives into account when building Windows DLLs (introduced in Tcl8.0.3). 2. Slighly modified the Windows makefile.vc to build the object files into distinct directories depending on some settings (debug, Tcl version). 3. File RE81.c is now based on the regexp source from Tcl8.1b1. 4. Completely rewrote the documentation. This now includes a comparison with flex, as well as a classical man page. It uses HTML + CSS so that newer browsers can display enhanced presentation while still allowing text-based browsers to display properly formatted text. 5. Added several examples, some from Neil Walker (thanks, Neil!), some from me (Frédéric BONNET). -------- 01/11/1999 tcLex version 1.1b2 -------- 1. Added SafeTcl entry point (Tclex_SafeInit). 2. Corrected bug that seemed to occur only on some Unix systems (eg. SGI and Solaris) but potentially affected others as well. This caused some lexers to be incorrectly reported as inactive even when returned by [lexer current]. The source of a bug was a missing lower bound in the lexer state deallocator (StateDelete) that caused subsequent states to be given a negative index, causing the "inactive lexer" error. Bug reported by Claude BARRAS and Neil Walker. 3. Corrected bug in the modified Tcl8.0 regexp engine that caused newlines to be treated as any characters even in line-sensitive mode, when used with * or +. Bug reported by Neil Walker. 4. Improved handling of ^$ in line-sensitive mode under Tcl8.0 so that they behave the same as under Tcl8.1. 5. Corrected bug with empty string match handling: some actions were called twice, once for the matched string and once for an empty string at the end of the previous one. 6. Fixed Unix warnings previously reported by Claude BARRAS but forgotten in the previous version: the struct regexec_state in RE80.c (modified Tcl8.0 regexp engine) was used before defined. This warning was silent under Windows (too low warning level?). -------- 04/04/1999 tcLex version 1.1 final -------- 1. Corrected minor typo in RE80.c: in function findChar, parameter c was declared as int* instead of int. This had no influence (it got cast to a char anyway) but generated warnings with some compilers (not mine unfortunately )-: Reported by Volker Hetzer . 2. TcLex is now intended to be linked against Tcl8.0.4 (or higher patchlevel) or Tcl8.1b2. On the latter, tcLex is configured by default to use the new stubs facility. Only minor code modifications were needed. Tcl8.1b1 isn't supported anymore. 3. Removed compatibility macros from tcLexInt.h now that the old functions are back in Tcl8.1b2. 4. Fixed major bug occuring with longest-prefered matching lexers. When several rules matched the same number of characters, the last defined rule was chosen instead of the first one, due to a bad comparison operator ('<' was used instead of '<=' in RuleTry). This broke the "pascal" example. 5. Reformatted the code so that it uses 4 spaces indentations instead of 2, to better conform with Tcl C coding conventions. This is rather cosmetic but makes the code a bit more readable. -------- 04/30/1999 tcLex version 1.1.1 -------- 1. TcLex is now intended to be linked against Tcl8.0.4 (or higher patchlevel) or Tcl8.1b3. Tcl8.1b2 isn't supported anymore. 2. Removed redefinition of TclUtfToUniCharDString and TclUniCharToUtfDString that were needed by stub-enabled Tcl8.1b2, now that Tcl_UtfToUniCharDString and Tcl_UniCharToUtfDString are publicly available in Tcl8.1b3. 3. Removed the hack needed by TclRegCompObj not being exported by stub-enabled Tcl8.1b2. Tcl8.1b3 now exports the public Tcl_GetRegExpFromObj which does the same thing. 4. Fixed regexp inconsistency between Tcl8.0 and Tcl8.1 with line-sensitive matching. Regexps with negated ranges (eg. [^a]) could span multiple lines under Tcl8.0 but couldn't under Tcl8.1 (the right behavior). 5. Cleaned up the modified regexp exec code and proposed it as a patch to the Tcl core. 6. Rewrote arguments parsing code using Tcl_GetIndexFromObj to use symbolic constants rather than integer indices. 7. Added links to Neil Walker's tcLex page (thanks Neil!) from the doc. -------- 04/25/1999 tcLex version 1.1.2 -------- 1. Corrected bug in line-sensitive matching. This bug was introduced by the above change #4, and was located in the negated range processing code in certain cases. -------- 06/24/1999 tcLex version 1.1.3 -------- 1. Corrected major bug with Tcl 8.1.1. The new regexp caching scheme introduced by Tcl 8.1.1 conflicted with the way tcLex stored compiled regexps. The regexp handling code has been completely reworked. Bug reported by Claude BARRAS. 2. Added URL to Scriptics' regexp-HOWTO in the doc (http://www.scriptics.com/support/howto/regexp81.html). -------- 07/20/1999 tcLex version 1.1.4 -------- 1. Corrected major bug with Tcl 8.1. The functions BufferNotStarving() and BufferAtEnd() mixed character and byte indices. which resulted in string overflows. Bug reported by Neil Walker. It is surprising that this bug did not show up earlier because the string overflows occured eventually in virtually any case, however it only crashed tcLex in very precise cases (hard to reproduce on Windows). -------- 09/03/1999 tcLex version 1.2a1 -------- 1. Added support for Tcl8.2 and higher. Now that Tcl8.2's regexp engine provides the features needed by tcLex (ie string overrun detection and matching at the beginning of the string), tcLex no longer needs a patched version of this engine. This makes the code much simpler as it now uses standard Tcl library functions. Added file RE82.c 2. The input string is now stored as a Tcl_Obj instead of a Tcl_DString. Reworked the related code in consequence (RuleTry(), RuleExec(), RuleGetRange()). Under Tcl8.0, use the obj's 8bits string. Under Tcl8.2, use the obj's Unicode (not UTF-8) string (actually, only pass the string obj to the Tcl library procs, which in turn use the obj's Unicode representation). Under Tcl8.1, added a Unicode object type and related procs (eg. Tcl_NewUnicodeObj(), Tcl_GetUnicode() and Tcl_GetCharLength()) to be source compatible with Tcl8.2. These new Unicode objects use Unicode Tcl_DStrings as their internal rep. 3. Modified "lexer begin initial" behavior so that it empties the conditions stack rather than pushing the "initial" condition on top of it. This makes some lexers easier to write (eg. Neil Walker's flex examples). tclex-1.2a1.orig/license.txt100644 0 0 5653 6763747176 14156 0ustar rootroot[file adaptated from the Tcl license] This software is copyrighted by Frederic BONNET . The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. These include earthquakes, volcanoes, tsunami, traffic jams, stupid TV programs, brain damage resulting of attempts to read and understand: the code, my bad english, the present license, or all-caps legalese. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. GOVERNMENT USE: If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are acquiring the software on behalf of the Department of Defense, the software shall be classified as "Commercial Computer Software" and the Government shall have only "Restricted Rights" as defined in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license. SPECIAL NOTES (the beerware clause): This software is freeware. However, it also falls under the beerware special category. That is, if you find this software useful, or use it every day, or want to grant me for my modest contribution to the Tcl community, feel free to send me a beer from one of your local brewery. My preference goes to Belgium abbey beers, Corona mexican cerveza, and irish stout (Guiness for strength!), but I also appreciate exotic, rare or original beers from everywhere (note: I live in France), especialy those with a nice packaging or original taste. tclex-1.2a1.orig/LISEZMOI.txt100644 0 0 27204 6763747176 14003 0ustar rootroot************************************************** tcLex : un générateur d'analyseur lexical pour Tcl ************************************************** INTRODUCTION tcLex est une extension Tcl servant à générer des lexeurs (analyseur lexical). Elle est inspirée des commandes Unix et GNU lex et flex, qui sont des "outils pour générer des programmes effectuant des 'pattern-matching' sur du texte". tcLex est très similaire à ces programmes, à part qu'elle utilise la philosophie et la syntaxe de Tcl, tandis que les autres utilisent leur propre syntaxe et sont utilisés en conjonction avec le langage C. Les personnes habituées à lex ou flex devraient donc se sentir familier avec tcLex. tcLex est une petite extension (la version compilée pour Windows fait environ 20ko, et le source environ 150ko), parce qu'il utilise au maximum la bibliothèque Tcl. Cependant, la présente n'utilise plus le code de regexp de Tcl, mais une version modifiée est maintenant incluse dans tcLex, ce qui la rend légèrement plus grosse (de quelques ko). tcLex devrait fonctionner avec Tcl 8.0 et ultérieurs. tcLex ne marchera JAMAIS avec des versions plus anciennes, parce qu'elle utilise le nouveau système d'"objets" de Tcl 8.0 pour des raisons de performance. Les caractéristiques les plus intéressantes sont : * support multi-plateforme, grâce à Tcl. Bien qu'elle ait été développée sur Windows et testée sur Windows et Unix, elle devrait fonctionner sur d'autres plateformes si une version de Tcl existe sur celles-ci. Les plateformes supportées par Tcl sont Windows 95/NT, Unix (Linux, Solaris...) et Macintosh. D'autres plateformes sont VMS, OS/2, NeXTStep, Amiga... * contrairement à lex et flex, qui génèrent uniquement des lexeurs statiques écrits en C et destinés à être compilés, tcLex génère dynamiquement des commandes Tcl qui peuvent être utilisées comme d'autes commandes C ou des procédures Tcl à partir de scripts Tcl ou de programmes C. * elle utilise les expressions régulières de Tcl. Ce qui signifie que vous n'avez pas à apprendre un nouveau langage de regexp. * elle fonctionne avec les "namespaces" de Tcl * les commandes générées peuvent être utilisées en une passe ou incrémentallement, car elles maintiennent des informations d'état. Ainsi, plusieurs instances du même lexeur (par exemple un parseur HTML) peuvent tourner simultanément dans des contextes distincts et maintenir des états également distincts (variables locales...). Les lexeurs n'ont pas besoin d'être spécialement conçus pour être utilisés incrémentallement, le même lexeur peut être utilisé en une passe ou incrémentallement de façon transparente. Cette caractéristique est particulièrement utile lors du traitement de texte issu d'un fichier ou d'une socket Internet (pages Web par exemple), quand les données ne sont pas nécessairement disponibles au début du traitement. VERSION La version actuelle de tcLex est 1.2a1. Le suffixe "a1" signifie "alpha 1", ce qui veut dire que cette version est une version incomplète par rapport aux fonctions de la future 1.2, qui étend et corrige la précédente. Le fichier changements.txt décrit les changements effectués entre la première version de tcLex et la version actuelle. Bien que ce soit une version alpha, elle apporte plus de corrections de bugs que de nouveaux ;-). Dans ce cas, alpha signifie que de nombreuses fonctions prévues ne sont pas encore implémentées, et la documentation peut être incomplête. La plupart des informations utiles sont dans le fichier changements.txt. Le fichier AFAIRE.txt contiens les fonctions prévues qui ne sont pas encore implémentées. POURQUOI TCLEX ? Quand j'ai décidé d'écrire tcLex, j'avais besoin d'une façon efficace de parser des fichiers HTML et CSS, dans le but de construire un navigateur Web (un de mes projets à long terme). J'essayais dans ce but d'utiliser les commandes intégrées de Tcl (regexp, regsub...). Bien qu'un parseur HTML basique fut assez simple à écrire, les limites de l'approche classique commencèrent à apparaitre avec CSS. J'avais besoin de limiter le champ d'action des commandes regexp/regsub à des zones spécifiques du texte parsé, selon certaines règles lexicales. Par exemple, la manière classique de transformer un fichier HTML en liste Tcl (pour un traitement plus aisé) est de remplacer (avec "regsub") les séparateurs de balises HTML (<>) avec des délimiteurs de liste Tcl (méthode inaugurée par Stephen Uhler dans sa html_lib), ou par des crochets pour une évaluation ultérieure avec "subst" ou "eval". Les problèmes commencent à apparaitre quand les séparateurs HTML sont utilisés dans les chaines de caractères pour les valeurs d'attributs (par exemple, "=> home"), dans ce cas cette méthode ne marche pas et la liste générée est invalide. De plus, parser des fichiers malformés échouera certainement et génèrera une erreur. A part cela, les performances ne sont pas garanties, et perticulièrement si vous voulez respecter les standards et gérer tous les cas d'erreurs, et aussi parce que plusieurs passes sont nécessaires. J'ai ensuite envisagé d'écrire des extension spécifiques en C pour parser ces fichiers, en utilisant des lexeurs écrits avec lex ou flex, mais le problème est qu'on a besoin d'une extension par type de fichier. De plus, ces parseurs sont statiques et non extensibles, même si leur base est la même. J'ai enfin décidé d'écrire une extension Tcl permettant d'écrire des lexeurs. Elle essaye d'abord de suivre la philosophie et la syntaxe de (f)lex tout en les adaptant à Tcl. Elle utilise ensuite la syntaxe de ligne de commande et les expressions régulières de Tcl, et des scripts Tcl à la place de code C. Elle crée également des commandes Tcl dynamiques au lieu de fichiers C destinés à être compilés. L'idée derrière cela est d'écrire un "lexeur générique" qui serait scriptable et extensible avec Tcl. Ainsi, seule une extension est requise quelle que soit le type de données texte. OU OBTENIR TCLEX Page d'accueil : http://www.multimania.com/fbonnet/Tcl/tcLex/index.htm Fichiers de distribution : - http://www.multimania.com/fbonnet/pub/tcLex12a1.zip (binaires Windows pour Tcl8.0.5, Tcl8.1.1 et Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.tar.gz (sources Windows/Unix pour Tcl8.0.5, Tcl8.1.1 et Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.patch (fichier correctif pour la version 1.1.4) SUPPORT Depuis le 17/11/1998, tcLex dispose d'une liste de diffusion dédiée. Le site Web de cette liste est : http://www.eGroups.com/list/tclex . Pour souscrire a cette liste, envoyez un e-mail à l'adresse suivante : tclex-subscribe@egroups.com . J'essaie également de répondre à tous les messages que les utilisateurs m'envoient concernant tcLex. COMPILER L'EXTENSION Si vous voulez compiler tcLex vous-même, vous devez savoir qu'elle a besoin des sources Tcl pour compiler car elle utilise quelques structures internes. Elle peut être compilée avec Tcl 8.0, 8.1 ou 8.2. * Windows: Des bibliothèques précompilées sont disponibles dans une distribution binaire distincte. Cependant, vous pouvez compiler l'extension vous-même. Allez dans le répertoire "src", éditez le fichier "makefile.vc" pour Microsoft Visual C++ (pas de Borland pour l'instant, des volontaires :-) et éditez les différentes variables pour refléter votre propre installation (compilateur, Tcl...). Ensuite, tapez sur la ligne de commande : nmake -f makefile.vc Une fois la compilation réussie, tapez : nmake -f makefile.vc install Et il copiera les fichiers requis dans un sous-répertoire du répertoire "lib" de Tcl, afin qu'elle puisse être utilisée avec "package require tcLex". * Unix: (Merci à John Ellson pour ces fichiers et instructions) Pour compiler tcLex sur des systèmes Unix, tapez: cd src chmod u+x configure chmod u+x install-sh ./configure make make install Le script de configuration tentera de déduire une variable $PREFIX d'une installation existante de Tcl. Vous pouvez toujours utiliser l'option --prefix=... si tclsh n'est pas dans votre $PATH, ou si différents tclsh sont installés. Le Makefile généré utilise le fichier $PREFIX/lib/tclConfig.sh laissé par la compilation de Tcl pour la plupart de ses paramètres de configuration. Le Makefile généré crée un fichier a pkgIndex.tcl compatible avec Tcl7.6 et ultérieurs. * MacOS: Il n'y a pas de makefile pour cette plateforme pour l'instant, cependant la compilation devrait être facile, il n'y a que deux fichiers C. Les seules choses dont le source a besoin sont les variables TCLEX_VERSION, BUILD_tcLex et USE_TCL_STUBS (si applicable) définies à la compilation. Vous pouvez jeter un oeil au makefile pour Windows. INSTALLATION DES BINAIRES Windows: Trois bibliothèques précompilées sont fournies avec la distribution binaire, nommés tcLex80.dll, tcLex81.dll et tcLex82.dll, respectivement pour Tcl 8.0, 8.1 et 8.2. Copiez-les simplement avec le fichier pkgIndex.tcl dans un sous-répertoire de votre choix dans le répertoire "lib" de Tcl. MacOS, Unix: Pas de distribution binaire pour l'instant. DOCUMENTATION Le répertoire doc contient la documentation de tcLex dans des fichiers HTML. La documentation est disponible en anglais (sous-rép en) et français (sous-rép fr). Lisez-la attentivement. CONTACT, COMMENTAIRES, BUGS, etc. * Veuillez s'il vous plait lire la license (fichier license.txt, en anglais uniquement), et spécialement la "beerware clause" ;-) traduite ici : " Ce logiciel est freeware. Cependant, il fait également partie de la catégorie spéciale "beerware". C'est-à-dire que si vous trouvez ce logiciel utile, ou que vous l'utilisez tous les jours, ou voulez me remercier pour ma modeste condition à la communauté Tcl, vous pouvez m'envoyer une bière d'une vos brasseries locales. Ma préférence va aux bières d'abbaye de Belgique, à la cerveza mexicaine Corona, et à la stout irlandaise (Guiness for strength!), mais j'apprécie aussi les bières exotiques, rares ou originales d'un peu partout (note : je vis en France), et particulièrement celles avec un emballage ou un goût originaux. " * Veuillez envoyer les bugs ou vos commentaires à . Les rapports de bugs et le retour utilisateur sont les seules façons que j'envisage pour améliorer et corriger tcLex. Si personne n'utilise tcLex je ne vois aucune raison pourquoi je devrais améliorer cette extension sauf pour mon usage personnel (pour lequel tcLex est plus qu'adéquat pour le moment) * Même si vous n'avez aucun commentaire, j'apprécierais que chaque utilisateur de tcLex m'envoie un mail à l'adresse mentionnée ci-dessus. Cela me donne des informations sur le nombre d'utilisateurs qui est une part importante de ma motivation. Je n'utiliserai pas votre adresse pour vous envoyer des messages non sollicités, du spam, ou la vendre à des "télémarquetteurs", mais uniquement pour garder une trace des utilisateurs. * Si vous trouvez un bug, un court script Tcl qui le met en évidence serait très utile, ou encore mieux, compilez avec debugging et spécifiez où il a planté dans ce script Tcl. POUR CONTRIBUER Comme j'utilise uniquement MS Visual C++ sous Windows, j'apprécierai des contributions de gens fournissant des makefiles pour d'autres compilateurs, des fichiers GNU autoconf, ou mieux, des extensions compilée pour des distributions binaires sur Macintosh et Unix (particulièrement Linux et Solaris). J'aimerai aussi réunir tous les lexeurs faits avec tcLex en un seul endroit (une page Web par exemple) comme une ressource de valeur pour la communauté Tcl. Des contributions intéressantes seraient par exemple des parseurs pour HTML, XML, CSS, JavaScript et d'autres langages du Web. tclex-1.2a1.orig/README.txt100644 0 0 22673 6763747176 13512 0ustar rootroot******************************************* tcLex: a lexical analyzer generator for Tcl ******************************************* tcLex is a lexer (lexical analyzer) generator extension to Tcl. It is inspired by Unix and GNU lex and flex, which are "tools for generating programs that perform pattern-matching on text". tcLex is very similar to these programs, except it uses Tcl philosophy and syntax, whereas the others use their own syntax and are used in conjunction with the C language. People used to lex or flex should then feel familiar with tcLex. tcLex is a small extension (the Windows compiled version is about 20kb, and the source is about 150kb), because it extensively uses the Tcl library. However, the current doesn't use Tcl's regexp code anymore but a patched version is now included in tcLex, which makes it slightly bigger (by a few KB). tcLex should work with Tcl 8.0 and later. tcLex will NEVER work with earlier versions, because it uses Tcl 8.0's "object" system for performance. The most interesting features are: * cross-platform support, thanks to Tcl. Though it has been developped on Windows and tested on Windows and Unix only, it should work on other platforms as long as Tcl exists on these platforms. Supported Tcl platforms are Windows 95/NT, Unix (Linux, Solaris...) and Macintosh. Other platforms are VMS, OS/2, NeXTStep, Amiga... * unlike lex and flex, which only generate static lexers written in C and intended to be compiled, tcLex dynamically generates Tcl commands that can be used like other C commands or Tcl procedures from within Tcl scripts or C programs. * it uses Tcl regular expressions. That means you don't have to learn another regexp language. * it works with Tcl namespaces * the generated lexer commands can be used in one pass or incrementally, because they maintain state information. That way, several instances of the same lexer (eg a HTML parser) can run at the same time in distinct call frames and maintain distinct states (local variables...). Lexer need not be specially designed in order to be used incrementally, the same lexer can transparently be used in one pass or incrementally. This feature is especially useful when processing text from a file or an Internet socket (Web pages for example), when data is not necessarily available at the beginning of the processing. VERSION The current tcLex version is 1.2a1. The suffix "a1" means "alpha 1", meaning that this version is the first fature-incomplete release of the future 1.2, extending and correcting the previous 1.1. The file changes.txt describes the changes made between the first version of tcLex and the current version. Although it is alpha software, it brings more bugs corrections than new ones ;-). In this case, alpha means that many planned features are not yet implemented, and documentation may be incomplete. Most of the useful info is in the file changes.txt. The file TODO.txt contains planned features that needs to be implemented. WHY TCLEX? When I decided to write tcLex, I needed an efficient way to parse HTML and CSS files, in order to build a Web browser (a long term project of mine). I was trying to use the built-in Tcl commands (regexp, regsub...) to achieve that. Although a basic HTML parser was quite simple to write, the limitations of the classic approach began to appear with CSS. Basically, I needed to limit the scope of the regexp/regsub commands to specific parts of the parsed text, depending on lexical rules. For example, the classic way of transforming a HTML file into a Tcl list (for easier processing) is to replace (with "regsub") the HTML tag delimiters (<>) with Tcl list delimiters (Stephen Uhler does it this way in his html_lib), or with brackets for further evaluation with "subst" or "eval". The problems begin to arise when HTML delimiter characters are used within strings for attribute values (for example, "=> home"), in this case this method doesn't work and the generated list is invalid. Besides, parsing misformed files will certainly fail and generate an error. Apart from that, performance is not guaranteed, especially if you want to respect the standards and handle all the error cases, and also because you need several passes. I then considered writing specific C extensions for parsing these files, using lexers written with lex or flex, but the problem is that you need one extension for each file type. Besides, these parsers are static and not extensible, even though their basics are the same. I finally decided to write a Tcl extension for writing lexers. It first tries to follow the (f)lex philosophy and syntax while adapting them to Tcl. It then uses Tcl's command line syntax and regular expressions, and Tcl scripts instead of C code. It also build dynamic Tcl commands instead of C files intended to be compiled. The idea behind that is to write a "generic lexer" that would be scriptable and extensible with Tcl. Thus, only one extension is needed whatever the text data type can be. WHERE TO GET TCLEX Home Page: http://www.multimania.com/fbonnet/Tcl/tcLex/index.en.htm Distribution files: - http://www.multimania.com/fbonnet/pub/tcLex12a1.zip (Windows binaries for Tcl8.0.5, Tcl8.1.1 and Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.tar.gz (Windows/Unix sources for Tcl8.0.5, Tcl8.1.1 and Tcl8.2) - http://www.multimania.com/fbonnet/pub/tcLex1.2a1.patch (patch file for version 1.1.4) SUPPORT Since 11/17/1998, tcLex has a dedicated mailing list. The Web site for this list is: http://www.eGroups.com/list/tclex . To subscribe, send a e-mail to the following address: tclex-subscribe@egroups.com . Also, I try to answer all the mails users send me regarding tcLex. BUILDING THE EXTENSION If you want to compile tcLex yourself, you must know that it needs the Tcl source to compile because it makes use of some internal structures. It will compile with Tcl 8.0, 8.1 or 8.2. * Windows: Precompiled libraries are available in a separate binary distribution. However, you can compile the extension yourself. Go to the "src" directory of the source distribution, edit the file "makefile.vc" for Microsoft Visual C++ (no Borland file yet, volunteers :-) and edit the different variables to reflect your own installation (compiler, Tcl...). Next, type on the command line: nmake -f makefile.vc Once the compilation has succeeded, type: nmake -f makefile.vc install And it will copy the necessary files in a subdirectory of the Tcl "lib" dir, so that it can be used with "package require tcLex" * Unix: (Thanks to John Ellson for these files and instructions) To build tcLex on Unix systems, type: cd src chmod u+x configure chmod u+x install-sh ./configure make make install The configure script will attempt to deduce a $PREFIX from an existing Tcl installation. You may still want to use --prefix=... if tclsh is not in your $PATH, or if you have multiple tclsh installed. The generated Makefile uses the file $PREFIX/lib/tclConfig.sh that was left by the make of Tcl for most of its configuration parameters. The Makefile generates a pkgIndex.tcl file that is compatible with Tcl7.6 and later. * MacOS: There are no makefiles for this platform yet, however compilation should be easy, there are only two C files. The only things the source needs are the variables TCLEX_VERSION, BUILD_tcLex and USE_TCL_STUBS (if appliable) being defined at compile time. You can take a look at the makefile for Windows. BINARY INSTALLATION Windows: Three precompiled libraries are provided in the binary distribution, named tcLex80.dll, tcLex81.dll and tcLex82.dll, respectively for Tcl 8.0, 8.1 and 8.2. Just copy them and the file pkgIndex.tcl in a sub-directory of your choice in the Tcl "lib" dir. MacOS, Unix: No binary distribution for now. DOCUMENTATION The directory doc contains tcLex documentation in HTML files. The documentation is available in english (subdir en) and french (subdir fr). Read it carefully. CONTACT, COMMENTS, BUGS, etc. * Please read the license (file license.txt), and especially the "beerware clause" ;-) * Please send any bugs or comments to . Bug reports and user feedback are the only way I intend to improve and correct tcLex. If no one uses tcLex, I see no reason why I should improve this extension except for my own use (for which tcLex is more than adequate for now). * Even if you have no comment, I'd appreciate that every tcLex user send me a mail to the address mentioned above. That gives me information about the number of users which is an important part of my motivation. I won't use your address to send you unsollicited email, spam, or sell it to telemarketers, but only to keep track of users. * If you find a bug, a short piece of Tcl that exercises it would be very useful, or even better, compile with debugging and specify where it crashed in that short piece of Tcl. TO CONTRIBUTE Since I only use MS Visual C++ on Windows, I'd appreciate contributions from people providing other compilers' makefiles (eg Borland), GNU autoconf's, or even better, compiled extensions for binay distribution on Macintosh and Unix (esp. Linux and Solaris). I'd also like to gather all the lexers made with tcLex in a single place (a Web page for example) as a valuable resource for the Tcl community. Interesting contributions would be for example parsers for HTML, XML, CSS, JavaScript and other Web languages. tclex-1.2a1.orig/TODO.txt100644 0 0 2602 6763747176 13270 0ustar rootrootTODO list for tcLex, last updated 07/20/1999: (unsorted) - Add various input types: string, variable, file, channel. Add corresponding switches to eval and start. - Add multiple input buffers, possibly using the following syntax: # create a buffer # equivalent to yy_create_buffer # original buffer is named "initial" or {} # option could be -file, -channel... default to string buffer create ?option? # switch to buffer # equivalent to yy_switch_to_buffer buffer switch # query the buffer list buffer list # return the current buffer buffer ?current? # delete a buffer buffer delete - Add special "eof" condition necessary with multiple buffers. - Add -append flag to continue and finish, to append new chars to the current input string rather than replacing it. - Add introspection and debugging features such as actions traces, info-like command, ... - Finish the documentation - Create Metrowerks CodeWarrior Pro 4 project file for Macintosh (and maybe also for Windows, for cross-platform development), and provide Macintosh binaries - Maybe add an option to lexers to disable the conditions stack (eg. -nocs, for "no conditions stack"), for a better (f)lex compatibility. There is no real equivalent to conditions stacks in (f)lex. tclex-1.2a1.orig/src/ 42755 0 0 0 6772444145 12444 5ustar rootroottclex-1.2a1.orig/src/tcLex.c100644 0 0 212277 6763747174 14045 0ustar rootroot/* * tcLex.c -- * * This module implements a lexer (or lexical analyzer) command * for Tcl. A lexer is used to parse text for processing with * the Tcl language. It is intended to ease the task of people * already using Tcl for regexp-based text processing. * * Inspired by Unix and GNU lex and flex * * Copyright (c) 1998 Frédéric BONNET * * See the file "license.txt" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #include "tcLex.h" #include "tcLexInt.h" #include "tcLexRE.h" #include /******************************************************* * * * Conditions management functions * * * *******************************************************/ /* *-------------------------------------------------------------- * * ConditionIndex -- * * This procedure returns the index of a lexer's condition from * a string. * * Results: * 0 for the initial condition; * -1 if the condition doesn't exist; * Else a positive integer corresponding to an index. * * Side effects: * None. * *-------------------------------------------------------------- */ static int ConditionIndex(lexer, string) TcLex_Lexer *lexer; char *string; /* Condition to search for */ { int i; char *cond; /* * Initial condition */ if ( strcmp(string, "initial") == 0 || strcmp(string, "0") == 0) { return 0; } /* * Search for the condition */ for (i=0; i < lexer->nbInclusiveConditions+lexer->nbExclusiveConditions; i++) { cond = Tcl_GetStringFromObj(lexer->conditions[i], NULL); if (strcmp(string, cond) == 0) { return i+1; } } /* * None found, error */ return -1; } /* *-------------------------------------------------------------- * * ConditionFromIndex -- * * This procedure returns the condition from its index. * * Results: * A Tcl_Obj* containing the condition's string, or NULL if * the condition doesn't exist. * * Side effects: * None. * *-------------------------------------------------------------- */ static Tcl_Obj * ConditionFromIndex(lexer, index) TcLex_Lexer *lexer; int index; /* Index of the condition */ { /* * Sanity check */ if ( index < 0 || index > lexer->nbInclusiveConditions+lexer->nbExclusiveConditions) return NULL; /* * Initial condition */ if (index == 0) return InitialCond; return lexer->conditions[index-1]; } /* *-------------------------------------------------------------- * * ConditionIsExclusive -- * * Check if the condition (given its index) is exclusive. * * Results: * -1 if the condition doesn't exist; * 0 if the condition is inclusive; * 1 if the condition is inclusive. * * Side effects: * None. * *-------------------------------------------------------------- */ static int ConditionIsExclusive(lexer, index) TcLex_Lexer *lexer; int index; /* Index of the condition */ { /* * Sanity check */ if ( index < 0 || index > lexer->nbInclusiveConditions+lexer->nbExclusiveConditions) return -1; if (index <= lexer->nbInclusiveConditions) return 0; return 1; } /* *-------------------------------------------------------------- * * ConditionCurrent -- * * Return the current condition, ie the top of the stack. * * Results: * A standard Tcl result. * * Side effects: * None. * *-------------------------------------------------------------- */ int ConditionCurrent(interp, lexer) Tcl_Interp *interp; TcLex_Lexer *lexer; { TcLex_State *statePtr = lexer->states[lexer->curState]; if (statePtr->conditionsStackLength == 0) Tcl_SetObjResult(interp, InitialCond); else Tcl_SetObjResult(interp, ConditionFromIndex(lexer, statePtr->conditionsStack[statePtr->conditionsStackLength-1])); return TCL_OK; } /******************************************************* * * * State management functions * * * *******************************************************/ /* *-------------------------------------------------------------- * * StateNew -- * * Create a new state for the given lexer, associated with the * given string. * * Results: * The index of the newly created state. * * Side effects: * The lexer's array is modified. * *-------------------------------------------------------------- */ static int StateNew(lexer, string) TcLex_Lexer *lexer; Tcl_Obj *string; /* String being lexed in the new state */ { int i, n; /* Index of the new state */ TcLex_State *statePtr; /* Newly created state */ /* * If states already exist... */ if (lexer->states) { /* * Search for a free slot in the array */ for (n=0; n < lexer->nbStates; n++) if (!lexer->states[n]) goto init; /* * No slot found, so grow the array */ n = lexer->nbStates++; lexer->states = (TcLex_State **)Tcl_Realloc((char *)lexer->states, sizeof(TcLex_State *) * lexer->nbStates); } else { /* * Create one slot in the array */ lexer->nbStates = 1; n = 0; lexer->states = (TcLex_State **)Tcl_Alloc(sizeof(TcLex_State *) * lexer->nbStates); } init: /* * Initialize the state */ statePtr = lexer->states[n] = (TcLex_State *)Tcl_Alloc(sizeof(TcLex_State)); statePtr->conditionsStack = NULL; statePtr->conditionsStackLength = 0; statePtr->lastMatched = -1; statePtr->bFailed = Tcl_Alloc(lexer->nbRules); for (i=0; inbRules; i++) statePtr->bFailed[i] = 0; statePtr->inputBuffer.chars = NULL; StateSetString(lexer, n, string); statePtr->inputBuffer.index = 0; statePtr->inputBuffer.bMatchedEmpty = 0; statePtr->currentBuffer = &statePtr->inputBuffer; statePtr->bRejected = 0; statePtr->startIndices = statePtr->endIndices = NULL; statePtr->pendingResult = NULL; return n; } /* * Tcl8.1 compatibily procs: Unicode object type. * This object uses a Unicode string in a Tcl_DString as their * internal representation */ #if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1) Tcl_FreeInternalRepProc FreeUnicode; Tcl_DupInternalRepProc DupUnicode; Tcl_UpdateStringProc UpdateUnicode; Tcl_SetFromAnyProc SetUnicodeFromAny; Tcl_ObjType UnicodeObjType = { "unicode", FreeUnicode, /* freeIntRepProc */ DupUnicode, /* dupIntRepProc */ UpdateUnicode, /* updateIntRepProc */ SetUnicodeFromAny /* setFromAnyProc */ }; void FreeUnicode(objPtr) Tcl_Obj *objPtr; { register Tcl_DString *string = (Tcl_DString *) objPtr->internalRep.otherValuePtr; /* Free the DString */ Tcl_DStringFree(string); Tcl_Free((char *) string); } void DupUnicode(srcPtr, dupPtr) Tcl_Obj *srcPtr; Tcl_Obj *dupPtr; { register Tcl_DString *srcString = (Tcl_DString *) srcPtr->internalRep.otherValuePtr; register Tcl_DString *dupString; /* Duplicate the DString */ dupString = (Tcl_DString *) Tcl_Alloc(sizeof(Tcl_DString)); Tcl_DStringInit(dupString); Tcl_DStringAppend(dupString, Tcl_DStringValue(srcString), Tcl_DStringLength(srcString)); dupPtr->internalRep.otherValuePtr = (char *) dupString; dupPtr->typePtr = &UnicodeObjType; } void UpdateUnicode(objPtr) Tcl_Obj *objPtr; { register Tcl_DString *string = (Tcl_DString *) objPtr->internalRep.otherValuePtr; Tcl_DString strUtf; /* * Set the UTF string from the internal Unicode DString */ /* Generate an UTF representation in a DString */ Tcl_DStringInit(&strUtf); Tcl_UniCharToUtfDString((Tcl_UniChar *) Tcl_DStringValue(string), Tcl_DStringLength(string)/sizeof(Tcl_UniChar), &strUtf); /* Allocate and fill the UTF string */ objPtr->length = Tcl_DStringLength(&strUtf); objPtr->bytes = Tcl_Alloc((unsigned) objPtr->length + 1); strcpy(objPtr->bytes, Tcl_DStringValue(&strUtf)); Tcl_DStringFree(&strUtf); } int SetUnicodeFromAny(interp, objPtr) Tcl_Interp *interp; Tcl_Obj *objPtr; { register Tcl_ObjType *oldTypePtr = objPtr->typePtr; register Tcl_DString *string; /* * Free the old internalRep before setting the new one. */ if ((oldTypePtr != NULL) && (oldTypePtr->freeIntRepProc != NULL)) { oldTypePtr->freeIntRepProc(objPtr); } /* Set the internal Unicode string from the UTF string */ string = (Tcl_DString *) Tcl_Alloc(sizeof(Tcl_DString)); Tcl_DStringInit(string); Tcl_UtfToUniCharDString(objPtr->bytes, objPtr->length, string); objPtr->internalRep.otherValuePtr = (char *) string; objPtr->typePtr = &UnicodeObjType; return TCL_OK; } int Tcl_GetCharLength(objPtr) Tcl_Obj *objPtr; { register Tcl_DString *string; if (objPtr->typePtr != &UnicodeObjType) { SetUnicodeFromAny(NULL, objPtr); } string = (Tcl_DString *) objPtr->internalRep.otherValuePtr; return Tcl_DStringLength(string)/sizeof(Tcl_UniChar); } Tcl_UniChar * Tcl_GetUnicode(objPtr) Tcl_Obj *objPtr; { register Tcl_DString *string; if (objPtr->typePtr != &UnicodeObjType) { SetUnicodeFromAny(NULL, objPtr); } string = (Tcl_DString *) objPtr->internalRep.otherValuePtr; return (Tcl_UniChar *) Tcl_DStringValue(string); } Tcl_Obj * Tcl_NewUnicodeObj(unicode, numChars) Tcl_UniChar *unicode; int numChars; { register Tcl_Obj *objPtr; register Tcl_DString *string; objPtr = Tcl_NewObj(); objPtr->bytes = NULL; string = (Tcl_DString *) Tcl_Alloc(sizeof(Tcl_DString)); Tcl_DStringInit(string); Tcl_DStringAppend(string, (char *) unicode, numChars*sizeof(Tcl_UniChar)); objPtr->internalRep.otherValuePtr = (char *) string; objPtr->typePtr = &UnicodeObjType; return objPtr; } #endif /* *-------------------------------------------------------------- * * StateSetString -- * * Given its index, modify a lexer state's string. * * Results: * None * * Side effects: * The state is modified. * *-------------------------------------------------------------- */ static void StateSetString(lexer, n, string) TcLex_Lexer *lexer; int n; /* Index of the state */ Tcl_Obj *string; /* New string being lexed */ { TcLex_State *statePtr = lexer->states[n]; if (statePtr->inputBuffer.chars) Tcl_DecrRefCount(statePtr->inputBuffer.chars); statePtr->inputBuffer.chars = string; Tcl_IncrRefCount(statePtr->inputBuffer.chars); } /* *-------------------------------------------------------------- * * StateGetString -- * * Given its index, modify a lexer state's string. * * Results: * None * * Side effects: * The state is modified. * *-------------------------------------------------------------- */ static Char * StateGetString(lexer, n, lengthPtr) TcLex_Lexer *lexer; int n; /* Index of the state */ int *lengthPtr; /* Length of string */ { TcLex_State *statePtr = lexer->states[n]; #if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) return Tcl_GetStringFromObj(statePtr->currentBuffer->chars, lengthPtr); #else if (lengthPtr) *lengthPtr = Tcl_GetCharLength(statePtr->currentBuffer->chars); return Tcl_GetUnicode(statePtr->currentBuffer->chars); #endif } /* *-------------------------------------------------------------- * * StateDelete -- * * Delete a state given its index. * * Results: * None * * Side effects: * The lexer's array is modified. * *-------------------------------------------------------------- */ static void StateDelete(lexer, n) TcLex_Lexer *lexer; int n; /* Index of the state */ { TcLex_State *statePtr = lexer->states[n]; int nb; /* * Free the state's structures */ Tcl_Free((char*)statePtr->conditionsStack); Tcl_Free((char*)statePtr->bFailed); Tcl_DecrRefCount(statePtr->inputBuffer.chars); Tcl_Free((char*)statePtr->startIndices); Tcl_Free((char*)statePtr->endIndices); if (statePtr->pendingResult) Tcl_DecrRefCount(statePtr->pendingResult); lexer->states[n] = NULL; /* * Modify the states array: delete the upper empty elements */ nb = lexer->nbStates; while (nb && !lexer->states[nb-1]) /* Search for nonempty elements */ nb--; /* at the end of the array. */ if (nb != lexer->nbStates) { /* If any, shrink the array. */ lexer->states = (TcLex_State **)Tcl_Realloc((char *)lexer->states, sizeof(TcLex_State *) * lexer->nbStates); lexer->nbStates = nb; } } /******************************************************* * * * Lexer management functions * * * *******************************************************/ /* *-------------------------------------------------------------- * * LexerDelete -- * * This procedure deletes a TcLex_Lexer structure. * * Results: * None. * * Side effects: * Tcl_Obj objects owned by the structure are freed. * *-------------------------------------------------------------- */ void LexerDelete(lexer) TcLex_Lexer *lexer; { int i; /* * Free conditions */ if (lexer->conditions) { for (i=0; i < lexer->nbInclusiveConditions+lexer->nbExclusiveConditions; i++) { Tcl_DecrRefCount(lexer->conditions[i]); } Tcl_Free((char *)lexer->conditions); } /* * Free active rules */ for (i=0; i < lexer->nbInclusiveConditions+lexer->nbExclusiveConditions+1; i++) { Tcl_Free((char *)lexer->activeRules[i]); } Tcl_Free((char *)lexer->activeRules); /* * Free result variable */ if (lexer->resultVariable) Tcl_DecrRefCount(lexer->resultVariable); /* * Free args */ if (lexer->args) Tcl_DecrRefCount(lexer->args); /* * Free scripts */ if (lexer->preScript) Tcl_DecrRefCount(lexer->preScript); if (lexer->midScript) Tcl_DecrRefCount(lexer->midScript); if (lexer->postScript) Tcl_DecrRefCount(lexer->postScript); /* * Free rules */ if (lexer->rules) { for (i=0; i < lexer->nbRules; i++) { RuleFree(lexer->rules+i); } Tcl_Free((char *)lexer->rules); } /* * Free states */ if (lexer->states) { TcLex_State *statePtr; for (i=0; i < lexer->nbStates; i++) { if (statePtr = lexer->states[i]) { Tcl_Free((char*)statePtr->conditionsStack); Tcl_Free((char*)statePtr->bFailed); Tcl_DecrRefCount(statePtr->inputBuffer.chars); Tcl_Free((char*)statePtr->startIndices); Tcl_Free((char*)statePtr->endIndices); if (statePtr->pendingResult) Tcl_DecrRefCount(statePtr->pendingResult); Tcl_Free((char *)statePtr); } } Tcl_Free((char *)lexer->states); } /* * Free lexer */ Tcl_Free((char *)lexer); return; } /* *-------------------------------------------------------------- * * LexerNew -- * * This procedure creates a new TcLex_Lexer structure. * * Results: * A pointer to the newly allocated TcLex_Lexer, or NULL * if failed. * * Side effects: * Some Tcl_Obj's are shared by the new structure. * *-------------------------------------------------------------- */ TcLex_Lexer * LexerNew(interp, inclusiveConditions, exclusiveConditions, resultVariable, preScript, midScript, postScript, args, flags, rulec, rulev) Tcl_Interp *interp; Tcl_Obj *inclusiveConditions; Tcl_Obj *exclusiveConditions; Tcl_Obj *resultVariable; Tcl_Obj *preScript; Tcl_Obj *midScript; Tcl_Obj *postScript; Tcl_Obj *args; int flags; int rulec; Tcl_Obj *CONST *rulev; { TcLex_Lexer *lexer; int i, j, k, l; int nbRules; int nbConds; int firstScript; /* Used to handle script */ Tcl_Obj *firstConditions; /* and conditions shortcuts */ int cc; /* Used to get */ Tcl_Obj **cv; /* list elements */ char ruleNb[32]; /* Rule number reported when an * error occurs */ /* * Sanity check */ /* Rule list must be a multiple of 4: