Chapter 3. The C++ API

Table of Contents

The Parse Tree Module
The Encoding class
The Symbol Table Module
The Type Analysis Module
The Type Repository
Overload Resolution
The Template Repository
Type Evaluation
Constant expressions
C++ Regression Tests

The Parser operates on an in-memory buffer of the whole (preprocessed) file. The generated parse tree refers to memory locations in that buffer, and it is possible to replace existing tree nodes by new ones, and then writing the modified buffer back to a file, preserving all but the modified regions.

This feature makes this parser an excellent choice for source-to-source transformation, as the new code doesn't need to be generated from scratch, but instead will preserve all features from the original file that the user didn't explicitely modify.

Parsing a source file involves a number of classes, such as Buffer, Lexer, Parser, and SymbolFactory. These can be constructed with a number of parameters, to control the specific language / language dialect (C, C++, GNU extensions, MSVC extensions, etc.).