diff --git a/src/main.rs b/src/main.rs index fe00d16..8cc4cc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 } diff --git a/src/parser.rs b/src/parser.rs new file mode 100644 index 0000000..aa28eef --- /dev/null +++ b/src/parser.rs @@ -0,0 +1,12 @@ +use crate::tokens::Token; + +#[derive(Debug)] +pub struct Parser { + tokens: Vec, +} + +impl Parser { + pub fn new(tokens: Vec) -> Self { + Self { tokens } + } +}