pub struct Configuration { /* private fields */ }
Expand description
Configure various aspects of how LALRPOP works.
Intended for use within a build.rs
script.
To get the default configuration, use Configuration::new
.
Implementations§
Source§impl Configuration
impl Configuration
Sourcepub fn new() -> Configuration
pub fn new() -> Configuration
Creates the default configuration.
equivalent to Configuration::default
.
Sourcepub fn always_use_colors(&mut self) -> &mut Configuration
pub fn always_use_colors(&mut self) -> &mut Configuration
Always use ANSI colors in output, even if output does not appear to be a TTY.
Sourcepub fn never_use_colors(&mut self) -> &mut Configuration
pub fn never_use_colors(&mut self) -> &mut Configuration
Never use ANSI colors in output, even if output appears to be a TTY.
Sourcepub fn use_colors_if_tty(&mut self) -> &mut Configuration
pub fn use_colors_if_tty(&mut self) -> &mut Configuration
Use ANSI colors in output if output appears to be a TTY, but not otherwise. This is the default.
Sourcepub fn set_in_dir<P>(&mut self, dir: P) -> &mut Self
pub fn set_in_dir<P>(&mut self, dir: P) -> &mut Self
Specify a custom directory to search for input files.
This directory is recursively searched for .lalrpop
files to be
considered as input files. This configuration setting also
impacts where output files are placed; paths are made relative
to the input path before being resolved relative to the output
path. By default, the input directory is the current working
directory.
Sourcepub fn set_out_dir<P>(&mut self, dir: P) -> &mut Self
pub fn set_out_dir<P>(&mut self, dir: P) -> &mut Self
Specify a custom directory to use when writing output files.
By default, the output directory is the same as the input directory.
Sourcepub fn use_cargo_dir_conventions(&mut self) -> &mut Self
pub fn use_cargo_dir_conventions(&mut self) -> &mut Self
Apply cargo
directory location conventions.
This sets the input directory to src
and the output directory to
$OUT_DIR
.
Sourcepub fn generate_in_source_tree(&mut self) -> &mut Self
pub fn generate_in_source_tree(&mut self) -> &mut Self
Write output files in the same directory of the input files.
If this option is enabled, you have to load the parser as a module:
mod parser; // synthesized from parser.lalrpop
This was the default behaviour up to version 0.15.
Sourcepub fn force_build(&mut self, val: bool) -> &mut Configuration
pub fn force_build(&mut self, val: bool) -> &mut Configuration
If true, always convert .lalrpop
files into .rs
files, even if the
.rs
file is newer. Default is false.
Sourcepub fn emit_rerun_directives(&mut self, val: bool) -> &mut Configuration
pub fn emit_rerun_directives(&mut self, val: bool) -> &mut Configuration
If true, print rerun-if-changed
directives to standard output.
If this is set, Cargo will only rerun the build script if any of the processed
.lalrpop
files are changed. This option is independent of
Self::force_build()
, although it would be usual to set Self::force_build()
and
Self::emit_rerun_directives()
at the same time.
While many build scripts will want to set this to true
, the default is
false, because emitting any rerun directives to Cargo will cause the
script to only be rerun when Cargo thinks it is needed. This could lead
to hard-to-find bugs if other parts of the build script do not emit
directives correctly, or need to be rerun unconditionally.
Sourcepub fn emit_comments(&mut self, val: bool) -> &mut Configuration
pub fn emit_comments(&mut self, val: bool) -> &mut Configuration
If true, emit comments into the generated code.
This makes the generated code significantly larger. Default is false.
Sourcepub fn emit_whitespace(&mut self, val: bool) -> &mut Configuration
pub fn emit_whitespace(&mut self, val: bool) -> &mut Configuration
If false, shrinks the generated code by removing redundant white space. Default is true.
Sourcepub fn emit_report(&mut self, val: bool) -> &mut Configuration
pub fn emit_report(&mut self, val: bool) -> &mut Configuration
If true, emit report file about generated code.
Sourcepub fn log_quiet(&mut self) -> &mut Configuration
pub fn log_quiet(&mut self) -> &mut Configuration
Minimal logs: only for errors that halt progress.
Sourcepub fn log_info(&mut self) -> &mut Configuration
pub fn log_info(&mut self) -> &mut Configuration
Informative logs: give some high-level indications of progress (default).
Sourcepub fn log_verbose(&mut self) -> &mut Configuration
pub fn log_verbose(&mut self) -> &mut Configuration
Verbose logs: more than info, but still not overwhelming.
Sourcepub fn log_debug(&mut self) -> &mut Configuration
pub fn log_debug(&mut self) -> &mut Configuration
Debug logs: better redirect this to a file. Intended for debugging LALRPOP itself.
Sourcepub fn set_macro_recursion_limit(&mut self, val: u16) -> &mut Configuration
pub fn set_macro_recursion_limit(&mut self, val: u16) -> &mut Configuration
Set the max macro recursion depth.
As lalrpop is resolving a macro, it may discover new macros uses in the macro definition to resolve. Typically deep recursion indicates a recursive macro use that is non-resolvable. The default resolution depth is 200.
Sourcepub fn set_features<I>(&mut self, iterable: I) -> &mut Configurationwhere
I: IntoIterator<Item = String>,
pub fn set_features<I>(&mut self, iterable: I) -> &mut Configurationwhere
I: IntoIterator<Item = String>,
Sets the features used during compilation, disables the use of cargo features.
(Default: Loaded from CARGO_FEATURE_{}
environment variables).
Sourcepub fn process(&self) -> Result<(), Box<dyn Error>>
pub fn process(&self) -> Result<(), Box<dyn Error>>
Process all files according to the set_in_dir
and
set_out_dir
configuration.
Sourcepub fn process_current_dir(&self) -> Result<(), Box<dyn Error>>
pub fn process_current_dir(&self) -> Result<(), Box<dyn Error>>
Process all files in the current directory, which – unless you have changed it – is typically the root of the crate being compiled.
Trait Implementations§
Source§impl Clone for Configuration
impl Clone for Configuration
Source§fn clone(&self) -> Configuration
fn clone(&self) -> Configuration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for Configuration
impl Default for Configuration
Source§fn default() -> Configuration
fn default() -> Configuration
Auto Trait Implementations§
impl Freeze for Configuration
impl RefUnwindSafe for Configuration
impl Send for Configuration
impl Sync for Configuration
impl Unpin for Configuration
impl UnwindSafe for Configuration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more