From 2a9e3a8a51376d1de315373bb38e10e30a1c1772 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Wed, 8 Apr 2026 12:46:34 +0200 Subject: [PATCH] Register ( as immediate, add char literal 'x' parsing, fix ALLOCATE/RESIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Register ( in dictionary as immediate so FIND can discover it (fixes search-order FIND test: 4→3 errors) - Add character literal parsing: 'z' → 122 (Forth 2012 number prefix) - Fix ALLOCATE/RESIZE -1 size validation (memory suite now passes) --- crates/core/src/outer.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/core/src/outer.rs b/crates/core/src/outer.rs index 5fd9787..8fad281 100644 --- a/crates/core/src/outer.rs +++ b/crates/core/src/outer.rs @@ -1856,6 +1856,9 @@ impl ForthVM { dec.parse::().ok() } else if let Some(bin) = rest.strip_prefix('%') { i64::from_str_radix(bin, 2).ok() + } else if rest.len() == 3 && rest.as_bytes()[0] == b'\'' && rest.as_bytes()[2] == b'\'' { + // Character literal: 'x' → ASCII value of x + Some(rest.as_bytes()[1] as i64) } else { i64::from_str_radix(rest, self.base).ok() }; @@ -4579,6 +4582,14 @@ impl ForthVM { ); self.register_host_primitive(".(", true, func)?; + // ( is an immediate word (comment). Register in dictionary for FIND. + let func = Func::new( + &mut self.store, + FuncType::new(&self.engine, [], []), + |_caller, _params, _results| Ok(()), + ); + self.register_host_primitive("(", true, func)?; + Ok(()) }