Skip to content

Commit

Permalink
chore: setup project for adding semantics.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Mar 11, 2024
1 parent 1aab487 commit 31f569d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions crates/fuse-ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion crates/fuse-semantic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 }
}
}
1 change: 1 addition & 0 deletions crates/fusec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ edition.workspace = true

[dependencies]
fuse_parser = { workspace = true }
fuse_semantic = { workspace = true }
13 changes: 11 additions & 2 deletions crates/fusec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
"#)
}

0 comments on commit 31f569d

Please sign in to comment.