pub struct Preprocessor { /* private fields */ }Expand description
Translation phase 4 over one file.
Holds the macro table and the conditional stack, so a single instance processes a whole translation unit and the definitions a header makes are visible after it.
Implementations§
Source§impl Preprocessor
impl Preprocessor
Sourcepub fn new() -> Preprocessor
pub fn new() -> Preprocessor
A preprocessor with an empty macro table.
Sourcepub fn macros(&self) -> &MacroTable
pub fn macros(&self) -> &MacroTable
The macros defined so far.
Sourcepub fn macros_mut(&mut self) -> &mut MacroTable
pub fn macros_mut(&mut self) -> &mut MacroTable
The macro table, for the driver to seed with -D and the predefined set.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Everything reported so far.
Sourcepub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
pub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
Takes the diagnostics, leaving the preprocessor able to carry on.
Sourcepub fn line_directives(&self) -> &[LineDirective]
pub fn line_directives(&self) -> &[LineDirective]
The #line directives seen, in the order they appeared.
Each one is also applied, to the source map, as it is read. This is the record of them rather than the mechanism: what a caller wants it for is reporting on the directives themselves, and asking the map is how to find out where anything is.
Sourcepub fn predefine(
&mut self,
target: &TargetInfo,
opts: &Predef,
cx: &mut Context<'_>,
) -> Result<(), SourceMapFull>
pub fn predefine( &mut self, target: &TargetInfo, opts: &Predef, cx: &mut Context<'_>, ) -> Result<(), SourceMapFull>
Defines the predefined macro set, and then -D and -U from the command line.
Called before Preprocessor::run, because a predefined macro is a macro like any
other by the time the source file is read. The set arrives as two synthetic files
rather than as a list of definitions, so a diagnostic about one of them points at
<built-in> or <command-line> the way GCC’s does, and so that -dM has something
to print. The reasoning is in crate::predef.
§Errors
When the source map has no room left for the two synthetic files.