Celum

Celum is a programming language invented by User:Zzo38 in 2006.
Each line can start with 0: or 1: and then a label name (not case sensitive, can even be blank or duplicates, can contain any ASCII character 33 to 126 except a colon), and then another colon, and then the commands of that line (white-space is ignored). Lines starting with c: or C: is comments. The memory is a unbounded tape in both directions, each cell can store one bit, all start with 0. Also one flag independent of the tape that stores one bit and starts with 0.
==Commands==
The valid commands are:
Command 	Description
hh 	Execute the elementary cellular automaton rule identified by the Wolfram code corresponding to the decimal value of two hexadecimal digits hh on the entire tape.
{ 	Invert the value of the bit in the middle of tape and then search upwards in the program for a line with the new value of the middle bit at the beginning and start to execute that line. If no such line can be detected, an error is signaled.
} 	Invert the value of the bit in the middle of tape and then search downwards in the program for a line with the new value of the middle bit at the beginning and start to execute that line. If no such line can be detected, an error is signaled.
i 	Input one bit to the middle of the tape utilizing an octet-sized input buffer. If this buffer is empty, query the standard input conduit for an ASCII character and store its bits in the buffer, upon each i request transferring the next bit unto the tape, proceeding from the buffer's least significant to its most significant position. If the highest-valued bit has been copied, the input buffer is purged and rendered empty.
o 	Output the bit in the middle of the tape utilizing an octet-sized output buffer. If the output buffer is not complete, with each invocation of o the tape bit is copied to the buffer's current position, proceeding from the least significant to most significant location. Upon the buffer's completion, the character whose ASCII code answers to the constructed byte's decimal value is printed to the standard output, while the position cursor is reset to the least significant location.
? 	If the program's bit flag is zero, the rest of the line is not executed.
!labelName	Invert the value of the program's bit flag, and then go to the line identified by a label with the labelName. Searches forward in the program, commencing with the line immediately below the currently processed one, and wraps around from beginning. If you go to an undefined label then the program is terminated. This must be last command on a line.
The program flow starts from the first line and will go to the next line, and terminate at the end of the last line, if it doesn't jump anywhere.
== Examples ==
=== Hello, world! ===
This program prints the message “Hello, world!” to the standard output:
 0::ooo}
 1::o}
 0::oo}
 1::o}
 0::o}
 1::o}
 0::o}
 1::o}
 0::oo}
 1::oo}
 0::ooo}
 1::oo}
 0::o}
 1::oo}
 0::ooo}
 1::oo}
 0::o}
 1::oo}
 0::o}
 1::oooo}
 0::o}
 1::oo}
 0::ooo}
 1::oo}
 0::o}
 1::o}
 0::ooooooo}
 1::o}
 0::oo}
 1::ooo}
 0::o}
 1::ooo}
 0::o}
 1::oooo}
 0::o}
 1::oo}
 0::oo}
 1::o}
 0::oo}
 1::ooo}
 0::ooo}
 1::oo}
 0::o}
 1::oo}
 0::ooo}
 1::o}
 0::oo}
 1::oo}
 0::o}
 1::o}
 0::oooo}
 1::o}
 0::ooo}
 1::o}
 0::o}
 1::o
=== One-time cat program ===
A one-time cat program is demonstrated below:
 0::ioioioioioioioio
=== Infinite cat program ===
A perpetually repeating cat program is defined as such:
 0::io!
=== Truth-machine ===
The following program realizes a truth-machine:
 0::i}
 C:As the center bit is flipped, an input of 0 generates a 1,
 C:and vice versa. In such a case, go to the line labeled
 C:as 'printZero'.
 1::!printZero
 C:As the center bit is flipped, an input of 1 generates a 0,
 C:and vice versa. In such a case, print the input bits, while
 C:concomitantly shifting the 8-bit section to the right and storing
 C:the bits in the correct order on the tape, ...
 0::}
 1:printOneInput:oF0ioF0ioF0ioF0ioF0ioF0ioF0ioF0!shiftBack
 C:... then shift the eight character bits back with the least
 C:significant position in the tape center, ...
 1:shiftBack:AAAAAAAAAAAAAAAA
 C:... and repeat the printing process --- this time eschewing the
 C:input buffer's employment. Finally, repeat with the back-shifting
 C:step above.
 1::oF0oF0oF0oF0oF0oF0oF0oF0!shiftBack
 0:printZero:0030oioioioioioioio
=== Infinite loop ===
A perpetual iteration is implemented in the following:
 0:jumpBack:!jumpForward
 1:jumpForward:!jumpBack
=== Command skipping ===
This program employs the command skipping instruction ? in order to prevent an infinite loop.
 0:start:!flagOn
 1:flagOn:!flagOff
 0:flagOff:?!start
== Convert Boolfuck to Celum ==
 C: +
 0::}
 1::
 C: ; (or .)
 0::o
 C: ,
 0::i
 C: >
 0::F0
 C: <
 0::AA
 C: [ (# must be replaced by a unique loop name)
 0:#0:33}
 1::33!x
 0::}
 1::!#1
 1:x:
 C: ] (# must be replaced by a unique loop name)
 0::!#0
 1:#1:33
==Interpreter==
* Common Lisp implementation of the Celum programming language.
Category:Languages
Category:2006
Category:Implemented