tclex

A lexical analyzer generator for tcl
 
  1
  1 review



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
developed 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.
Latest reviews
4
blueXrider 13 years ago

quite nice