Skip to content

Commit 31f569d

Browse files
committed
chore: setup project for adding semantics.
1 parent 1aab487 commit 31f569d

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

crates/fuse-ast/src/visit.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
use crate::ast::*;
55

6+
/// Placeholder macro for visiting, It is used instead of calling visitor methods directly.
7+
/// Would be useful if we need some operation to happen for every visit.
68
macro_rules! visit {
79
($expr:expr) => {
810
$expr

crates/fuse-semantic/src/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
pub fn semantic_analysis() {}
1+
use fuse_ast::Chunk;
2+
3+
pub struct Semantic<'a> {
4+
source: &'a str,
5+
chunk: Chunk,
6+
}
7+
8+
impl<'a> Semantic<'a> {
9+
pub fn new(source: &'a str, chunk: Chunk) -> Self {
10+
Self { source, chunk }
11+
}
12+
}

crates/fusec/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ edition.workspace = true
99

1010
[dependencies]
1111
fuse_parser = { workspace = true }
12+
fuse_semantic = { workspace = true }

crates/fusec/src/lib.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
use fuse_parser::Parser;
2+
use fuse_semantic::Semantic;
23

34
fn compile_chunk(source: &str) {
4-
let parsed_tree = Parser::new(source).parse();
5-
todo!("Compiler isn't done yet!")
5+
let parsed = Parser::new(source).parse();
6+
let semantic = Semantic::new(source, parsed.chunk.unwrap());
7+
}
8+
9+
#[test]
10+
fn manual_test() {
11+
compile_chunk(r#"
12+
let x = 123
13+
let y = x
14+
"#)
615
}

0 commit comments

Comments
 (0)