pub struct Preprocessor<'a> { /* private fields */ }Expand description
The preprocessor.
Implementations§
Source§impl Preprocessor<'_>
impl Preprocessor<'_>
Sourcepub fn set_compile_mode(&mut self)
pub fn set_compile_mode(&mut self)
Read tokens for the compiler proper, instead of writing out preprocessed text: directives that are the compiler’s to act on are acted on.
Sourcepub fn next_token(&mut self) -> Tok
pub fn next_token(&mut self) -> Tok
Read the next token. At the end of the source, the token is
Tok::Eof, however often it is asked for.
Sourcepub fn unget_token(&mut self)
pub fn unget_token(&mut self)
Put the current token back, to be read again, and make the one before it current. Only one token can be put back this way.
Sourcepub fn unget_to(&mut self, earlier: SrcToken)
pub fn unget_to(&mut self, earlier: SrcToken)
Put the current token back, to be read again, and make a token that was read earlier current in its place.
Sourcepub fn push_token(&mut self, token: SrcToken)
pub fn push_token(&mut self, token: SrcToken)
Put a token in front of what is still to be read.
Source§impl<'a> Preprocessor<'a>
impl<'a> Preprocessor<'a>
Sourcepub fn new(files: &'a mut dyn SourceFiles) -> Self
pub fn new(files: &'a mut dyn SourceFiles) -> Self
A preprocessor that reads files through files.
Sourcepub fn set_test_report_mode(&mut self, on: bool)
pub fn set_test_report_mode(&mut self, on: bool)
Name files without their folders in __FILE__ and in messages.
Sourcepub fn set_imports(&mut self, imports: Vec<(String, Option<String>)>)
pub fn set_imports(&mut self, imports: Vec<(String, Option<String>)>)
The libraries a Hexicon source can import (import hexad;), each
with the header importing it gives, if it has one.
Sourcepub fn set_default_charset(&mut self, name: &str)
pub fn set_default_charset(&mut self, name: &str)
Set the character set of source files that do not say what they
are in, with a byte order mark or #charset. It is UTF-8 unless
this is called.
Sourcepub fn add_include_path(&mut self, path: &str)
pub fn add_include_path(&mut self, path: &str)
Add a folder to look for included files in.
Sourcepub fn define_macro(&mut self, mac: &LinkMacro)
pub fn define_macro(&mut self, mac: &LinkMacro)
Define a macro as the program’s table of macros has it, with its parameters, for code compiled while the program runs.
Sourcepub fn set_source(&mut self, name: &str) -> bool
pub fn set_source(&mut self, name: &str) -> bool
Start reading a source file. Returns false if it cannot be read.
Sourcepub fn file_name(&self, file: usize) -> &str
pub fn file_name(&self, file: usize) -> &str
The name of a file that a Line came from. In test report mode
it is the name without the folder.
Sourcepub fn gave_up(&self) -> bool
pub fn gave_up(&self) -> bool
Whether so many errors have been found that nothing more is read: from then on the source is at its end.
Sourcepub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
pub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
Take the problems found so far.
Sourcepub fn next_line(&mut self) -> Option<Line>
pub fn next_line(&mut self) -> Option<Line>
The next line of preprocessed text, or None at the end of the
source. There is a line of output, possibly empty, for each line
of the source.
Sourcepub fn files(&mut self) -> &mut dyn SourceFiles
pub fn files(&mut self) -> &mut dyn SourceFiles
The files it reads through, lent: to read what else is wanted of them while it is in use.
Sourcepub fn file_names(&self) -> Vec<String>
pub fn file_names(&self) -> Vec<String>
The names of the files read, by their numbers.
Sourcepub fn link_macros(&self) -> Vec<LinkMacro>
pub fn link_macros(&self) -> Vec<LinkMacro>
The macros as the source left them, as the reference writes them
to its object file: those defined now, but for __LINE__ and
__FILE__ and any name that was ever undefined or defined anew,
in the order of the reference’s table of them (chain by chain,
the sum of the name’s bytes in 512, and in a chain the newest
first).