Bedtime
The program is a bedtime story, and the interpreter is a small child who refuses a boring one.
PixelatedStarfish, 2021 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
PixelatedStarfish made Bedtime in 2021, after Beatnik, Shakespeare and Rockstar. A source file is a story. The interpreter turns it into Nondescript, a small stack language with 13 opcodes, and runs that.
Read the story
What sets it apart is the listener. If one word comes more than three times in a sentence, the story is boring and the child refuses it. Words under three letters and "the" are exempt. Every error is a critique from the child, such as asking for water when the stack is empty.
The machine
A fragment is a run of words up to a stop, one of . , ! ; ?. The last word, touching the stop, is the opcode, and its number is its length. The words before it are the argument, one digit per word, so Hi sweet doggy is 255. A ? makes the argument negative, and a word next to ... counts as 0. Text in double quotes is printed as it stands, and parentheses hold comments.
| Length | Does |
|---|---|
| 0 | Print the top of the stack as a number |
| 1 | Print the argument as a character |
| 2 | Print the top as a character |
| 3, 4 | Pop; push the argument |
| 5 | Add the argument to the top, or 1 |
| 6, 7, 8 | Label; go to a label; go to it if the top is 0 |
| 9 | Read a character |
| 10, 11, 12 | Duplicate; shuffle the stack; halt |
Example
The truth machine.
The truth machine. Charlie's has nine letters, so it reads a character. What could've ended? adds 48 with the sign turned, as "What" and "could've" give the digits 4 and 8. Forgives, jumps to label 0 if that left 0, and Bowser, with no argument is label 0. On 1 the story falls into a loop of Love spiritual O!, which prints character 49, and A teacher., which goes back to label 1.
A story with three of the same word is fine, and the printable at its end is read out. With a fourth "very" the child refuses the whole story before it starts, and nothing is printed.
Patterns it teaches
- Camouflage: the source has to read as a story, and a dull one fails.
- Encoding tricks: numbers are word lengths, digit by digit.
- Stack machines: underneath it is Nondescript, one stack and 13 opcodes.
Further
See also
Pseudonatural
Stack-based
Write your own in Run Convert a program from Bedtime
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: bedtime.
Command line
shib run bedtime -e '"?"'shib manual bedtimeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/bedtime.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org