From bda12e168733451328e39aceb6b2625f6b28e29c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 26 Jun 2026 23:20:37 +0200 Subject: added new project README The original hsrex README has been re-added as README.old. --- README | 55 ------------------------------------------------------- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ README.old | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 55 deletions(-) delete mode 100644 README create mode 100644 README.md create mode 100644 README.old diff --git a/README b/README deleted file mode 100644 index 981a113..0000000 --- a/README +++ /dev/null @@ -1,55 +0,0 @@ - -This is a port to make standalone available the Henry Spencer's Regex Library -from Tcl 8.6a2. - -In the hope that the Tcl developers take this port as the base for their RE -module, great effort was paid to not update the *.c files, sadly it was not -possible. Some *.h files suffered dirty updates for the same reasons. - -To build and test - make - ./regtest_terex.sh - -To rebuild - make clean - make - -To build against the other library uncomment the proper line in the file -regtest_terex.sh and execute again. - # Either this one - $CC -I. -I$H/inc -L. -lterex -o $rgbin $rgsrc - # or this one - #$CC -I. -I$H/inc -L. -lteurex -DREGEX_UTF8 -o $rgbin $rgsrc - -You would like to test with debuging information. Uncomment the proper line in -the Makefile and rebuild. - # Either this one - #CFLAGS = -DREGEX_STANDALONE -fPIC -DREG_DEBUG -g - # Or this one - CFLAGS = -DREGEX_STANDALONE -fPIC -D_NDEBUG -O3 - -Two libraries are provided, libterex.so and libteurex.so. The first one is for -ascii character code and the second one for wide characters. Both libraries -were tested in Linux and Solaris. Compiling and runing in Window$ should be -easy. - -The following entry point where defined in each library: -re_comp() (re_ucomp() for wide char) to compile a RE -re_exec() (re_uexec() for wide char) to parse data against a compiled RE. -regfree() To dispose the memory of a compiled RE. -regerror() Translates error codes to ascii strings. - -It is pretty easy to add support for a regcomp() regexec() front end. That -front end functions should take care of UTF-8 to wide charater conversion, for -instance. - -The regression test script regtest_terex.sh contains an example of how to use -the libraries. It just test cases I was interested on. Adding more use cases to -that script should be easy. - -Send any comments to Walter Waldo - -Enjoy it, - -Walter Waldo. - diff --git a/README.md b/README.md new file mode 100644 index 0000000..f3b39ab --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# 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 and execution 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. diff --git a/README.old b/README.old new file mode 100644 index 0000000..7a823b9 --- /dev/null +++ b/README.old @@ -0,0 +1,55 @@ + +This is a port to make standalone available the Henry Spencer's Regex Library +from Tcl 8.6a2. + +In the hope that the Tcl developers take this port as the base for their RE +module, great effort was paid to not update the *.c files, sadly it was not +possible. Some *.h files suffered dirty updates for the same reasons. + +To build and test + make + ./regtest_hsrex.sh + +To rebuild + make clean + make + +To build against the other library uncomment the proper line in the file +regtest_hsrex.sh and execute again. + # Either this one + $CC -I. -I$H/inc -L. -lhsrex -o $rgbin $rgsrc + # or this one + #$CC -I. -I$H/inc -L. -lhswrex -DREGEX_WCHAR -o $rgbin $rgsrc + +You would like to test with debuging information. Uncomment the proper line in +the Makefile and rebuild. + # Either this one + #CFLAGS = -DREGEX_STANDALONE -fPIC -DREG_DEBUG -g + # Or this one + CFLAGS = -DREGEX_STANDALONE -fPIC -D_NDEBUG -O3 + +Two libraries are provided, libhsrex.so and libhswrex.so. The first one is for +ascii character code and the second one for wide characters. Both libraries +were tested in Linux and Solaris. Compiling and runing in Window$ should be +easy. + +The following entry point where defined in each library: +re_comp() (re_wcomp() for wide char) to compile a RE +re_exec() (re_wexec() for wide char) to parse data against a compiled RE. +regfree() To dispose the memory of a compiled RE. +regerror() Translates error codes to ascii strings. + +It is pretty easy to add support for a regcomp() regexec() front end. That +front end functions should take care of UTF-8 to wide charater conversion, for +instance. + +The regression test script regtest_hsrex.sh contains an example of how to use +the libraries. It just test cases I was interested on. Adding more use cases to +that script should be easy. + +Send any comments to Walter Waldo + +Enjoy it, + +Walter Waldo. + -- cgit v1.2.3