# RE2HS lexer generator

**URL:** <https://discourse.haskell.org/t/re2hs-lexer-generator/10806>\
**Category:** Announcements\
**Created:** [November 25, 2024, 4:11pm UTC](https://discourse.haskell.org/t/re2hs-lexer-generator/10806 "2024-11-25T16:11:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skvadrik](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/skvadrik/32/4791_2.png) [@skvadrik](https://discourse.haskell.org/u/skvadrik)\
**Post date:** [November 25, 2024, 4:11pm UTC](https://discourse.haskell.org/t/re2hs-lexer-generator/10806/1 "2024-11-25T16:11:53Z")

</div>

Regular expression compiler re2c now supports Haskell (as of release 4.0).

A short intro from the official website: _re2c_ stands for _Regular Expressions to Code_. It is a free and open-source lexer generator that supports C, C++, D, Go, Haskell, Java, JavaScript, OCaml, Python, Rust, V, Zig, and can be extended to other languages by implementing a single syntax file. The primary focus of re2c is on generating _fast_ code: it compiles regular expressions to deterministic finite automata and translates them into direct-coded lexers in the target language (such lexers are generally faster and easier to debug than their table-driven analogues). Secondary re2c focus is on _flexibility_: it does not assume a fixed program template; instead, it allows the user to embed lexers anywhere in the source code and configure them to avoid unnecessary buffering and bounds checks. Internal algorithm used by re2c is based on a special kind of deterministic finite automata: lookahead TDFA. These automata are as fast as ordinary DFA, but they are also capable of performing submatch extraction with minimal overhead.

There is a [detailed user guide](http://re2c.org/manual/manual_hs.html) and [online playground](http://re2c.org/playground/?example=hs/01_basic.re) with many examples.

---

<div class="post-metadata">

**Author:** ![oshepherd](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/oshepherd/32/2595_2.png) [@oshepherd](https://discourse.haskell.org/u/oshepherd)\
**Post date:** [November 29, 2024, 2:48pm UTC](https://discourse.haskell.org/t/re2hs-lexer-generator/10806/2 "2024-11-29T14:48:22Z")

</div>

Wow, that’s awesome! I love re2c, it’s just so… elegant, and I’m very happy to see a Haskell backend added!
