Typed Regular Expressions
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark
examples Move to jbuilder. Aug 4, 2018
src Add a bunch of flambda instrumentation. Oct 7, 2018
test Add tests for marks. Aug 17, 2018
.gitignore Move to jbuilder. Aug 4, 2018
.travis-ci.sh
.travis.yml
CHANGES.md
LICENSE.md
Makefile
Readme.md Add doc boilerplate. Aug 6, 2018
tyre.descr Add a descr. Aug 17, 2018
tyre.opam

Readme.md

Tyre Build Status docs

Tyre is a set of combinators to build type-safe regular expressions, allowing automatic extraction and modification of matched groups.

Tyre is bi-directional: a typed regular expressions can be used for parsing and unparsing. It also allows routing, by providing a list of regexs/routes and their handlers.

Tyre is pure OCaml and uses re. To install it:

opam install tyre

Documentation is available here. See also the examples/ directory. A primitive HTTP parser can be found in the benchmark/ directory.

# let dim = Tyre.( str"dim:" *> int <&> str"x" *> int ) ;;
val dim : (int * int) Tyre.t

# let dim_re = Tyre.compile dim ;;
val dim_re : (int * int) Tyre.re

# Tyre.exec dim_re "dim:3x4" ;;
- : (int * int, (int * int) Tyre.error) result = Result.Ok (3, 4)

# Tyre.eval dim (2, 5) ;;
- : string = "dim:2x5"

Benchmark

Some benchmarks are available under the benchmark/ directory. The benchmark compares the parsing of HTTP requests using angstrom and various tyre methods. You can run them with:

./benchmark/data/replicate benchmark/data/http-requests.txt 100
jbuilder exec benchmark/benchmark_angstrom.exe -- -a