Files
BrainAssembly/docs/syntax.md

55 lines
1.1 KiB
Markdown
Raw Normal View History

To create a comment, begin a line with a hash (#) symbol, like python.
2025-10-06 12:52:38 +11:00
## create var *bytes = Value
2025-10-06 10:50:14 +11:00
2025-10-06 12:52:38 +11:00
Creates the variable "var" with a set number of bytes allocated to it, and initialises its value.
**IMPORTANT:** The number of bytes cannot be modified later.
2025-10-06 12:52:38 +11:00
Example: `create var *5 = "Hello"`
## print var
Prints the value of `var` to the console, where `var` is a variable.
Example: `print var`
## set var = Value
Changes the value of an already created value.
2025-10-10 08:30:37 +11:00
Example: `set var = "World"`
2025-10-11 11:11:14 +11:00
## input var *bytes = type *ibytes
Creates a new variable that is `bytes` long, that reads the first `ibytes` of input.
Example: `input str *5 = string *3` (3 bytes of input, remaining 2 bytes are left blank)
2025-10-10 08:30:37 +11:00
## if bool
Runs code if a boolean is true.
Example:
```
2025-10-11 11:11:14 +11:00
# If a boolean is true
2025-10-10 08:30:37 +11:00
if bool {
2025-10-11 11:11:14 +11:00
set str = "Hello"
}
# If second byte of var and third byte of var are equal
if var[1] == var[2] {
set bool = true
2025-10-10 08:30:37 +11:00
}
2025-10-10 14:19:07 +11:00
```
## while bool
Runs code until a boolean is false
Example:
```
create bool *1 = true
while bool {
# Loops forever because bool is never false
}
2025-10-10 08:30:37 +11:00
```