Contents

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.3.1 Lexer option
  5.3.2 Word bondary option
  5.3.3 Regular expression options
 5.4 Python code
  5.4.1 Syntax
  5.4.2 Indentation
 5.5 TPG parsers
  5.5.1 Methods
  5.5.2 Rules
6 Lexer
 6.1 Regular expression syntax
 6.2 Token definition
  6.2.1 Predefined tokens
  6.2.2 Inline tokens
 6.3 Token matching
  6.3.1 Splitting the input string
  6.3.2 Matching tokens in grammar rules
7 Parser
 7.1 Declaration
 7.2 Grammar rules
 7.3 Parsing terminal symbols
 7.4 Parsing non terminal symbols
  7.4.1 Starting the parser
  7.4.2 In a rule
 7.5 Sequences
 7.6 Alternatives
 7.7 Repetitions
 7.8 Precedence and grouping
 7.9 Actions
  7.9.1 Abstract syntax trees
  7.9.2 Text extraction
  7.9.3 Object
8 Context sensitive lexer
 8.1 Introduction
 8.2 Grammar structure
 8.3 CSL lexers
  8.3.1 Regular expression syntax
  8.3.2 Token matching
 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.2.1 Trigonometric and other functions
  10.2.2 Memories
 10.3 Source code
11 Infix/Prefix/Postfix notation converter
 11.1 Introduction
 11.2 Abstract syntax trees
 11.3 Grammar
  11.3.1 Infix expressions
  11.3.2 Prefix expressions
  11.3.3 Postfix expressions
 11.4 Source code