""> >

Chapter 1

1.1 Introduction

TPG (Toy Parser Generator) is a Python1 parser generator. It is aimed at easy usage rather than performance. My inspiration was drawn from two different sources. The first was GEN6. GEN6 is a parser generator created at ENSEEIHT2 where I studied. The second was PROLOG3, especially DCG4 parsers. I wanted a generator with a simple and expressive syntax and the generated parser should work as the user expects. So I decided that TPG should be a recursive descendant parser (a rule is a procedure that calls other procedures) and the grammars are attributed (attributes are the parameters of the procedures). This way TPG can be considered as a programming language or more modestly as Python extension.

1.2 License

TPG is available under the GNU Lesser General Public.

Toy Parser Generator: A Python parser generator

Copyright (C) 2002 Christophe Delord

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

1.3 Structure of the document

Part I
starts smoothly with a gentle tutorial as an introduction. I think this tutorial may be sufficent to start with TPG.
Part II
is a reference documentation. It will detail TPG as much as possible.
Part III
gives the reader some examples to illustrate TPG.
Part IV
is an explanation of how TPG works internally. It details the predictive algorithm and shows the generated code. It is not needed to read this part but it can help to understand how TPG works or why some grammars fail.