Toy Parser Generator or How to easily write parsers in Python
Date: 2005-03-01 21:58:00

## Toy Parser Generator
or
How to easily write parsers in Python

Christophe Delord
christophe.delord@free.fr
http://christophe.delord.free.fr/en/tpg/
March 1, 2005
Contents
List of Figures
I Introduction and tutorial
1 Introduction
1.1 Introduction
1.2 License
1.3 Structure of the document
2 Installation
2.1 Getting TPG
2.2 Requirements
2.3 TPG for Linux and other Unix like
2.4 TPG for M$ Windows
2.5 TPG for other operating systems
3 Tutorial
3.1 Introduction
3.2 Defining the grammar
3.3 Reading the input and returning values
3.4 Embeding the parser in a script
3.5 Conclusion
II TPG reference
4 Usage
4.1 Package content
4.2 Command line usage
5 Grammar structure
5.1 TPG grammar structure
5.2 Comments
5.3 Options
5.4 Python code
5.5 TPG parsers
6 Lexer
6.1 Regular expression syntax
6.2 Token definition
6.3 Token matching
7 Parser
7.1 Declaration
7.2 Grammar rules
7.3 Parsing terminal symbols
7.4 Parsing non terminal symbols
7.5 Sequences
7.6 Alternatives
7.7 Repetitions
7.8 Precedence and grouping
7.9 Actions
8 Context sensitive lexer
8.1 Introduction
8.2 Grammar structure
8.3 CSL lexers
8.4 CSL parsers
9 Debugging
9.1 Introduction
9.2 Verbose parsers
III Some examples to illustrate TPG
10 Complete interactive calculator
10.1 Introduction
10.2 New functions
10.3 Source code
11 Infix/Prefix/Postfix notation converter
11.1 Introduction
11.2 Abstract syntax trees
11.3 Grammar
11.4 Source code