PPAP is a (maybe yet another) programming language inspired by https://www.youtube.com/watch?v=0E00Zuayv9Q
I have 80 Pen I have 65 Apple Uh! Put-Pen Uh! Put-Pen Uh! Put-Apple Uh! Put-Pen
I have a Pen I have an Apple Apple-Pen Uh! Pick-Pen # Read a character Uh! Put-Pen # Print the character Uh! Jump-Apple-Pen # Loop
How to run
This implementation is written in Ruby.
$ git clone https://github.com/yhara/ppap-lang/ $ bundle install $ bundle exec ppap exec examples/ppap.ppap PPAP
- Unlimited number of registers
- 24-bits wide memory (initialized with 0)
- A PPAP program is executed line by line
- Define range of a register value
# This is comment I have an Apple # This is also comment
Registers must be declared before use. For example, the following code
declares a register
Pen with 5 as its initial value. (Note that register name must be singular even when the value is more than 1, and register value must be >= 0.)
I have 5 Pen
Name of a register must:
- start with A-Z
- consist of A-Z, a-z, 0-9
- include 'p' or 'P'
- not a command verb (Replace, Compare, etc.)
There are some special forms for register value 0 and 1.
I have no Pinapple # Pinapple == 0 I have Pinapple # Pinapple == 1 I have a Pinapple # Pinapple == 1 I have an Pinapple # Pinapple == 1
Register values are always parsed as decimal, even when it starts with '0'.
It is allowed to declare a register with the same name. In this case, the latter will overwrite the register value.
I have 3 Pen # Pen == 3 I have 5 Pen # Pen == 5
Labels are names joined with
-. Each name must be previously declared as a register (You cannot set a label Apple-Pen when you don't have at least 1 Apple and Pen.)
I have a Pen I have an Apple Apple-Pen # A label I have a Pinapple Pen-Pinappple-Apple-Pen # Another label
You can optionally prefix
Uh! to a label.
I have a Pen I have an Apple Uh! Apple-Pen
It is an error when two labels of the same name are declared.
A command execution starts with
Uh! and a specific verb corresponding to the command described below.
Change the value of A to the value of B
I have a Pen I have 5 Apple Uh! Replace-Pen-Apple # Pen == 5
A += B
A -= B
A *= B
A /= B
Store the value of A to memory address B
Load the value of memory address B into register A
Print the value of A as a number
I have 97 Apple Uh! Print-Apple #=> 97
Print the character whose character code is A
I have 97 Apple Uh! Put-Apple #=> a
Put can take more than one arguments.
I have 97 Apple Uh! Put-Apple-Apple-Apple #=> aaa
Read a character from stdin and store its code to A
A = (A == B ? 1 : 0)
Jump to C if A == B
Compare performes NE when suffixed
A = (A != B ? 1 : 0)
!? when you also want to jump (note:
?! is not allowed.)
Jump to C if A != B
A = (A > B ? 1 : 0)
Jump to C if A > B
A = (A >= B ? 1 : 0)
Jump to C if A >= B
Jump to C
- Let me know if you have a nice keyword for LT/LE or MOD (it must include 'p')