Skip to main content

Preprocessor

Struct Preprocessor 

Source
pub struct Preprocessor<'a> { /* private fields */ }
Expand description

The preprocessor.

Implementations§

Source§

impl Preprocessor<'_>

Source

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.

Source

pub fn cur_token(&self) -> &SrcToken

The token most recently read.

Source

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.

Source

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.

Source

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.

Source

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>

Source

pub fn new(files: &'a mut dyn SourceFiles) -> Self

A preprocessor that reads files through files.

Source

pub fn set_test_report_mode(&mut self, on: bool)

Name files without their folders in __FILE__ and in messages.

Source

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.

Source

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.

Source

pub fn add_include_path(&mut self, path: &str)

Add a folder to look for included files in.

Source

pub fn define(&mut self, name: &str, expansion: &str)

Define a macro without parameters.

Source

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.

Source

pub fn undefine(&mut self, name: &str)

Remove a macro’s definition.

Source

pub fn set_source(&mut self, name: &str) -> bool

Start reading a source file. Returns false if it cannot be read.

Source

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.

Source

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.

Source

pub fn take_diagnostics(&mut self) -> Vec<Diagnostic>

Take the problems found so far.

Source

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.

Source

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.

Source

pub fn file_names(&self) -> Vec<String>

The names of the files read, by their numbers.

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.