Moed
Moed (pronounced /mid/) is an esoteric programming language by User:Dhzb.
Whitespace
Whitespace is sometimes significant.
Newlines
Newlines can be scoped inside of {...}
groups which can be targeted by newline-imperae.
Execution
Moed executes in a given direction which is initialized to 1 (right), the direction can be changed to other values by using one of three dexterimperae.
Data storage
Moed primarily uses the stack to store short-term data but also provides a secondary medium which is the matrix.
When an empty stack is popped, it returns 0.
The memory matrix is infinite in all directions.
Imperae
Currently, Moed has 2 types of imperae: Dexterimperae and Sinisterimperae. Each imperae has an associated symbol to represent it.
Dexterimperae
Symbol | Version | Name | Description |
---|---|---|---|
0-9 | A1 | Digit | Pushes the corresponding digit onto the stack |
> | A1 | Right | Sets the direction of execution to 1 |
< | A1 | Left | Sets the direction of execution to -1 |
| | A1 | Mirror | Mirrors (by negating) the execution direction |
_ | A1 | Newline | Jumps to the next character of the next newline in the current scope |
" | A1 | Subnewline | Pops n and jumps to the next character of the next newline in the scope n levels up |
= | A1 | Skip | Skips over one execution step (including groups as one execution step) |
+ | A1 | Addition | Pops x and y and pushes x+y onto the stack |
- | A1 | Subtraction | Pops x and y and pushes x-y onto the stack |
* | A1 | Multiplication | Pops x and y and pushes x×y onto the stack |
/ | A1 | Division | Pops x and y and pushes x÷y onto the stack (0 divisor returns 0) |
% | A1 | Modulo | Pops x and y and pushes x mod y onto the stack (negative wraps around, 0 divisor returns 0) |
^ | A1 | Exponentiation | Pops x and y and pushes xy onto the stack |
\ | A1 | Swap | Swaps the top 2 values on the stack |
$ | A1 | Discard | Pops a value and discards it |
' | A1 | Character | Skips one execution step and pushes the character at the execution pointer onto the stack |
: | A1 | Duplicate | Duplicates the top value on the stack |
; | A1 | N-duplicate | Pops n and duplicates the nth value from the top of the stack (starting at 0) to the top of the stack |
& | A1 | Incharacter | Gets a character from input |
? | A1 | Auxiliary incharacter | Gets a character from auxiliary input |
# | A1 | Innumber | Gets a number literal from input |
, | A1 | Outcharacter | Outputs a character from the stack (pop) |
. | A1 | Outnumber | Outputs a number literal from the stack (pop) |
` | A1 | Unvalencitudinity | If top of stack (don't pop) is nonzero, continue forwards, otherwise mirror+skip |
~ | A1 | Sinisterimpera toggle | Interpret the characters as sinisterimperae from now on |
@ | A1 | Stop | Halts the program execution |
(...) | A1 | Special | Does a special operation based on the first character in it and the rest of the string |
J | B1 | Jump | Pops n and jumps to the nth j relative to the current character |
I | B1 | Pause | Pauses execution |
R | B1 | Return | Returns to the previous location before a custom impera call |
Any other character | B1 | Call | Goes to the location associated with the character |
Sinisterimperae
Symbol | Version | Name | Description |
---|---|---|---|
| | A1 | Set | Pops y, x, and v and sets the value at the corresponding position x,y in the matrix to v |
^ | A1 | Get | Pops y and x and pushes the value at the corresponding position x,y in the matrix onto the stack |
= | A1 | Skip | Does the same as it is as a dexterimpera except that it doesn't skip groups |
? | B1 | Random | Pushes a random number in the range [0,1) |
. | B1 | Floor | Applies a floor function on the top value on the stack |
: | B1 | Ceiling | Applies a ceiling function on the top value on the stack |
; | B1 | Round | Applies a round function on the top value on the stack |
~ | A1 | Dexterimpera toggle | Interpret the characters as dexterimperae from now on |
Any other character | A1 | Does nothing |
Special operations
First character | Version | Description |
---|---|---|
" | A1 | Pushes the rest of the string onto the stack starting from the end of the string |
& | A1 | Prints the rest of the string |
= | B1 | Associates a location (after the '=') with the popped character on the stack |
Any other character | A1 | Does nothing |
Examples
Computational class
User:Dhzb has created a brainfuck interpreter with infinite cells in Moed, therefore, Moed is turing-complete
Implementation
Future additions
Moed-B1
- [✓] Custom operations (e.g.
'√(=21/\^)
) -- now'√(=21/\^R)
- [✓] Pause execution
Moed-A2
- [__] Additional memory slots in every other dimension
- [__] Internet connection