Basic syntax
MPL Easy language uses postfix notation. It means that we can put elements on top of stack and call operations without specifying arguments directly in the call syntax. Each operation works with stack contents. For example, in classic notation, we write
2+3*4
and it means that first, we calculate 3*4 because * has higher priority than + , and then we calculate 2+12. In postfix notation, this expression can be written as
2 3 4 * +
Try it!
This snippet puts 2, 3, 4 to stack. Then * gets top two numbers from stack (these are 3 and 4), multiplies them, and pushes the result (12) back to stack. Stack now contains 2 and 12. Then + gets two numbers from stack and pushes the result of their addition (14) back to stack.
String literals are written in double quotes, e.g. "some text" .
Variables
Each word that ends with : is a new variable. When we write name: , we make a new variable ‘name’ and push it to a special ‘label stack’ (it is a different stack from the one mentioned above). This variable cannot be used yet and doesn't have any value. When we write ; , the top value from stack is assigned to the top label from label stack.
For example:
a: 1;Try it!