# PaRappa

Jump to navigation
Jump to search

**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) | Outcome |
---|---|

"□" | Moves the pointer to the right once. |

"○" | Moves the pointer to the right once. |

"△" | Moves the pointer to the right once. |

"✕" | Moves the pointer to the right once. |

"R" | Moves the pointer to the right once. |

"L" | Moves the pointer to the right once. |

"·" | 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. |

" " | 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. 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. |

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

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