A simple, modern C++ library for creating top-down recursive-descent predictive parsers for LL(1) grammars.
It is perhaps best to start with what this library is not. It is not intended to be, or to replace, a commercial product. Nor is it exhaustively tested.
It is, however, intended to offer up a collection of utility routines and classes to make creating your own parsers a more practical exercise. It includes classes for:
- Customizable Lexical Analysis
- A multi-level symbol table
- An extensible parsing framework
I have always been fascinated by the concepts behind compilers and interpreters. I gathered knowledge where and when I could and over time taught myself the basics of parsing technology. Over many years I've used what I've learned to create useful data serialization formats, small scripting languages, assemblers, and compilers.
Parsing concepts are sometimes difficult to learn and explain, and the technology still seems mystical to many. So I decided that I would share my library. I hope that this library is helpful to others.
I've found that there is no single textbook that clearly presents all that you want and need to know about parsing. For those just starting out I would recommend:
- The Dragon Book is one of the classical texts on the subject.
- Good coverage of the GNU versions of Yacc and Lex is Flex and Bison
- Another good source of information on Yacc and Lex is The Unix Programming Environment
- Modern Compiler Implementation in C provides a great overview of different parsing methods as well as other aspects of compiler implementation like register allocation and code generation.
The documentation for the library is a work in progress.
Several example projects are included to help illustrate some ways to make use of the library.
Provided examples include:
Name | Description |
---|---|
json | A simple JSON parser |
xml | A basic XML parser |
bnf | Simple Yacc-like table-driven parser generator |
yaml | YAML parser (not yet started) |