Struct Lexer

Source
pub struct Lexer<'a> {
    pub s: &'a str,
    /* private fields */
}

Fields§

§s: &'a str

Implementations§

Source§

impl<'a> Lexer<'a>

Source

pub fn new(source: &str) -> Lexer<'_>

Examples found in repository?
examples/disp.rs (line 35)
34fn main() {
35    let l = Lexer::new(TEST);
36    let mut p = Parser::new(l);
37    let a = p.parse();
38    println!("{:#?}", a);
39}
More examples
Hide additional examples
examples/flex.rs (line 51)
50fn main() {
51    let l = Lexer::new(TEST);
52    let mut p = Parser::new(l);
53    let a = p.parse();
54    println!("{:#?}", a);
55}
examples/grid.rs (line 36)
35fn main() {
36    let l = Lexer::new(TEST);
37    let mut p = Parser::new(l);
38    let a = p.parse();
39    println!("{:#?}", a);
40}
examples/no_class.rs (line 30)
29fn main() {
30    let l = Lexer::new(TEST);
31    let mut p = Parser::new(l);
32    let a = p.parse();
33    println!("{:#?}", a);
34}
examples/load.rs (line 10)
4fn main() {
5    let args: Vec<String> = std::env::args().collect();
6    if args.len() < 2 {
7        panic!("Expected a file input!");
8    }
9    let s = std::fs::read_to_string(&args[1]).expect("Failed to read file!");
10    let l = Lexer::new(&s);
11    let mut p = Parser::new(l);
12    let a = p.parse();
13    println!("{:#?}", a);
14}
Source

pub fn next(&mut self) -> Token<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Lexer<'a>

§

impl<'a> RefUnwindSafe for Lexer<'a>

§

impl<'a> Send for Lexer<'a>

§

impl<'a> Sync for Lexer<'a>

§

impl<'a> Unpin for Lexer<'a>

§

impl<'a> UnwindSafe for Lexer<'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, 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.