From eb4390340809574b84b356be83b8314842f47492 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Sat, 27 Jul 2024 14:22:41 +0200 Subject: [PATCH] Add operator sketch --- content/nativity/_index.md | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/content/nativity/_index.md b/content/nativity/_index.md index 0b9afc1..608ce95 100644 --- a/content/nativity/_index.md +++ b/content/nativity/_index.md @@ -88,3 +88,56 @@ fn [cc(.c)] main [export] () s32 { return 0; } ``` + +## Operators (from highest to lowest precedence) + +### Unary suffix operators + +- Call: `'a()'` +- Array: `a[]` +- Field/namespace: `a.b` (TODO: should we separate them?) +- Pointer dereference: `a.@` (TODO: study the available tokens) + +### Unary prefix operators + +- Negation: `-(%)a` (Optionally, the negation operator can be wrapping) +- Logical NOT: `!a` +- Bitwise NOT: `~a` +- Address of: `&a` + +### Divide/multiply operators + +- Multiply: `*` +- Divide: `/` +- Modulus: `%` + +### Add/substract operators + +- Add: `+` +- Substract `-` + +### Shift operators + +- Shift left: `<<` +- Shift right: `>>` + +### Binary bitwise operators + +- And: `&` +- Or: `|` +- Xor: `^` + +### Comparison operators + +- Equal: `==` +- Not equal: `!=` +- Less than: `<` +- Greater: `>` +- Less or equal than: `<=` +- Greater or equal than: `>=` + +### Assignment operators + +- Assignment ('=') and the rest of assignment operators + +