a-gram
- This is still a work in progress. It may be changed in the future.
a-gram is an esoteric programming language that only accepts Unicode characters with "gram" in their name as valid characters.
Syntax
Basic commands
Command | Description |
---|---|
⚍ (LESSER YIN)
|
Grabs a single character from console and pushes its ASCII value onto the stack |
⚌ (GREATER YANG)
|
Outputs the value on the top of the stack as an ASCII character |
⚎ (LESSER YANG)
|
Outputs the value on the top of the stack as a number |
䷨ (DECREASE)
|
Decrements the value on the top of the stack |
䷩ (INCREASE)
|
Increments the value on the top of the stack |
☰ (HEAVEN)
|
Pushes 1 onto the stack |
䷀ (THE CREATIVE HEAVEN)
|
Pushes 127 onto the stack |
䷯ (THE WELL)
|
Pushes a random number between 0 and 127 onto the stack |
䷏ (ENTHUSIASM)
|
Squares the value on the top of the stack |
䷶ (ABUNDANCE)
|
Duplicates the value on the top of the stack |
䷠ (RETREAT)
|
Takes the value from the bottom to the top of the stack |
Note that if nothing is on the stack, using INCREASE and DECREASE will return with an error message.
Any other unrecognised character will be ignored by the compiler.
Flow control
a-gram allows you to loop based on certain conditions.
You may start a loop by using the DURATION hexagram, ䷟
. There are multiple conditions on which to loop based on. These are placed directly after the DURATION hexagram.
Condition | Description |
---|---|
䷼ (INNER TRUTH)
|
Loops while the current value on the stack is truthy (greater than 0) |
䷺ (DISPERSION)
|
Loops while the stack has values in it |
䷫ (COMING TO MEET)
|
Pops a value off the stack and then loops until the value currently on the stack is equal to the popped value |
䷽ (SMALL PREPONDERANCE)
|
Pops a value off the stack and then loops until the value currently on the stack is less than the popped value |
䷛ (GREAT PREPONDERANCE)
|
Pops a value off the stack and then loops until the value currently on the stack is greater than the popped value |
䷄ (WAITING)
|
Loops infinitely |
The loop then must have a hexagram for BEFORE COMPLETION (䷿
) to start the loop block, as well as a hexagram for AFTER COMPLETION (䷾
) to end it.
For example, here is a simple yes-like program, along with an explanation of how it works.
⚍䷟䷄䷿䷶⚌䷾
⚍ Grab single character from STDIN ䷟ ䷄ Loop forever ䷿ { ䷶ Duplicate value on stack ⚌ Pop value off stack and print it ䷾ }
As well, there is one additional flow-control related command: RETURN (䷗
). This command jumps to the start of any loop it is in. If it is not in a loop, it will instead jump to the start of the file, making infinite loops that surround the entire program easier.
Example programs
Hello, world!
☰䷩䷩䷩䷩䷩䷩䷩䷏䷩䷩䷩䷩䷩䷩䷩䷩⚌ ䷀䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌ ䷩䷩䷩䷩䷩䷩䷩䷶⚌ ䷶⚌ ䷩䷩䷩⚌ ☰䷩䷩䷩䷩䷩䷩䷏䷨䷨䷨䷨䷨⚌ ☰䷩䷩䷩䷩䷩䷏䷨䷨䷨䷨⚌ ䷀䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌ ䷨䷨䷨䷨䷨䷨䷨䷨䷶⚌ ䷩䷩䷩䷶⚌ ䷨䷨䷨䷨䷨䷨䷶⚌ ䷨䷨䷨䷨䷨䷨䷨䷨⚌ ☰䷩䷩䷩䷩䷩䷏䷨䷨䷨⚌ ☰䷩䷩䷩䷩䷩䷩䷩䷩䷩⚌
This outputs "Hello, world!" with a trailing newline.
Echo program
䷟䷄䷿⚏䷟䷺䷿䷠⚌䷾䷾
This fairly short program loops infinitely, echoing anything it receives from STDIN to STDOUT.