-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
The most traditional implementation of a lexer is, without a doubt, Flex (https://github.com/westes/flex). It is used by many programming languages, or at least it’s the starting point for many of them. It works with a code generator, which interleaves the code required to match the regular expressions with the actions that need to be executed.
Its main advantage is its ubiquity: there’s probably not an operating system in which you can’t get Flex to work, and it has been extensively optimized and reviewed over the years. Its main disadvantage is the contrived rules of its code generator, where you’re expected to write C code interleaved with the lexer rules that Flex parses, which then get converted into a final C file.
re2c (https://re2c.org/) and RE/flex (https://github.com/Genivia/RE-flex) are lexers that take a similar approach to Flex, in the sense that you have a separate programming language interleaved...