Struct Parser

Source
pub struct Parser<'a> {
    pub i: usize,
    pub tokens: Vec<Token<'a>>,
    /* private fields */
}

Fields§

§i: usize§tokens: Vec<Token<'a>>

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new(lexer: Lexer<'a>) -> Self

Examples found in repository?
examples/disp.rs (line 36)
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 52)
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 37)
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 31)
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 11)
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 parse(&mut self) -> Ast

Examples found in repository?
examples/disp.rs (line 37)
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 53)
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 38)
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 32)
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 12)
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}

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

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