Bauberqueue
Paradigm(s) | Post-like |
---|---|
Designed by | User:Quintopia |
Appeared in | 2017 |
Computational class | Turing complete |
Reference implementation | See below |
Influenced by | Aubergine, Resplicate |
File extension(s) | .bbq |
Bauberqueue is a queue-based language created by User:Quintopia in 2017. It takes the data storage and syntax principles of Aubergine but replaces the single tape with a list of queues. It replaces Aubergine's conditional jump with a Resplicate-like subqueue duplication command.
The Queues
A Bauberqueue program mixes instructions and data in the same space as queues of unbounded integers. There is one queue corresponding to each integer (positive, negative, or zero). When a program is read, each of the n lines of the program is read in order into the first n queues (numbered 1-n) and all other queues are initially empty. Each line is pushed character-by-character into its queue from front to back except for any trailing whitespace, such as newline characters.
Popping an empty queue always yields the value zero.
The queue numbered zero is always empty. Any data pushed to it is immediately discarded.
Escaping Characters
Programs may contain backslash-escaped characters. All standard backslash-escaped characters are supported, such as \n, \t, \\. Non-printable characters can be encoded with \x<hex byte>.
Registers
Like Aubergine, Bauberqueue has three mutable registers, called "a", "b" and "i". "a" and "b" are initialized to zero and "i" is initialized to 1. These registers can hold any integer value.
All of these registers can be dereferenced by capitalizing their names: "A", "B", or "I". Used this way, they refer to the queue assigned the number in that register. (For instance, I always refers to the queue from which code is currently being executed.)
There is also an immutable register "1". It cannot be set and always contains the value 1.
Input/Output
Using "o" as the source of a command reads a byte from stdin. Using it as the target of a command prints a character to stdout. "O" is not valid.
Execution cycle
On each cycle, three values are popped from the queue number referred to by register "i" and interpreted as a command that is then executed. If the values do not correspond to a legitimate command, execution ends immediately.
Commands
Every command has a target and a source. Usually, these will be the actual location the values will be read from and written to. In the case of subqueue duplication, these will both be read, and their values used as references to source and target queues. Sources can be "a", "b", "i", "A", "B", "I", "o", or "1". Targets can be "a", "b", "i", "A", "B", or "o". Getting the value of "A", "B", or "I" will cause a value to be popped from the corresponding queue. Setting a value to "A", "B", or "I" will cause a value to be pushed to the corresponding queue.
Name | Syntax | Description |
---|---|---|
Assignment | = <target> <source> | Set the target to the source's value. |
Increment | + <target> <source> | Add the source's value to the target's value and set the target to the result. |
Decrement | - <target> <source> | Subtract source's value from the target's value and set the target to the result. |
Subqueue Duplication | <target queue> <source queue> <count> | Pop a sequence of count values from the source queue and push this sequence to the target queue twice. |
Examples
Hello, world!
Here are three versions of Hello, World!, each more complex than the previous.
This one just contains 14 consecutive writes to output:
+a1+a1=oA=oA=oA=oA=oA=oA=oA=oA=oA=oA=oA=oA=oA=oA Hello, World!\n
This one uses a list of characters as a unary encoding of when to loop the output command:
+i1\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06 +a1+a1+a1=b1iiB=oAiiB Hello, World!\n
This one uses the "b" register to count the number of loops of the output command:
=b1=bB\x11=a1=aA\x19+aB-b1iia=a1+a1=oA=a1=aA\x19+aB-b1iia Hello, World!\n !
Truth-machine
=ao-aI.=ia =oI0 iiI\x08=oI1iiI\x08
Counting up in unary
=b1=bB\x05=a1+a1aaAiaA " -a1-a1aiI +a1=oA1-b1+a1+aBaaAiaA" 1/-a1-a1-a1aiI/=oI\n=B1=ab=aA+a1=Ba=ba=a1+a1aaAiaA1 \x01\x05
Bootstrap Quine
This program outputs a Bauberqueue quine. Encoding said quine using Python's "encode('string_escape')" produces this program.
-a1aiI<=bIy=oI-=oIa=oI1=oIa=oIi=oII=oI<iiI\r=oA-b1+iBiiI\rBiI\x07-a1aiI<=bIy=oI-=oIa=oI1=oIa=oIi=oII=oI<iiI\r=oA-b1+iBiiI\rBiI\x07-a1aiI<
Reference Implementation
In Python, by User:Quintopia: Bauberqueue/bauberqueue.py