This is a library for parsing and operating on formal regular expressions. The repository is divided into three modules:
regex
: A library for tokenizing and parsing regular expressions.derivative
: A program for computing regular expression derivatives.reverse
: A program for computing the reverse of regular expressions.
- Install
smlnj
:
apt install smlnj
- Install libgmp-dev:
apt install libgmp-dev
-
Install mlton:
-
Download a release from here
-
Un-tar the downloaded file
-
Enter the untar-ed folder and run
make install
-
-
Run
make
. This will create two binaries,bin/reverse
andbin/derive
- Compute a first-order derivative
$ make
$ bin/derive -e "aa|b" -x a -n 1
# Output: a|b
- Reverse an expression
$ make
$ bin/reverse "a|b"
# Output: b|a
This project is no longer maintained. See my jare for a more formal regex
implementation using Elm
.
This implementation is based on Professor Timothy Ng's lecture notes. The utility file util/check.sml is borrowed from Professor Adam Shaw's CMSC 22100.