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.
This commit is contained in:
@@ -16,7 +16,7 @@ fn fibonacci_iter(n: u8) -> u64 {
|
|||||||
a = b;
|
a = b;
|
||||||
b = temp;
|
b = temp;
|
||||||
|
|
||||||
counter = counter + 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
@@ -156,19 +156,29 @@
|
|||||||
"operators": {
|
"operators": {
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"comment": "Arrow (return type separator)",
|
"comment": "Arrow (return type separator) — must precede - and -=",
|
||||||
"name": "keyword.operator.arrow.flux",
|
"name": "keyword.operator.arrow.flux",
|
||||||
"match": "->"
|
"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",
|
"comment": "Comparison operators",
|
||||||
"name": "keyword.operator.comparison.flux",
|
"name": "keyword.operator.comparison.flux",
|
||||||
"match": "==|!=|<=|>=|<|>"
|
"match": "==|!=|<=|>=|<|>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"comment": "Assignment",
|
"comment": "Assignment — negative lookbehind excludes all compound-assign prefixes",
|
||||||
"name": "keyword.operator.assignment.flux",
|
"name": "keyword.operator.assignment.flux",
|
||||||
"match": "(?<![=!<>])=(?!=)"
|
"match": "(?<![=!<>+\\-*/%&|^])=(?!=)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"comment": "Arithmetic: + - * / %",
|
"comment": "Arithmetic: + - * / %",
|
||||||
@@ -176,7 +186,7 @@
|
|||||||
"match": "[+\\-*/%]"
|
"match": "[+\\-*/%]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"comment": "Bitwise: & | ^ ~ and unary ! ~",
|
"comment": "Bitwise and unary: & | ^ ~ !",
|
||||||
"name": "keyword.operator.bitwise.flux",
|
"name": "keyword.operator.bitwise.flux",
|
||||||
"match": "[&|^~!]"
|
"match": "[&|^~!]"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user