CSL
Jump to navigation
Jump to search
Command Stack Language (CSL for short, CSLAAI2D* for long) is a 2D, stack-based programming language by User:Actuallyallama.
The language features two stacks - one for actual memory, one for instructions.
The instruction pointer works as it does in many languages. It is manipulated by directional commands, and will wrap around.
The difference in this language, is rather than immediately executing instructions, it instead adds the instruction to the top of the instruction stack and executes it when at a special execution instruction. Since it's a stack, all of the instructions will execute in reverse order to the order they are added.
Commands
Command | Name | Description |
---|---|---|
! | EOF | Terminate program. |
e | EXC | Execute the command on top of the stack. |
E | EX2 | Execute all commands on the stack. |
v | MDN | Switches instruction direction |
< | MLT | Switches instruction direction |
> | MRT | Switches instruction direction |
^ | MUP | Switches instruction direction |
{ | CLF | If pop == 0, move left. Else, keep direction. |
} | CRF | If pop != 0, move right. Else, keep direction. |
1 | ONE | Push a 1 onto the stack. |
D | DUP | Duplicate the top of the stack. |
P | PRT | Pop the top of the stack and print it. |
p | PRA | Pop the top of the stack and print it as ASCII character. |
N | PRN | Print a line terminator. |
+ | INC | Pop the top, increment it by 1, push it. |
- | DEC | Pop the top, decrement it by 1, push it. |
& | ADD | Pop the top two items, add them. Push result. |
* | MUL | Pop the top two items, multiply them. Push result. |
_ | SUB | Pop the top two items, subtract them. Push result. |
~ | SWT | Switch the top two items. |
| | NUL | Pop the top item, and discard it. |
$ | BRK | Break out of mass execution (E). |
? | CEX | If pop == 0, pop the top command and invoke. Else pop top command and discard. |
Examples
Hello World:
p&1*+1*+++1+++1p_~+++++++1pD_~+++++1pD&++1pD&*+++1+++++1pD&*++1++++1pp&&D+++++1D*+1*D+++1|p&++1pDpD&++++++1pD&+++1&*++++1++++1DDpD*+1*D+++++1E!
provides the following output:
Hello, World!
Implementations
The file extension for code it runs is ".csl"
Footnotes
- Stands for "Command Stack Language (And Also In 2 Dimensions)"