Baba Is Program
Programs written as the rules of Baba Is You. BABA IS YOU is an assignment.
2019 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Baba Is Program comes from the puzzle game Baba Is You, whose rules are sentences such as BABA IS YOU. In Baba Is Program is does almost everything. X is 3 assigns, X is added counts up, and after If the same words compare. The specification says the rest is mostly based on Java, and it gives the Java for two of its examples.
Read the story
The tutorial in the specification is itself a program. Its prose sits in Comment lines and in Block-Comment is blocks, and a bare end stops it before its last lines.
The machine
| Statement | Does |
|---|---|
X is 3 | Assign a number, a "string", Input or a sum |
X is added X is subtracted | Count up or down by 1 |
Say X | Print a value and a line feed |
If ... then ... end If | Run when the condition holds; Else If and Else then may follow |
For (Initialization is ... and Termination is ... and Increment is ...) then ... end For | Java's for loop |
end | End the program |
Comment | A comment to the end of the line |
Block-Comment is ... end Block-Comment | A comment over many lines |
Values join with plus and minus, and plus joins text when either side is a string. A condition compares with is, is less than or is greater than, the last two also with or equal to, and conditions join with and and or. A line end or the word and parts two statements, and keywords may be written in any case.
Example
The Fibonacci program, without its comments.
The Fibonacci program, without its comments. The Termination is the condition to go on, as in Java, so the loop runs 12 times.
The lines in capitals from the end of the tutorial. BABA IS YOU copies the value of the variable YOU, and after IF the same three words compare.
Input reads one line.
Ideas it shows
See also
Also in Jokes
Write your own in Run Convert a program from Baba Is Program
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: baba-is-program.
Command line
shib run baba-is-program -e 'SAY "Hello, World!"'shib manual baba-is-programSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/baba-is-program.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org