compound assignment

This commit is contained in:
2026-06-22 21:20:15 +02:00
parent 663f4dc658
commit 6512ccd543
14 changed files with 995 additions and 99 deletions
+15
View File
@@ -84,6 +84,9 @@ Expr_Kind :: enum u8 {
Negate,
Not,
Add,
Sub,
Mul,
Div,
Eq,
Ne,
Lt,
@@ -126,6 +129,14 @@ Stmt_Kind :: enum u8 {
For,
}
Assignment_Op :: enum u8 {
Set,
Add,
Sub,
Mul,
Div,
}
Stmt :: struct {
kind: Stmt_Kind,
span: source.Span,
@@ -134,6 +145,10 @@ Stmt :: struct {
type: Type_Syntax,
immutable: bool,
pointer_capture: bool,
// Assignments store the lvalue in `target`, the right-hand side in `expr`,
// and the source operator in `assignment_op`. `Set` is ordinary `=`;
// the arithmetic variants are `+=`, `-=`, `*=`, and `/=`.
assignment_op: Assignment_Op,
target: Expr_Id,
expr: Expr_Id,
// `If` statements use `expr` as the condition, `captures` as optional