mseminatore / ParserKit

A C++ library for creating top-down recursive-descent predictive parsers for LL(1) grammars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ParserKit

A simple, modern C++ library for creating top-down recursive-descent predictive parsers for LL(1) grammars.

What is ParserKit?

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

Why create this library?

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.

How can I learn more about parsing?

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:

  1. The Dragon Book is one of the classical texts on the subject.
  2. Good coverage of the GNU versions of Yacc and Lex is Flex and Bison
  3. Another good source of information on Yacc and Lex is The Unix Programming Environment
  4. 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.

Documentation

The documentation for the library is a work in progress.

Examples

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)

About

A C++ library for creating top-down recursive-descent predictive parsers for LL(1) grammars

License:MIT License


Languages

Language:C++ 99.1%Language:Makefile 0.9%