DOG

DOG is an esoteric programming language created by Jeremy Ruten. The commands in this program are supposed to look like commands you'd give to a dog. Numbers are represented as piles of cookies. Piles of cookies (numbers) are stored in dishes, plates, and the floor. Dishes are named dish0, dish1, ..., dish9. Plates are named plate0, plate1, ..., plate9. So you only have 10 dishes and 10 plates. The floor should hold as many numbers as you want. When you get a number from the floor, the dog (the interpreter) will choose a random number from the floor that isn't 0. Negative numbers are allowed.
Each command must be seperated by a newline. Any command can be preceded with a number or variable (dishx, platex, or floor). This number or variable tells the dog how many times to execute that command. This is where the difference between dishes and plates comes in. If a dish variable precedes a command, the command is executed however many cookies is in that dish. But if a plate variable precedes a command, the command is only executed once if the number of cookies on the plate is not 0. If the number of cookies on the plate is 0, the command isn't executed at all. This is useful for making the equivalent of a "jump if not zero" command.
Comments start with 0 (which means "execute this command 0 times") and end at the next newline. If you try to do a command a negative number of times, the command won't be executed at all.
==Command list==
Where X appears, you can replace it with dishX, plateX, floor, or a number. Where V appears, you can replace it with dishX, plateX, or floor, but NOT a number. If X or V appears in square brackets, it's optional.
* fetch X - Place X cookies into dog's mouth, adding onto whatever number is already there.
* drop V - Move cookies from dog's mouth into V, adding onto whatever number is already there.
* pickup V - Move cookies from V to dog's mouth, adding onto whatever number is already there.
* eat [X] - Subtract X amount of cookies from dog's mouth. If X isn't provided, dog eats all cookies.
* clear V - Resets V to 0. If V is floor, it resets the entire floor to 0.
* die - Ends the program. Dog dies. :(
* take - Waits for user to input a number and adds that number to the dog's mouth.
* show - Prints the number that is in the dog's mouth.
* give - Prints the number that is in the dog's mouth and resets dog's mouth to 0.
* bark "string" - Prints whatever is in the quotes to the screen. Use \n to print a newline.
* jump label_name - Jumps to the label label_name.
* label label_name - Where a jump command jumps to when jumping to the label "label_name".
==Examples==
===Adding===
 2 take
 give
===Subtracting===
 take
 drop dish1
 take
 drop dish2
 pickup dish1
 eat dish2
 give
===Multiplying===
 take
 drop dish1
 take
 drop dish2
 dish1 fetch dish2
 give
===Rolling a dice===
 fetch 1
 drop floor
 fetch 2
 drop floor
 fetch 3
 drop floor
 fetch 4
 drop floor
 fetch 5
 drop floor
 fetch 6
 drop floor
 pickup floor
 bark "You rolled a "
 give
===Adding test===
 0 Store numbers 1 to 100 on the floor
 fetch 100
 drop plate1
 label loop
 pickup plate1
 drop dish1
 fetch dish1
 drop floor
 pickup dish1
 eat 1
 drop plate1
 plate1 jump loop
 
 0 Reset dish1 and dog's mouth to 0
 pickup dish1
 eat
 
 0 Store the random numbers into dish1 and dish2
 fetch floor
 drop dish1
 fetch floor
 drop dish2
 
 0 Write the question "What is x + y?"
 bark "What is "
 fetch dish1
 give
 bark " + "
 fetch dish2
 give
 bark "? "
 
 0 Get the answer, store it in dish3
 fetch dish1
 fetch dish2
 drop dish3
 
 0 Take user's guess
 take
 
 0 Check if it's right by subtracting the real answer from their guess and checking if the result is 0
 eat dish3
 drop plate1
 plate1 bark "Wrong!"
 plate1 die
 bark "Right!"
===Hello world===
 bark "Hello world!\n"
===Fibonacci numbers===
 0 This is how many numbers will be shown (has to be at least 4, otherwise it'll be an infinite loop
 fetch 4
 
 0 Subtract 3 from the above number before storing it, because of the initial two numbers and ending number
 eat 3
 drop plate1
 
 0 Store the initial two numbers (1 and 1) into dish1 and dish2, and also display them
 fetch 1
 show
 bark ", "
 drop dish1
 fetch 1
 show
 bark ", "
 drop dish2
 label loop
 0 Show the next number
 fetch dish1
 fetch dish2
 show
 bark ", "
 
 0 Temporarily store result in dish3
 clear dish3
 drop dish3
 
 0 Store whatever's in dish2 into dish1, and store the result into dish2
 clear dish1
 pickup dish2
 drop dish1
 pickup dish3
 drop dish2
 
 0 Decrement plate1
 pickup plate1
 eat 1
 drop plate1
 plate1 jump loop
 
 0 Show the last number outside the loop (otherwise a comma would be printed after it)
 fetch dish1
 fetch dish2
 show
===99 bottles of beer===
 fetch 99
 drop plate1
 label loop
 pickup plate1
 show
 bark " bottles of beer on the wall, "
 show
 bark " bottles of beer.\n"
 bark "Take one down and pass it around, "
 eat 1
 show
 bark " bottles of beer on the wall.\n\n"
 drop plate1
 plate1 jump loop
 bark "No more bottles of beer on the wall, no more bottles of beer.\n"
 bark "Go to the store and buy some more, 99 bottles of beer on the wall."
==External resources==
* DOG interpreter written in perl
* DOG sample programs and specification
Category: 2007
Category: Implemented
Category: Languages
Category: Thematic
Category: Pseudonatural