forked from jontheapple/pikachu-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.txt
52 lines (31 loc) · 2.03 KB
/
syntax.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Copied from http://trove42.com/pikachu-syntax-rules/
Here are the syntax and language rules for the Pikachu programming language explained in the human language of English:
There are only 3 syntax elements – pi, pika and pikachu. Repeating the same syntax element 3 times in a row is not allowed.
Pikachu makes use of 2 pikachus(stacks) – Pi Pikachu and Pika Pikachu.
If a line ends with pi pikachu or pika pikachu, perform operations on that specified pikachu based on the commands preceding it:
pi pika
Add the top element of the pikachu to the next top element, and push the result on to the pikachu
pika pi
Subtract the top element of the pikachu from the next top element, and push the result on to the pikachu
pi pikachu
Multiply the top element of the pikachu to the next top element, and push the result on to the pikachu
pika pi
Divide the second top element of the pikachu by the top element, and push the result on to the pikachu
pika pikachu
Pop the value on top of the pikachu and print it.
pikachu pikachu
Pop the value on top of the pikachu and print its equivalent ASCII character.
*blank*
Pop the value on top of the pikachu.
*n number of terms*
Push the number of terms – n – on to the pikachu. Make sure that no syntax element pi, pika or pikachu is repeated 3 times in a row.
The following 4 commands operate on both the pi pikachu and the pika pikachu. Therefore, these lines also don’t need to end with the name of an individual pikachu:
pi pika
Copy the top of pi pikachu to pika pikachu.
pika pi
Copy the top of pika pikachu to pi pikachu.
pikachu pikachu
If the top of pi pikachu and pika pikachu are equal, go to line number n, where n is the number of terms in the immediate next line.
pika pika
If the top of pi pikachu and pika pikachu are inequal, go to line number n, where n is the number of terms in the immediate next line.
Note : Inputs are initially added to pi pikachu. To specify multiple inputs, separate them by spaces. The first input will be pushed on to pi pikachu first, followed by the second, and so on.