Skip to content

Commit 52ff12d

Browse files
committed
Expanded README.md
Added more syntax specifications to the readme
1 parent ac725fc commit 52ff12d

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,66 @@ type MY_STRUCT: struct {
1717
};
1818
1919
func main: (vessel: Vessel /* Vessel holds vessel data */) -> () {
20-
let mut hi_text: str = "hi world?";
21-
hi_text = "Hello World!";
20+
let mut hi_text: str = "hi kerbin?";
21+
hi_text = "Hello kOS!";
2222
if ?hi_text { // Not worth printing if its empty
2323
print(hi_text);
2424
}
2525
}
2626
```
27+
28+
### Keywords
29+
- `func`: specifies a function or function signature
30+
- `let`: specifies an immutable variable
31+
- `const`: specifies a compile time constant, only allowed in global scope
32+
- `macro`: specifies a compile time macro (code replacement), only allowed in global scope
33+
- `mut`: marks a variable or refrence as mutable
34+
- `return`: returns from a function
35+
- `if`: if-statement
36+
- `else`: else-statement
37+
- `switch`: switch-statement
38+
39+
#### Type Keywords
40+
- `i16`
41+
- `i32`
42+
- `f32`
43+
- `f64`
44+
- `bool`
45+
- `byte`
46+
- `str`
47+
- `struct`
48+
- `enum`
49+
50+
#### Reserved Keywords
51+
These are reserved, there is currently no plan to implement them
52+
53+
- `async`
54+
- `import`
55+
56+
### Unary Prefix Operators
57+
- `?`: Logical Operator, Evaluates "truthness" of another type (uses kOS's `OpcodeLogicToBool` in `src/kOS.Safe/Compilation/Opcode.cs`)
58+
- `&`: Refrence
59+
- `*`: Derefrence
60+
- `!`: Logical Not
61+
- `-`: Arithmetic Negation
62+
63+
### Binary Infix Operators
64+
- `+`: Addition
65+
- `-`: Subtraction
66+
- `*`: Multiplication
67+
- `\`: Division
68+
69+
### Number Literals
70+
Integer and byte literals may begin with `0x` to indicate hexadecimal parsing
71+
72+
### String Literals
73+
String literals must be surrounded with `"` characters
74+
75+
#### String Escape Sequences
76+
- `\n`: Newline
77+
- `\t`: Tab
78+
- `\r`: Carriage Return
79+
- `\0`: Nullbyte
80+
- `\3`: Hex `0x03`, to print ksm argument headers
81+
- `\\`: `\` character
82+
- `\"`: `"` character

0 commit comments

Comments
 (0)