Register ( as immediate, add char literal 'x' parsing, fix ALLOCATE/RESIZE
- 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)
This commit is contained in:
@@ -1856,6 +1856,9 @@ impl ForthVM {
|
||||
dec.parse::<i64>().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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user