

To use Lemon, lemon.c needs to be compiled into an executable with a command such as the following: Its main site provides source code ( lemon.c and lempar.c) and a link to the tool's documentation.

I'm not one of those people, so don't be upset or surprised if the content of this article lacks the academic rigor you'd expect in a professional publication. Many computer scientists take the topic of parsing deathly seriously. However, it should be usable with any C/C++ build system. The example code presented in this article has been compiled with gcc. But you should have a firm grasp of C programming. To understand this article, you don't need to be familiar with parsing theory. This article adopts a hands-on approach in explaining how to generate parsing code with Lemon. This parser executes quickly, and the SQLite project relies on a Lemon-generated parser to analyze SQL commands. This means it matches rules to token sequences by looking ahead at most one token. To demonstrate how Lemon is used, this article's example involves generating a parser for an abridged version of the C programming language.Ī parser generated by Lemon performs LALR(1) parsing, where LALR stands for Look Ahead Left-to-Right. This article explains how a Lemon-generated parser can use those tokens to analyze text structure. The preceding article explained how re2c can be used to split text into a series of tokens.
