modules/lang/forth.zzm

lang-forth-0.0.2 documentation

Package

Name
lang-forth
Version
0.0.2
Uploaded
2026-06-12 23:11:04
Repository
https://github.com/tobyink/zuzu-lang-forth
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

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 source in a new ForthSystem and returns captured output.

  • forth_system(Dict options?)

    Returns a fresh ForthSystem with the standard dictionary installed.

  • parse_forth(String source, String source_name?)

    Tokenizes source text and returns ForthToken values.

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.