From 53c66a3d03333eeae3d5b4aae352d8d36d37e4a9 Mon Sep 17 00:00:00 2001 From: Jooris Hadeler Date: Wed, 11 Mar 2026 10:11:01 +0100 Subject: [PATCH] Feat: update VSCode extension with compound assignment and shift operators Add compound assignment operators (+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=) and shift operators (<<, >>) to the tmLanguage syntax highlighting grammar. Patterns are ordered longest-first to prevent shorter tokens from shadowing multi-character operators. Also update fibonacci example to use += compound assignment. --- examples/fibonacci.flx | 2 +- vscode-flux/syntaxes/flux.tmLanguage.json | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/fibonacci.flx b/examples/fibonacci.flx index 4e7aa31..f6634cd 100644 --- a/examples/fibonacci.flx +++ b/examples/fibonacci.flx @@ -16,7 +16,7 @@ fn fibonacci_iter(n: u8) -> u64 { a = b; b = temp; - counter = counter + 1; + counter += 1; } return a; diff --git a/vscode-flux/syntaxes/flux.tmLanguage.json b/vscode-flux/syntaxes/flux.tmLanguage.json index ebadedd..14191ea 100644 --- a/vscode-flux/syntaxes/flux.tmLanguage.json +++ b/vscode-flux/syntaxes/flux.tmLanguage.json @@ -156,19 +156,29 @@ "operators": { "patterns": [ { - "comment": "Arrow (return type separator)", + "comment": "Arrow (return type separator) — must precede - and -=", "name": "keyword.operator.arrow.flux", "match": "->" }, + { + "comment": "Compound assignment operators — must precede shift, comparison, and arithmetic", + "name": "keyword.operator.assignment.compound.flux", + "match": "<<=|>>=|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=" + }, + { + "comment": "Shift operators — must precede < and >", + "name": "keyword.operator.bitwise.shift.flux", + "match": "<<|>>" + }, { "comment": "Comparison operators", "name": "keyword.operator.comparison.flux", "match": "==|!=|<=|>=|<|>" }, { - "comment": "Assignment", + "comment": "Assignment — negative lookbehind excludes all compound-assign prefixes", "name": "keyword.operator.assignment.flux", - "match": "(?])=(?!=)" + "match": "(?+\\-*/%&|^])=(?!=)" }, { "comment": "Arithmetic: + - * / %", @@ -176,7 +186,7 @@ "match": "[+\\-*/%]" }, { - "comment": "Bitwise: & | ^ ~ and unary ! ~", + "comment": "Bitwise and unary: & | ^ ~ !", "name": "keyword.operator.bitwise.flux", "match": "[&|^~!]" }