BAK: It's Not Forth

The only source file extension BAK recognizes is ".bak" (or ".BAK"),
and the BAK interpreter enforces this. This guarantees some confusion with
automatically generated backup files.

The only data type in BAK is the pointer, but it shall be referred to
as the 'BAKword'. Every BAKword points to a character, but it shall be
referred to as the BAKword's 'reverse'. These BAKwords are kept on a data
structure called the 'LIFO'.

The position starts at the first reverse of the program. After executing the
feature at the position, the position is incremented unless the feature
otherwise specifies. Data space is identical to program space.

A BAK program may end only if it reaches the point exactly after the last
position, with the LIFO in its original state.

BAK has an unlucky number of instructions: 13. It is hard to say whether
the unlucky properties apply to the programmers or implementers. These
thirteen features are described by name below.

The here feature ($) takes the position as a BAKword and adds it to the LIFO.

The there feature (:) pulls a BAKword from the LIFO and sets the current
position to it.

The low feature (<) pulls two BAKwords from the LIFO and replaces the lower one.

The high feature (>) pulls two BAKwords from the LIFO and replaces the higher
one.

The math feature (;) pulls three BAKwords from the LIFO and replaces the third
after adding the second subtracted from the first.

The attract feature (+) pulls two BAKwords from the LIFO and hides a datum from
the source in the reverse of the second BAKword, unless the source is dry, in
which case the position becomes the first BAKword.

The repel feature (-) dumps the reverse of a BAKword pulled from the LIFO in the
sink.

The toss feature (@) pulls three BAKwords from the LIFO, and starting at the
second searches for the reverse of the third, incrementing, and ending either
at the first or when the reverse of the third is found. It then adds the
resulting BAKword to the LIFO.

The send feature (=) pulls two BAKwords from the LIFO, and replaces the reverse
of the first with the reverse of the second.

The breed feature (*) pulls a BAKword from the LIFO and replaces it twice.

The twiddle feature (/) pulls two BAKwords from the LIFO and replaces the first
and second, in that order.

The twoddle feature (\) pulls three BAKwords from the LIFO and replaces the
first, third, and second, in that order.

The trash feature (!) pulls a BAKword and shreds it.

Any feature not on this list is silently overlooked. The float (.) is commonly
used for this purpose.

Credits for the BAK programs:

BAK.c           Prfnoff         The portable BAK interpreter.
BAKref.txt      Prfnoff         This file, of course.
cat.bak         Prfnoff         A BAK program that copies its input to its output.
cat2.bak        Martin Harper   A shorter version of the 'cat' program.
hello.bak       Prfnoff         'Hello, world' in BAK (programmed lazily).
hello2.bak      Prfnoff         'Hello, world' written in 'while loop' style

"This has *serious* potential. I like it *a lot*." - Simon Cozens
"Fascinating. I know some LISP programmers who would love it." - John Dallman
"This looks very interesting." - Claudio Calvelli, CLC-INTERCAL author

-- Prfnoff

