A golfing language with typable commands based on 05ab1e.
XP is a stack based language. Values get pushed onto the global stack. Most operations are performed on the stack.
Literal values like numbers will get pushed onto the stack one after the other. Thus, this code
40 60will push 40 and then 60 onto the stack.
Stack:
+----+
| 60 | <- top
+----+
| 40 |
+----+An operation like + pops the top two elements and pushes the result back onto the stack.
40 60+This will cause 100 to be on the top of the stack.
Stack:
+-----+
| 100 | <- top
+-----+String literals are enclosed in double quotes.
"Hello""World"This pushes the string "Hello", and the "World" onto the stack.
Stack:
+---------+
| "World" | <- top
+---------+
| "Hello" |
+---------+Performing + now will concatenate them. It's a golfing language, so a lot of things are implied.
"Hello""World"+Stack:
+--------------+
| "HelloWorld" | <- top
+--------------+Some clever features of 05ab1e have made their way into XP.
- Looping constructs automatically begin a code block.
F <code> }is the syntax for aforloop. - The top of the stack gets implicitly printed if nothing else was printed at the execution.
"Hello, World!"is a hello-world program. - Ending a block / string is implied by eof.
"Hello, World!is also a hello-world program. - Input is also taken implicitly if the stack is empty and an operation requires arguments.
+is a program that prints the sum of two numbers taken from the user.