Struct Config

Source
#[non_exhaustive]
pub struct Config { pub start_line_number: NonZeroU64, pub source: Option<Rc<Source>>, }
Expand description

Configuration for the lexer

Config is a builder for the lexer. A new instance is created with default settings. You can then customize the settings by modifying the corresponding fields. Finally, you can pass an input object to the input method to create a lexer.

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.
§start_line_number: NonZeroU64

Line number for the first line of the input

The lexer counts the line number from this value to annotate the location of the tokens. The line number is saved in the start_line_number field of the Code instance that is contained in the Location instance of the token.

The default value is 1.

§source: Option<Rc<Source>>

Source of the input

The source is used to annotate the location of the tokens. This value is saved in the source field of the Code instance that is contained in the Location instance of the token.

The default value is None, in which case the source is set to Source::Unknown. It is recommended to set this to a more informative value, so that the locations in the parsed syntax tree can be traced back to the source code. Especially, the correct source is necessary to indicate the location of possible errors that occur during parsing and execution.

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Creates a new configuration with default settings.

You can also call Lexer::config to create a new configuration.

Source

pub fn input<'a>(self, input: Box<dyn InputObject + 'a>) -> Lexer<'a>

Creates a lexer with the given input object.

Trait Implementations§

Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl !Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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.