Parser - Created structure
This commit is contained in:
parent
8856d733ad
commit
ed03d565ea
2 changed files with 20 additions and 1 deletions
|
@ -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
12
src/parser.rs
Normal 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 }
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue