pub struct LexSource<'t> { /* private fields */ }
Expand description

Structure to hold contents of a source (such as contents of file). A StrTokenizer can be created from such a struct. It reads the contents of a file using std::fs::read_to_string and stores it locally.

Implementations§

source§

impl<'t> LexSource<'t>

source

pub fn new(path: &'t str) -> Result<LexSource<'t>>

creates a new LexSource struct with given source file path, reads contents into struct using std::fs::read_to_string

source

pub fn from_file(path: &'t str) -> Result<LexSource<'t>>

creates a new LexSource struct with given source file path, reads contents into struct using std::fs::read_to_string. Alias for LexSource::new

source

pub fn with_bump(path: &'t str) -> Result<LexSource<'t>>

creates a new LexSource struct with given file path, reads contents into struct using std::fs::read_to_string, creates bump allocator with same lifetime as the struct. For use with auto-bump grammar option

source

pub fn from_stdin() -> Self

Creates LexSource by reading all lines from stdin. Note that all lines are read at once and the input stream is expected to be terminated (such as with Cntrl-D) before the LexSource is created.

source

pub fn from_stdin_bump() -> Self

Creates LexSource by reading from stdin, with bump arena. For use with auto-bump grammar option.

source

pub fn from_bufread(br: impl BufRead) -> Self

Creates LexSource by reading all lines from a impl io::BufRead argument.

source

pub fn from_bufread_bump(br: impl BufRead) -> Self

Creates LexSource by reading all lines from a impl io::BufRead argument, with bump allocator

source

pub fn get_bump(&self) -> Option<&Bump>

retrieves reference to bump allocator, if created with with_bump

source

pub fn get_contents(&self) -> &str

retrieves entire contents of lexsource

source

pub fn get_path(&self) -> &str

retrieves original path (such as filename) of this source

Auto Trait Implementations§

§

impl<'t> !RefUnwindSafe for LexSource<'t>

§

impl<'t> Send for LexSource<'t>

§

impl<'t> !Sync for LexSource<'t>

§

impl<'t> Unpin for LexSource<'t>

§

impl<'t> !UnwindSafe for LexSource<'t>

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>,

§

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>,

§

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.