summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-08-22 13:38:47 -0400
committerBrian Cully <bjc@spork.org>2025-08-22 14:42:36 -0400
commit79441128958669b16ce8dfe39a3684069921f604 (patch)
tree4112092916e7bf568cc67e6bcd0621779e2d6eae /src/lib.rs
parent4f7bbbf4ee269ef6638c69fc5982b0dfe4b8b947 (diff)
downloadautomathon-79441128958669b16ce8dfe39a3684069921f604.tar.gz
automathon-79441128958669b16ce8dfe39a3684069921f604.zip
make compile button actually compile
Diffstat (limited to 'src/lib.rs')
-rwxr-xr-xsrc/lib.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 716ad09..f4fc294 100755
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,7 +2,7 @@ use log::{Level, debug, info};
use console_log;
use wasm_bindgen::prelude::*;
-mod forth;
+pub mod forth;
#[wasm_bindgen]
extern {
@@ -11,8 +11,13 @@ extern {
}
#[wasm_bindgen]
-pub fn compile() {
- info!("compiling code");
+pub fn compile(text: &str) {
+ info!("compiling code: `{}`", text);
+ let mut p = forth::parser::Parser::new(&text);
+ p.parse().expect("couldn't parse text");
+ debug!("wordlist: {:?}", &p.wordlist);
+ let interp = forth::interp::Interp::new(p.wordlist);
+ debug!("interp: {:?}", interp);
}
#[wasm_bindgen]
@@ -28,17 +33,7 @@ pub fn run() {
#[wasm_bindgen(start)]
pub fn init() -> Result<(), JsValue> {
console_log::init_with_level(Level::Debug).expect("couldn't init console log");
- debug!("starting run");
-
- let window = web_sys::window().expect("no global `window` exists");
- let document = window.document().expect("should have `document` on window");
- let body = document.body().expect("document should have `body`");
-
- let val = document.create_element("p")?;
- val.set_text_content(Some("hi there"));
- body.append_child(&val)?;
-
- debug!("done in rust's run");
+ info!("wasm init");
Ok(())
}