NAME
lang/forth - Interpret ANS Forth-style source.
SYNOPSIS
from lang/forth import forth, forth_system;
say( forth(": square dup * ; 9 square .") ); # 81
let system := forth_system();
system.evaluate("variable x 41 x ! x @ 1+ .");
say( system.output() ); # 42
DESCRIPTION
This module implements a small pure-Zuzu ANS Forth-oriented interpreter. It provides the ordinary data stack, return stack, dictionary, colon definitions, variables, constants, values, memory cells, output capture, and a practical Core word set.
The implementation is intended for embedding Forth snippets and scripts inside ZuzuScript applications. It is not a native-code Forth system and does not expose implementation-defined address arithmetic beyond the managed cell store used by @, !, ,, and related words.
EXPORTS
forth(String source, Dict options?)Evaluates
sourcein a newForthSystemand returns captured output.forth_system(Dict options?)Returns a fresh
ForthSystemwith the standard dictionary installed.parse_forth(String source, String source_name?)Tokenizes source text and returns
ForthTokenvalues.
COPYRIGHT AND LICENCE
lang/forth is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.