RE2C 4.0 Lexical Analyzer Generator Released

Published release re2c 4.0 – a generator of lexical analyzers (aka regular expressions compiler to the code in the target language of programming). RE2C specializes in the generation of fast and easily built-in lexers and differs from a more well-known FLEX analogue with a flexible interface, generating optimized non-table lexers and Submatch Extraction based on determinated finite machines with tags (tdfa). RE2C is used in projects where the speed of Lexer’s work is important, for example, in Ninja and in PHP.

In release 4.0, the code generation subsystem has radically redesigned the support of eight new languages (D, Haskell, Java, JavaScript, Ocaml, Python, V, Zig) in addition to already supported (C/C++, GO, RUST), as well as implement a general mechanism for adding new languages through configuration files.

The code generator is responsible for the broadcast of the already constructed and optimized final automatic machine into the code, that is, its task is to choose the control structure, type of data, the general model of the program, etc., suitable for the target language. Previously, all this logic was part of the RE2C source code, and in order to change it or add a new language, it was necessary to patch the source code and reconfigure RE2C. Such patches were not accepted into the main repository without implementing a standard set of examples and tests, which additionally complicated the entire process.

Now all this logic is transferred to syntactic files – textual configuration files that can be provided by the user (By default, Re2C uses standard). The source code Re2C is completely free from the details of a particular language and is relied only on a syntactic file. The user can partially reassemble the existing syntactic file or write a new one from scratch. For all officially supported languages, there is complete documentation with examples.

The release also includes many other changes to simplify the user interface and improve work with existing groups. Added online environment for editing and compiling examples.

/Reports, release notes, official announcements.