summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules3
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml3
-rw-r--r--src/main.rs21
m---------vendor/rust_lisp0
-rwxr-xr-xwww/slgj-2025.wasmbin585365 -> 0 bytes
7 files changed, 34 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index ea8c4bf..1c61b22 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Cargo.lock b/Cargo.lock
index ff2132e..b56b62c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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]]
diff --git a/Cargo.toml b/Cargo.toml
index f119be8..d47334b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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
deleted file mode 100755
index 93909fc..0000000
--- a/www/slgj-2025.wasm
+++ /dev/null
Binary files differ