Re2c is a free and open-source lexer generator for C, C++ and Go. It compiles regular expressions to determinisitic finite automata and encodes the automata in the form of a program in the target language. The main advantages of re2c are speed of the generated code and a flexible user interface that allows one to adapt the generated lexer to a particular environment and input model. Re2c supports fast and lightweight submatch extraction with either POSIX or leftmost greedy semantics. Re2c is used in other open-source projects such as php, ninja, yasm, spamassassin, BRL-CAD and wake, etc.
You can get the latest release on Github, as well as the older releases. Many Linux distributions and other systems provide their own packages. Re2c source code is hosted on both Github (https://github.com/skvadrik/re2c) and SourceForge (https://sourceforge.net/p/re2c). Github serves as the main repository, bugtracker and tarball hosting. SourceForge is used as a backup repository and email hosting.
Bugs & patches¶
Please send bugs reports, patches and other feedback to Github issue tracker or email them to
Re2c has an IRC channel
#re2c on freenode.
Re2c developers are happy to answer questions and provide help.
Contributions are always welcome!
RE2C: a more versatile scanner generator by Peter Bumbulis and Donald D. Cowan, ACM Letters on Programming Languages and Systems (LOPLAS), 1994
Tagged Deterministic Finite Automata with Lookahead by Ulya Trofimovich, arXiv:1907.08837, 2017
Efficient POSIX submatch extraction on NFA by Angelo Borsotti and Ulya Trofimovich, 2019
Re2c is in the public domain. The data structures and algorithms used in re2c are all either taken from documents available to the general public or are inventions of the author. Programs generated by re2c may be distributed freely. Re2c itself may be distributed freely, in source or binary, unchanged or modified. Distributors may charge whatever fees they can obtain for re2c. If you do make use of re2c, or incorporate it into a larger project an acknowledgement somewhere (documentation, research report, etc.) would be appreciated. Re2c is distributed with no warranty whatsoever. The code is certain to contain errors. Neither the author nor any contributor takes responsibility for any consequences of its use.
This website describes re2c version 2.1.1.