You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
689 B

use crate::lexer::Token;
pub struct Parser {
tokens: Box<dyn Iterator<Item = Token>>,
current: Option<Token>,
indentation_level: usize,
}
impl Parser {
pub(crate) fn new(tokens: impl Iterator<Item = Token> + 'static) -> Self {
Parser {
tokens: Box::new(tokens),
current: None,
indentation_level: 0,
}
}
fn next(&mut self) {
self.current = self.tokens.next();
}
}
#[derive(Debug)]
pub struct AST;
pub fn parse(tokens: impl Iterator<Item = Token> + 'static) -> AST {
let mut parser = Parser::new(tokens);
let ast = AST {};
loop {
parser.next();
break;
}
ast
}