FTH Forth Scripting |
|---|
Download from Sourceforge
Documentation
Fth
is a BSD licensed free software package
which includes the interpreter
fth
and the
extension library
libfth.
You can use Fth as a
command line interpreter like Awk, Perl, or Ruby, you can write Forth
scripts, use the repl for interactive input or you can link the libfth
into an application using Fth as an extension language.
Fth's core language is Ficl, Forth-inspired command language, written by John Sadler . The manipulated Ficl source is included in Fth's source tree. The original Ficl source is slightly modified because of Fth' special needs.
Fth has the following ANS Forth labels:
| Label | Value | Label | Value |
|---|---|---|---|
| core | yes | core-ext | yes |
| /counted-string | 1024 | /hold | 1024 |
| /pad | 1024 | address-unit-bits | 8 |
| floored | no | max-char | UCHAR_MAX (0xFF) |
| max-n | 0x7FFFFFFF | max-u | 0xFFFFFFFF |
| stack-cells | 1024 | return-stack-cells | 1024 |
| exception | yes | exception-ext | yes |
| file | yes | file-ext | yes |
| floating | yes | floating-ext | yes |
| floating-stack | 0 | max-float | Infinity (GMP) or MAXFLOAT |
| locals | yes | locals-ext | yes |
| #locals | 2048 | memory-alloc | yes |
| search-order | yes | search-order-ext | yes |
| wordlists | 32 | tools | yes |
| tools-ext | no | double | no |
| double-ext | no |
Fth' double word set doesn't eat two stack entries and the so called double word numbers are actually ficl2Integers.
The Fth library contains at most object type extensions, for example arrays, hashs, strings, regexp and others. A garbage collector handles the memory management of object types.
If you are new to Forth, a very good introduction to the programming language Forth can be found in the Gforth distribution. The description of the Gforth language fits generally to Ficl/Fth.
You can get the latest fth-1.2.8.tar.gz or fth-1.2.8.tar.bz2 from http://sourceforge.net/projects/fth/ . If you prefer anonymous CVS, the following example may show the way. The first time you have to checkout the whole source tree, but afterwards a CVS session is much simpler:
% mkdir ~/src
% cd ~/src
% cvs -z3 -d:pserver:anonymous@fth.cvs.sourceforge.net:/cvsroot/fth co -P fth
A new directory ~/src/fth now exists with a copy of the source tree of Fth. Later on, say, two days later, you have to type only
% cd ~/src/fth
% cvs update -P -d
The -P option means prune empyt directories and the -d option means create directories. One can write CVS options to ~/.cvsrc.
% cat ~/.cvsrc
update -Pd
So the commands above are reduced to
% cd ~/src/fth
% cvs update
Happy Forthing!
| Web Hosting by sourceforge | DNS Hosting by zoneedit | IPv6 by GO6 | Gateway6 v5.0 Gateway6 |
|