esolang

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

Expected: Hello, World!

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

StatementDoes
X is 3Assign a number, a "string", Input or a sum
X is added X is subtractedCount up or down by 1
Say XPrint a value and a line feed
If ... then ... end IfRun when the condition holds; Else If and Else then may follow
For (Initialization is ... and Termination is ... and Increment is ...) then ... end ForJava's for loop
endEnd the program
CommentA comment to the end of the line
Block-Comment is ... end Block-CommentA 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.

Expected: 0 1 1 2 3 5 8 13 21 34 55 89

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.

Expected: YOU

Input reads one line.

Expected: Hello, Baba

Further

Ideas it shows

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-program

Source

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