esolang

PaRappa

A program is a line of button prompts from a rhythm game, and the beats between them are the code.

Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

PaRappa is meant to look like a level of PaRappa the Rapper 2, and is nearly the same as the language Eek!. The buttons □ ○ △ ✕ and the letters R and L all do the same thing, they step to the next cell. The dots between them count up the number in the cell. A space steps on and writes 16.

Read the story

Only then does the program run. A pointer walks the row of numbers, one cell a turn, and each number is an instruction for a stack and an accumulator. 0 counts the accumulator up, 3 prints, 4 reads, 10 and 11 skip ahead on a comparison, 5 and 8 jump by the accumulator, 16 stops. A run of empty cells sets the accumulator, since every 0 adds one to it on the way past.

The machine

NumberDoes
0Accumulator up by one
1, 2Top of the stack up by 1 or 10
3, 4Print the top as a byte; read a byte into it
5, 8Pointer back or forward by the accumulator
6, 9, 15Push 0; pop; push the accumulator
7Pop a random number of times
10, 11Skip two cells if the top equals the accumulator, or does not
12, 13, 14Accumulator down; to 0; to the top
16Stop

The specification gives a Ruby interpreter. It tests the cell again after every instruction, so after a jump the higher numbers act on the new cell in the same turn.

Example

The truth machine.

The truth machine. Its first line is 50 buttons and no beats, so the accumulator reaches 49, the code of 1, before the read.

Read 0, print it, compare it with 49, fall onto the 16 and stop. On 1 the comparison skips the 16, the accumulator starts again from 0 and counts to 2, and a jump back by 2 loops on printing 1.

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from PaRappa

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: parappa.

Command line

shib run parappa -e '✕○✕✕□✕✕✕✕✕✕□✕✕✕○○○✕✕□□□□□✕✕✕✕○✕✕○✕✕✕□✕○○✕✕□□✕✕✕✕✕✕
····□···△·········· 
△·············□○✕···○····· ' --input '0'
shib manual parappa

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/parappa.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org