Enumerate operator type support

This commit is contained in:
Alex Hirsch 2021-04-13 15:24:42 +02:00
parent 054e7fe844
commit f2e9c9afe1

View File

@ -149,13 +149,23 @@ String literals are at most 1000 characters long.
Arrays are at most `LONG_MAX` elements long.
### Operators
The following table enumerates which types an operator supports.
In the case of a binary operator, both sides must be of the same type.
| Operator | Supported Types |
| ----------------- | ---------------------- |
| `-` `+` `*` `/` | `int`, `float` |
| `<` `<=` `>` `>=` | `int`, `float` |
| `==` `!=` | `bool`, `int`, `float` |
| `!` `&&` `||` | `bool` |
### Special Semantics
#### Boolean
`bool` is considered a first-class citizen, distinct from `int`.
The operators `!`, `&&`, and `||` can only be used with Booleans.
Short-circuit evaluation is *not* supported.
An expression used as a condition (for `if` or `while`) is expected to be of type `bool`.