Parser - Created structure

This commit is contained in:
Emmanuel BENOîT 2022-12-30 23:50:33 +01:00
parent 8856d733ad
commit ed03d565ea
2 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,6 @@
mod ast;
mod errors;
mod parser;
mod scanner;
mod tokens;
@ -10,16 +11,22 @@ use std::{
};
use errors::ErrorHandler;
use parser::Parser;
use scanner::Scanner;
/// Execute a script.
fn run(source: String) -> ErrorHandler {
let mut error_handler = ErrorHandler::default();
let scanner = Scanner::new(source);
let tokens = scanner.scan_tokens(&mut error_handler);
for token in tokens {
for token in tokens.iter() {
println!("{:#?}", token);
}
let _parser = Parser::new(tokens);
error_handler
}

12
src/parser.rs Normal file
View file

@ -0,0 +1,12 @@
use crate::tokens::Token;
#[derive(Debug)]
pub struct Parser {
tokens: Vec<Token>,
}
impl Parser {
pub fn new(tokens: Vec<Token>) -> Self {
Self { tokens }
}
}