Struct rustlr::lexer_interface::LexSource
source · 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>
impl<'t> LexSource<'t>
sourcepub fn new(path: &'t str) -> Result<LexSource<'t>>
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
sourcepub fn from_file(path: &'t str) -> Result<LexSource<'t>>
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
sourcepub fn with_bump(path: &'t str) -> Result<LexSource<'t>>
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
sourcepub fn from_stdin() -> Self
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.
sourcepub fn from_stdin_bump() -> Self
pub fn from_stdin_bump() -> Self
Creates LexSource by reading from stdin, with bump arena. For use with auto-bump grammar option.
sourcepub fn from_bufread(br: impl BufRead) -> Self
pub fn from_bufread(br: impl BufRead) -> Self
Creates LexSource by reading all lines from a impl io::BufRead argument.
sourcepub fn from_bufread_bump(br: impl BufRead) -> Self
pub fn from_bufread_bump(br: impl BufRead) -> Self
Creates LexSource by reading all lines from a impl io::BufRead argument, with bump allocator
sourcepub fn get_bump(&self) -> Option<&Bump>
pub fn get_bump(&self) -> Option<&Bump>
retrieves reference to bump allocator, if created with with_bump
sourcepub fn get_contents(&self) -> &str
pub fn get_contents(&self) -> &str
retrieves entire contents of lexsource