diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Cargo.lock | 8 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | src/main.rs | 21 | ||||
m--------- | vendor/rust_lisp | 0 | ||||
-rwxr-xr-x | www/slgj-2025.wasm | bin | 585365 -> 0 bytes |
7 files changed, 34 insertions, 2 deletions
@@ -1 +1,2 @@ /target +/www/slgj-2025.wasm diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3defb88 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/rust_lisp"] + path = vendor/rust_lisp + url = ssh://git.henriquelalves.com:23231/00.public/forks/rust_lisp @@ -231,6 +231,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a651516ddc9168ebd67b24afd085a718be02f8858fe406591b013d101ce2f40" [[package]] +name = "rust_lisp" +version = "0.18.0" +dependencies = [ + "cfg-if", +] + +[[package]] name = "simd-adler32" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -241,6 +248,7 @@ name = "slgj-2025" version = "0.1.0" dependencies = [ "macroquad", + "rust_lisp", ] [[package]] @@ -4,4 +4,5 @@ version = "0.1.0" edition = "2021" [dependencies] -macroquad = "0.4"
\ No newline at end of file +macroquad = "0.4" +rust_lisp = { path = "vendor/rust_lisp" }
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 6b82d49..dbc60fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,27 @@ use macroquad::prelude::*; +use std::{cell::RefCell, rc::Rc}; + +use rust_lisp::default_env; +use rust_lisp::parser::parse; +use rust_lisp::interpreter::eval; + #[macroquad::main("BasicShapes")] async fn main() { + // create a base environment + let env = Rc::new(RefCell::new(default_env())); + + // parse into an iterator of syntax trees (one for each root) + let mut ast_iter = parse("(+ \"Hello \" \"world!\")"); + let first_expression = ast_iter.next().unwrap().unwrap(); + + // evaluate + let evaluation_result = eval(env.clone(), &first_expression).unwrap(); + + // use result + println!("{}", &evaluation_result); + loop { clear_background(RED); @@ -10,7 +29,7 @@ async fn main() { draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN); draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW); - draw_text("IT WORKS!", 20.0, 20.0, 30.0, DARKGRAY); + draw_text(&format!("IT WORKS! {}!", &evaluation_result), 20.0, 20.0, 30.0, DARKGRAY); next_frame().await } diff --git a/vendor/rust_lisp b/vendor/rust_lisp new file mode 160000 +Subproject e0f571bd9575eb79d0dbd75552c605eaa86a6e2 diff --git a/www/slgj-2025.wasm b/www/slgj-2025.wasm Binary files differdeleted file mode 100755 index 93909fc..0000000 --- a/www/slgj-2025.wasm +++ /dev/null |