Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config<'a> { pub input: Box<dyn InputObject + 'a>, pub start_line_number: NonZeroU64, pub source: Option<Rc<Source>>, }
Expand description

Configuration for the parser

This struct holds various configuration options for the parser, including the input function to read source code and source information.

Parser implementations are not provided in this crate (yash-env). The standard parser implementation is provided in the yash-syntax crate. Config is provided here so that other crates can use RunReadEvalLoop without depending on yash-syntax.

Since this struct is marked as #[non_exhaustive], you cannot construct it directly. Instead, use the with_input function to create a Config instance, and then modify its fields as necessary.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§input: Box<dyn InputObject + 'a>

Input function to read source code

§start_line_number: NonZeroU64

Line number for the first line of the input

The lexer counts lines starting from this number. This affects the start_line_number field of the Code instance attached to the parsed AST.

The default value is 1.

§source: Option<Rc<Source>>

Source information for the input

If provided, this source information is saved in the source field of the Code instance attached to the parsed AST.

The default value is None, in which case Source::Unknown is used.

Implementations§

Source§

impl<'a> Config<'a>

Source

pub fn with_input(input: Box<dyn InputObject + 'a>) -> Self

Creates a Config with the given input function.

Trait Implementations§

Source§

impl<'a> Debug for Config<'a>

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Config<'a>

§

impl<'a> !RefUnwindSafe for Config<'a>

§

impl<'a> !Send for Config<'a>

§

impl<'a> !Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> !UnwindSafe for Config<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.