started work on compiler

This commit is contained in:
2025-06-30 20:44:39 +01:00
parent ae92510fb8
commit 2582ad10fa
7 changed files with 533 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
use std::{fs, path::Path};
pub mod lexer;
pub mod parser;
fn main() {
println!("Hello, world!");
let path = Path::new("../resources/dsc/example.dsc");
let contents = fs::read_to_string(path).expect("Failed to read file");
let lexer = lexer::Lexer::new(&contents);
let tokens = lexer.collect::<Vec<_>>();
println!("{tokens:?}");
let mut parser = parser::Parser::new(tokens);
let ast = match parser.parse() {
Ok(ast) => ast,
Err(e) => {
eprintln!("Error: {e:?}");
return;
}
};
println!("{ast:?}");
}