https://github.com/hazimavdal/regex
A library for parsing and operating on formal regular expressions
https://github.com/hazimavdal/regex
brzozowski-derivative formal-languages parsing regular-expression regular-expressions smlnj
Last synced: 4 months ago
JSON representation
A library for parsing and operating on formal regular expressions
- Host: GitHub
- URL: https://github.com/hazimavdal/regex
- Owner: hazimavdal
- Created: 2020-02-13T05:53:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-11-12T20:38:32.000Z (over 4 years ago)
- Last Synced: 2025-05-19T06:08:42.694Z (about 1 year ago)
- Topics: brzozowski-derivative, formal-languages, parsing, regular-expression, regular-expressions, smlnj
- Language: Standard ML
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RegEx
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.
# Getting Started (Linux)
- Install `smlnj`:
```
apt install smlnj
```
- Install [libgmp-dev](https://gmplib.org/):
```
apt install libgmp-dev
```
- Install [mlton](http://mlton.org/):
- Download a release from [here](https://github.com/MLton/mlton/releases/tag/on-20201002-release)
- Un-tar the downloaded file
- Enter the untar-ed folder and run `make install`
- Run `make`. This will create two binaries, `bin/reverse` and `bin/derive`
# Example Usage
- 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
```
# Project Status
This project is no longer maintained. See my [jare](https://github.com/hazimavdal/jare) for a more formal `regex` implementation using `Elm`.
## Acknowledgements
This implementation is based on Professor Timothy Ng's [lecture notes](http://people.cs.uchicago.edu/~timng/280/w20/). The utility file [util/check.sml](https://github.com/hazimavdal/regex/blob/master/util/check.sml) is borrowed from Professor Adam Shaw's [CMSC 22100](http://people.cs.uchicago.edu/~adamshaw/cmsc22100-2018/index.html
).