Learning preprocessor and lexer essentials
In the previous, Working with SourceLocation and SourceManager section, we've learned how source locations, which are an important part of the preprocessor, are represented in Clang. In this section, we will first explain the principle of Clang's preprocessor and lexer, along with their working flow. Then, we'll go into some of the important components in this flow and briefly explain their usage in the code. These will also prepare you for the project in the, Developing custom preprocessor plugins and callbacks section later in this chapter.
Understanding the role of the preprocessor and lexer in Clang
The roles and primary actions performed by Clang's preprocessor and lexer, represented by the Preprocessor
and Lexer
classes respectively, are illustrated in the following diagram:
We believe most readers here will be familiar with...