"Pocket Forth manual.V0.6.5" - читать интересную книгу автора (Heilman C.)

Pocket Forth has a simple interpreter that can execute code or compile it into
a dictionary for later execution. Source code text is typed from the keyboard,
pasted from the clipboard or loaded from a file. The text is interpreted one
line at a time. When the line is completed an 'ok' prompt appears and the
input sequence restarts.

The text interpreter parses tokens from the input line (also called the input
stream). Tokens are any group of characters, excluding space, tab and carriage
return. Individual tokens are separated from each other by one or more spaces.
Carriage return signals the end of the line.

Each token of a line is looked up in a dictionary. The dictionary is a list of
named subroutines, called words. Each of these words does a part of the
program in a reusable subroutine. Words can be called by the interpreter or
compiled into larger words.

In executing mode, the word's subroutine is run and the interpreter continues
with the next token. Tokens not found in the dictionary are converted to a
value. If the token is not a valid integer or floating point number, an error
is signaled by printing a question mark and the unrecognized token.

Some words place the interpreter into compile mode. When in compile mode, new
words are defined. Words are written into the dictionary as machine language
subroutines. Thus, Pocket Forth produces subroutine threaded code. A program
is built by factoring an algorithm into its parts, then defining words that
assemble those parts into code. (12)

Here is the structure of the interpreter:

[figure 1]

Text Files

Typing into the Pocket Forth window supplies text to be interpreted. None of
what is typed is saved, so write programs with an editor.

Pocket Forth does not use Forth's traditional block input, rather it
interprets normal text files. This allows program source files to be prepared
with your favorite text editor and tools. Which editor you choose will depend
on memory available and personal preference.

On Macintoshes with MultiFinder or System 7, the Pocket Forth application runs
in multitasking mode. A 64K byte segment is the minimum, but 128K bytes or can
be used. This allows Pocket Forth to run simultaneously with an editor.
Accessory editors can be used with Pocket Forth on even the smallest
Macintosh.

Text from a file can be interpreted by Pocket Forth from the clipboard via
copy and paste, or directly from the file. You may select and copy text from a
source file and paste it into the Pocket Forth window. The pasted text is