metanohi/site/projects/bito/README

87 lines
4.3 KiB
Plaintext
Executable File

▄▄▄▄▄ ▀ ▄ █ ▄█▀█▄ ▀▀▄ ▀▀█▀▀ ▄▀▀▀▀█
█ █ ▄▄▄ ▄▄█▄▄ ▄▄▄ █ █ █ █ █ █ █
█▄▄▄▄▀ █ █ █▀ ▀█ █ █▄ ▄█ █ █ ▄▀▀▀▀█
█ █ █ █ █ █ █ ▀▀▀ ▀▀█▀▀ ▀▀▀ █ █
█▄▄▄▄▀ ▄▄█▄▄ ▀▄▄ ▀█▄█▀ █ ▀ ▄ ▀▀▀▀▀
Bito is a programming language that aims to be easy to work with. Bito only
accepts ones and zeroes. All other characters will be ignored. A command in
Bito consists of two parts, the first part consisting of 1 bit and the second
part consisting of three bits. All first parts must be written from left to
right, while all last parts must be written from right to left. A last part
consisting of 011 must thus be written 110.
Bito saves data in a list containing an infinite numbers of memory cells. A
cell can hold only any number above or equal to 0. There are no limits on how
large numbers can be.
Tip: Writing comments with ones and zeroes will make code more difficult to
understand. Try to replace ones with uppercase "i"s and zeroes with
uppercase "o"s.
Available commands:
0 xxx Append xxx to current memory cell (as a string)
1 000 Print current number
1 001 Print current number as ASCII
1 010 Increment memory cell index
1 011 Decrement memory cell index
1 100 Start loop
1 101 Restart or end loop
1 110 Add value of previous cell to current cell (as an integer)
1 111 Write input from stdin to next cells and write length to current cell
Trying to print an unset number will result in an error. Trying to print a
number not in the ASCII range as ASCII text will also result in an error.
Loops will run the times specified by the current cell. If the value of the
current cell is either unset, 0 or 1, the loop will run only once, i.e. it will
not act as a loop. Specifying the value 2 or above will thereby make it a loop.
Because infinite loops are not possible in Bito, Bito does not suffer from the
Halting Problem.
Ending a loop when no loop has been started will not result in an error, nor
will starting a loop without ending it do so (though the loop will, in those
cases, not function as a loop). Also, nested loops cannot exist. When a loop
has been started, all subsequent attempt to start a new loop will be ignored,
until the loop has ended.
Trying to add the value of a previous cell to the current cell will result in
an error if the current cell is unset. If a previous cell is unset, its value
is -1, which makes it ideal for use in subtracting numbers.
How to print an "N" (ASCII 78, binary ASCII 1001110):
Short version:
0001100011100100
Long version:
0 Current cell: OOI
0 Current cell: OOIOOI
0 Current cell: OOIOOIIIO (i.e. IOOIIIO)
1 Print ASCII 78 (N)
100
011
100
100
Saving ones and zeroes as ASCII is meaningless, as it takes up much more space
than needed. It is therefore recommended to convert every 8 characters into a
byte. This will greatly reduce filesizes. If the number of characters in a file
isn't directly dividable with 8 (4, 12, 132, etc.), just append a command that
does not affect the the script too much -- like ending a loop (1 101). If this
command is called outside a loop, nothing will happen.
The above N-printing program would, in byte-form, take up two bytes instead of
its current 16 bytes. It would save the first byte with 24 as its value and the
second byte with 224 as its value (this is theoretically speaking -- as
compressed Bito files are basically still text files, it is normal to have a
newline character appended at the end of a file).
To run Bito programs, you can use the bitopret.py interpreter found in the
'interpreter' directory. This interpreter also functions as a Bito file packer,
i.e. it can compress Bito files.
You will find a set of example programs in the 'examples' subdirectory.
The Bito programming language was created by Niels Serup (metanohi.org). You
can contact Niels a <ns@metanohi.org>.
Updates to Bito are likely to appear at <http://metanohi.org/projects/bito/>.
This readme was written by Niels and was put into the public domain by him.
Date: 27 July 2009