Chapter 3. The C++ API
Prev |  | Next

## Chapter 3. The C++ API

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.).

Prev |  | Next
Python Regression Tests | Home | The Parse Tree Module