This repository contains the JS implementation of the Aglang interpreter, hosted at https://aglang.0xf1.dev
If you're looking for the main repository, you can find it here.
The following table contains all the valid tokens and their use.
| Token | Description | Note |
|---|---|---|
; |
Statement delimiter | The semicolon is placed at the end of a statement to declare its end. |
0 and 1 |
Binary literals | 8-bit binary numbers can be used as number literals. |
' |
Register 1 | The Register 1 is an 8-bit register used to store a value. |
'' |
Register 2 | The Register 2 is an 8-bit register used to store a value. |
: |
Stack | The Stack is a LIFO array of 8-bit values; only the top value in it can be read. While it can be directly read via the copy operator, the top value cannot be directly written, it can only be pushed and popped. |
> |
Copy | The Copy operator is used to copy or insert values from a source to a destination |
! |
Remove | The Remove operator is used to pop (in the case of the stack) or clear (in the case of a register) a value. |
| |
Input | The Input operator is used to wait a value from the StdIn and insert it in the stack in reverse order and delimited at the bottom by a 0. |
+ |
Sum | The Sum operator is used to sum 2 values. The result gets stored in the first argument. In the case of an overflow, the result wraps around to 0. |
- |
Subtraction | The Subtraction operator is used to subtract 2 values. The result gets stored in the first argument. In the case of an underflow, the result wraps around to 0. |
* |
Multiplication | The Multiplication operator is used to multiply 2 values. The result gets stored in the first argument. In the case of an overflow, the result wraps around to 0. |
/ |
Division | The Division operator is used to divide 2 values and get the quotient. The result gets stored in the first argument. |
% |
Remainder | The Remainder operator is used to get the remainder of the division of the 2 arguments. The result gets stored in the first argument. |
\ |
StdOut | The StdOut can be used as the destination of a copy operation to print the ASCII character of the source to the terminal. When a # character is appended to it (\#), the value gets printed as its decimal value instead of the ASCII character. |
[ and ] |
Loop | A Loop runs until, at the end of it, the top value in the stack is 0. |
~ |
Label | Used to declare a label. A label can only be named using dots (e.g. ".", "..") |
? |
Compare | Compares [src] to [dest]. Can either result in Greater, Less or Equal |
^ |
Greater | Needs to be preceded by a Compare statement. If the result of the comparison is Greater, the program will jump to [label]. |
< |
Less | Needs to be preceded by a Compare statement. If the result of the comparison is Less, the program will jump to [label]. |
= |
Equal | Needs to be preceded by a Compare statement. If the result of the comparison is Equal, the program will jump to [label]. |