diff --git a/crates/fuse-ast/src/visit.rs b/crates/fuse-ast/src/visit.rs index 8834c80..6a50c36 100644 --- a/crates/fuse-ast/src/visit.rs +++ b/crates/fuse-ast/src/visit.rs @@ -3,6 +3,8 @@ use crate::ast::*; +/// Placeholder macro for visiting, It is used instead of calling visitor methods directly. +/// Would be useful if we need some operation to happen for every visit. macro_rules! visit { ($expr:expr) => { $expr diff --git a/crates/fuse-semantic/src/lib.rs b/crates/fuse-semantic/src/lib.rs index 9835f10..b25970b 100644 --- a/crates/fuse-semantic/src/lib.rs +++ b/crates/fuse-semantic/src/lib.rs @@ -1 +1,12 @@ -pub fn semantic_analysis() {} +use fuse_ast::Chunk; + +pub struct Semantic<'a> { + source: &'a str, + chunk: Chunk, +} + +impl<'a> Semantic<'a> { + pub fn new(source: &'a str, chunk: Chunk) -> Self { + Self { source, chunk } + } +} diff --git a/crates/fusec/Cargo.toml b/crates/fusec/Cargo.toml index 39a7087..34c5654 100644 --- a/crates/fusec/Cargo.toml +++ b/crates/fusec/Cargo.toml @@ -9,3 +9,4 @@ edition.workspace = true [dependencies] fuse_parser = { workspace = true } +fuse_semantic = { workspace = true } diff --git a/crates/fusec/src/lib.rs b/crates/fusec/src/lib.rs index 6b675bc..029efeb 100644 --- a/crates/fusec/src/lib.rs +++ b/crates/fusec/src/lib.rs @@ -1,6 +1,15 @@ use fuse_parser::Parser; +use fuse_semantic::Semantic; fn compile_chunk(source: &str) { - let parsed_tree = Parser::new(source).parse(); - todo!("Compiler isn't done yet!") + let parsed = Parser::new(source).parse(); + let semantic = Semantic::new(source, parsed.chunk.unwrap()); +} + +#[test] +fn manual_test() { + compile_chunk(r#" + let x = 123 + let y = x + "#) }