# TECO Regular Expression Engine

This is a regular expression engine, derived from the standalone
[hsrex](https://github.com/garyhouston/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](https://www.tcl-lang.org/man/tcl/TclCmd/re_syntax.html)).
In contrast to [PCRE](https://www.pcre.org/) terex' stack
use cannot grow arbitrarily and it has polynomial worst-case runtime.
terex is the regular expression engine used by the [SciTECO](https://sciteco.fmsbw.de)
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:

* 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_RAW`
  compilation flag.

## TODO

* Hook into the matching algorithm.
  Even though runtime cannot be as catastrophically bad as in pure
  backtracking engines like PCRE, `re_exec()` calls can still be slow
  on extremely large texts.
  The hook allows interruptions.
* 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.

## Building

    make -f Makefile.linux

There is also an Automake file (Makefile.am) for integration into an existing
Autotools build system.
