# PaRappa

PaRappa is an esoteric programming language that is based on the rhythm game "PaRappa The Rapper 2". The code is meant to look like the gameplay. It is nearly identical to Eek!, the esolang that it is a derivative of.

## Commands

Command (no quotation marks) Name outcome
"□" Square Moves the pointer to the right once.
"○" Circle Moves the pointer to the right once.
"△" Triangle Moves the pointer to the right once.
"✕" X Moves the pointer to the right once.
"R" Right Moves the pointer to the right once.
"L" Left Moves the pointer to the right once.
"·" Dot Increments the cell that the pointer is on by 1. Set the cell to 15 if the value stored in it is greater than 15.
" " Space Move the pointer to the right once, then set the cell that the pointer is on to 16.

## Explanation

In PaRappa, the commands "□", "○", "△", "✕", "R", and "L" will move a pointer on an array of cells to the right once. The command "·" will add 1 to the cell that the pointer is on. The language will then interpret the numbers in the array as instructions that it executes. It will start on cell 0, and move to the right. The language usually moves forward one cell before interpreting a number as an instruction. An exception to this is when you use the commands associated with the numbers 10 and 11. If the language moves forward two cells after the command is interpreted, it will interpret the command it is on without moving forward again (if is a 10 or 11, it will move forward.). Another thing to keep in mind is that when command associated with the number 5 causes the language to move backwards, the language will move forward one cell before interpreting an instruction if the instruction's number is lower than 5. Below is the list of numbers that the language will interpret as instructions.

## Numbers

Number Instruction
0 Increment the accumulator.
1 Increment the value at the top of the stack by 1.
2 Increment the value at the top of the stack by 10.
3 Print the ASCII character associated with the value at the top of the accumulator.
4 Set the value at the top of the stack to the ASCII value of one byte of input.
5 Move the pointer on the array that holds the instructions backwards a number of cells equal to the value in the accumulator.
6 Push 0 onto the stack.
7 Pop the value off the top of the stack a random amount of times, the highest possible amount of times is equal to the value in the accumulator minus 1.
8 Move the pointer on the array that holds the instructions forwards a number of cells equal to the value in the accumulator.
9 Pop the value off the top of the stack.
10 Move the pointer on the instruction array to the right 2 times if the value at the top of the stack is equal to the value in the accumulator.
11 Move the pointer on the instruction array to the right 2 times if the value at the top of the stack is not equal to the value in the accumulator.
12 Decrement the accumulator
13 Set the value in the accumulator to 0.
14 Set the value in the accumulator to the value at the top of the stack.
15 Push the value in the accumulator to the top of the stack.
16 Terminate the program.

## Example programs

Cat program.

```□□○○····△···✕·····
```

Simple slot machine game. Match 3 characters to win.

```△✕△··△··□··△·✕·△·R·△·L·△······△··□··□··△·△·△·L·△·△·△·△·······△·□···△······□······△··△··✕··△·△·□·□·□·△·△······△··□··△··△·△·✕·✕·△·△·□·△·······
△·△···□······△······△··□··△··△·△·△·△·R·L·R······△··△··△··△·□·△·□·△·□·△·△·······△·✕···
```

Truth machine.

```✕○✕✕□✕✕✕✕✕✕□✕✕✕○○○✕✕□□□□□✕✕✕✕○✕✕○✕✕✕□✕○○✕✕□□✕✕✕✕✕✕
····□···△··········
△·············□○✕···○·····
```

## Interpreter

Source code (written in Ruby)

```eval '\$m=Hash.new(\$p=0); \$q=Hash.new(\$d=0); \$h=Hash.new(\$j=0); (\$r=0); (\$f=0);'+ARGF.read.gsub(/./,
'□' => '\$p+=1;',
'○' => '\$p+=1;',
'△' => '\$p+=1;',
'✕' => '\$p+=1;',
'R' => '\$p+=1;',
'L' => '\$p+=1;',
'·' => '\$m[\$p]+=1; \$m[\$p]=15 if \$m[\$p]>15;', #<- Remember to change this when making new commands
' ' => '\$p+=1; \$m[\$p]+=16;',)
\$p=0
while 0==0
\$p+=1
\$p+=2 if \$m[\$p]==10 and \$q[\$d]==\$r
\$p+=2 if \$m[\$p]==11 and \$q[\$d]!=\$r
\$r+=1 if \$m[\$p]==0
\$q[\$d]+=1 if \$m[\$p]==1
\$q[\$d]+=10 if \$m[\$p]==2
putc \$q[\$d] if \$m[\$p]==3
\$q[\$d]=STDIN.getbyte if \$m[\$p]==4 and !STDIN.eof
\$p-=\$r if \$m[\$p]==5
\$d+=1 if \$m[\$p]==6
\$q[\$d]=0 if \$m[\$p]==6
\$d-=rand(\$r) if \$m[\$p]==7
\$p+=\$r if \$m[\$p]==8
\$d-=1 if \$m[\$p]==9
\$r-=1 if \$m[\$p]==12
\$r=0 if \$m[\$p]==13
\$r=\$q[\$d] if \$m[\$p]==14
\$d+=1 if \$m[\$p]==15
\$q[\$d]=\$r if \$m[\$p]==15
exit if \$m[\$p]==16
end
```