ASCIIORb
Jump to navigation
Jump to search
ASCIIORb is a stack-based language that follows the "syntax" of the @ORb language created by Threesodas.
Stack-based
In ASCIIORb, there are three stacks: the Action stack (STAQ
), the Numerical stack (STAK
) and the Queue stack (STAC
). Each stack has its own purpose:
Stack | Identification | Purpose |
---|---|---|
Action | STAQ
|
This stack is an immutable stack in the sense that no values can be popped or dropped; values can only be pushed. Its purpose is to represent actions such as pushes to other stacks. Actions that have already been taken can be repeated. See the code below this table for an example. |
Numerical | STAK
|
This stack is a mutable stack. In order to print a character, you must first push a numerical value to this stack. Then, you can pop one or all numerical values and push them to the Queue stack. |
Queue | STAC
|
This stack is a mutable stack. However it doesn't have much of a purpose considering all it is used for is execution. When the final keyword FIN is used, the program will end and it will begin to print characters based off of ASCII values from the top down. *CLARIFICATION: When ALL values of the Numerical stack are pushed to the Queue stack, they are all added into ONE value. For instance, if you were to push 10,10,10,10,10,10,1,1,1,1,1 to the Queue stack, it would add up to 65.
|
Action Stack Visualization
INQ STAK 9 REP 0 STAK PUSHAL STAC FIN STAC
Here is the visualization of the stack for this code:
Print all values from the Queue stack. Push all values from the Numerical stack to the Queue stack. Repeat the first action nine times. Increase the Numerical stack by 10.
Numerical Stack Visualization
INQ STAK 9 REP 0 STAK PUSHAL STAC FIN STAC
Here is the visualization of the stack for this code:
10 10 10 10 10 10 10 10 10 10
Queue Stack Visualization
INQ STAK 9 REP 0 STAK PUSHAL STAC FIN STAC
Here is the visualization of the stack for this code:
100
Commands and their functions
The following is a table including all commands in ASCIIORb:
Command | Function | Example |
---|---|---|
INC
|
Add a value of 1 to the specified stack. | INC STAK
|
INQ
|
Add a value of 10 to the specified stack. | INQ STAK
|
PUSH
|
Push the top value of the specified stack to another. | STAK PUSH STAC
|
PUSHAL
|
Push all values of a stack to another. | STAC PUSHAL STAK
|
PEK
|
Peek; push the top value of a stack to another without removing it. | STAK PEK STAC
|
PEKAL
|
Push all values from one stack to another without removing them. | STAK PEKAL STAK
|
DROP
|
Drop the top value from a stack. | DROP STAK
|
DROPAL
|
Drop all values from a specified stack. | DROPAL STAK
|
REP
|
Repeat an action from the Action stack. | 9 REP 0
|
FIN
|
Print all values from the specified stack. This ends the program. | FIN STAC
|
Complete Descriptions
<> : Required argument [] : Optional argument INC, INQ: Add a value of 1 or 10 to the Numerical stack depending on the command. Usage: INC <Stack> Example: INC STAK PUSH, PUSHAL: Push the top or all values to another stack. This removes one or all values from the stack. Usage: <FromStack> PUSH <ToStack> Example: STAK PUSH STAC PEK, PEKAL: This command is the same as PUSH/PUSHAL except the value is not removed. Usage: <FromStack> PEK <ToStack> Example: STAK PEK STAC DROP, DROPAL: Removes one or all values from a stack. Usage: DROP <Stack> Example: DROP STAQ REP: Repeat an action from the Action stack. Usage: <RepeatAmount> REP <IndexOfAction> Example: 5 REP 4 FIN: Print all values from a stack from the top down. Usage: FIN <Stack> Example: FIN STAC
Thinking Backwards
Since a stack is executed from the top to the bottom, you must have your string reversed! If your stack represented "H,E,L,L,O", it would be executed as "O,L,L,E,H".
Examples
Peeking and Dropping
The following program generates the output text “ABA” by peeking items and employing the DROP
command:
INQ STAK INQ STAK INQ STAK INQ STAK INQ STAK INQ STAK INC STAK INC STAK INC STAK INC STAK INC STAK STAK PEKAL STAC INC STAK STAK PEKAL STAC DROP STAK STAK PEKAL STAC FIN STAC
Interpreter
- Common Lisp implementation of the ASCIIORb programming language.