Preprocessor
A preprocessor for C.
We provide a preprocessor for C that, unlike typical preprocessors,
preserves the information about the #include directives.
That is, it does not replace such directives
with the (preprocessed) contents of the referenced files,
but it otherwise performs the rest of the preprocessing.
Our preprocessor maps a list of file paths
to a file set (see files):
it preprocesses all the files with the given file paths,
as well as all the files directly and indirectly included.
The resulting file set contains entries for all such files,
not only the ones with the given file paths.
Our preprocessor reads characters and lexes them into lexemes,
while executing the preprocessing directives.
The resulting sequence of lexemes is then turned into characters
that are written into files.
The resulting file set is amenable to our parser
(more precisely, it will be, once we have extended our parser
to accept #include directives in certain places).
Our preprocessor preserves white space, in order to preserve the layout
(modulo the inherent layout changes caused by preprocessing).
Our preprocessor also preserves comments,
although some comments may no longer apply to preprocessed code
(e.g. comments talking about macros).
Currently some of this preprocessor's code duplicates, at some level,
some of the code in the parser
(including the lexer and the reader).
At some point we should integrate the preprocessor with the parser.
This preprocessor is still work in progress.
Subtopics
- Preprocessor-states
- States of the preprocessor.
- Pread-token/newline
- Read a token or newline during preprocessing.
- Pread-token
- Read a token during preprocessing.
- Preprocessor-lexer
- Lexer component of the preprocessor.
- Pproc-files
- Preprocess zero or more files.
- Preprocessor-printer
- Printer component of the preprocessor.
- Pproc-file
- Preprocess a file.
- Filepath-plexeme-list-alist-to-filepath-filedata-map
- Turn an alist from file paths to lists of preprocessing lexemes
into a map from file paths to file data.
- Filepath-plexeme-list-alist
- Fixtype of alists from file paths to lists of preprocessing lexemes.
- Preprocessor-reader
- Reader component of the preprocessor.
- Preprocessor-messages
- Messages from he preprocessor (including lexer and reader).