qo
Brainfuck with a stack beside the tape, where every letter pushes itself.
SplittyDev, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
SplittyDev made qo in 2015, and its specification calls it a stack-based brainfuck. It keeps brainfuck's eight commands and adds a stack, doubling and halving, and a program counter that a cell can hold. Every letter, ! and ? pushes its own character code, so text goes onto the stack as it is written and comes off in reverse. The specification calls it a wonderful language with a terrible syntax, made to counter another language, JacobFck.
The machine
| Command | Does |
|---|---|
> < + - . , [ ] | As in brainfuck |
* / | Double or halve the cell |
: ; | Push the cell; pop into the cell |
& \ @ | Duplicate the top; swap the top two; reverse the stack |
# | Write the stack's size to the cell |
= | Pop two and write 1 if they were equal, else 0 |
^ | Pop a cell number and move the pointer there |
( ) | Loop while the top of the stack is not 0 |
letters, !, ? | Push the character code |
% $ _ | Write the next position to the cell; jump to the cell's position; write the end's position |
' | Comment to the end of the line |
Cells are 32-bit integers. The specification leaves the end of input open, and it reads as 0. Positions count commands only, so comments and spaces do not move them.
Example
The Hello World pushes the letters, then @ reverses the stack and # counts it into a cell.
The Hello World pushes the letters, then @ reverses the stack and # counts it into a cell. A loop counts that cell down and pops and prints one letter a turn. The specification says it prints Hello World!, but world! pushes a lowercase w.
Without the @ the letters come off in reverse.
% keeps the position of the > after it in a cell, and $ jumps back there while the counter is not 0.
A cat for an end of input that reads as 0.
Patterns it teaches
- Turing tarpit: brainfuck with a stack and a jump added.
- Stack machines: text goes onto a stack and comes off reversed.
Further
See also
Brainfuck
Cell-based
Write your own in Run Convert a program from qo
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: qo.
Command line
shib run qo -e ',[.,]' --input 'cat'shib manual qoSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/qo.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org