TECO Regular Expression Engine
This is a regular expression engine, derived from the standalone hsrex library, which is based on Henry Spencer's implementation of advanced regular expressions (ARE) in the Tcl language. This library therefore also provides AREs (see re_syntax). It is a hybrid NFA/DFA design. In contrast to PCRE terex' stack use cannot grow arbitrarily and it has polynomial worst-case runtime. terex is the regular expression engine used by the SciTECO editor and motivated by its needs. It is still kept as a standalone library and may be useful to other projects as well.
Compared to hsrex, this library has the following changes:
- Renamed
re_comp()totere_comp(),re_exec()totere_exec(),re_free()totere_free()andre_error()totere_error()to avoid collisions with BSD's functions from unistd.h. - Native UTF-8 support - no need to convert UTF-8 to UTF-32 first.
You no longer need to compile a special version of the library.
It expects Unicode strings by default unless specifying the
REG_RAWtere_comp()compilation flag. - Support the
REG_ANCHOREDflag fortere_exec(). tere_free()ignores nullifiedregex_tobjects.tere_set_is_interrupted_cb()allows configuring a repeatedly invoked callback. If it returns true (non-null) matching aborts immediately andtere_exec()will returnREG_EINTR.
TODO
- Expose enough API to swap out the regular expression lexer. Useful for custom DSLs like glob patterns or TECO patterns.
- Support splitting the subject string into two halves, so we can preserve the buffer gap when used in SciTECO.
- Check for useful changes in the Tcl codebase.
- Check against a proper regular expression test suite.
At the very least, convert
regtest_terex.shinto an Autotest suite - but then it will work only with Autoconf.
Building
make -f Makefile.linux
There is also an Automake file (Makefile.am) for integration into an existing Autotools build system.
