- Grammar: update pointer_type to support optional mut keyword; LL(1) verified (56 named rules, no conflicts) - AST: update Type enum with mutable: bool field for Pointer and OpaquePointer variants - Parser: consume optional mut token in parse_type; update all existing pointer tests; add 4 new mut pointer tests (85 pass) - VSCode extension: add *mut capture-group pattern for syntax highlighting; update SYNTAX.md with pointer mutability table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
218 lines
6.7 KiB
JSON
218 lines
6.7 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "Flux",
|
|
"scopeName": "source.flux",
|
|
"fileTypes": ["flux"],
|
|
"patterns": [
|
|
{ "include": "#line-comment" },
|
|
{ "include": "#block-comment" },
|
|
{ "include": "#string" },
|
|
{ "include": "#char" },
|
|
{ "include": "#number" },
|
|
{ "include": "#fn-def" },
|
|
{ "include": "#struct-def" },
|
|
{ "include": "#control-keywords" },
|
|
{ "include": "#decl-keywords" },
|
|
{ "include": "#type-keywords" },
|
|
{ "include": "#boolean-literals" },
|
|
{ "include": "#operator-keywords" },
|
|
{ "include": "#operators" },
|
|
{ "include": "#punctuation" }
|
|
],
|
|
"repository": {
|
|
|
|
"line-comment": {
|
|
"name": "comment.line.double-slash.flux",
|
|
"match": "//.*$"
|
|
},
|
|
|
|
"block-comment": {
|
|
"name": "comment.block.flux",
|
|
"begin": "/\\*",
|
|
"end": "\\*/",
|
|
"beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.flux" } },
|
|
"endCaptures": { "0": { "name": "punctuation.definition.comment.end.flux" } }
|
|
},
|
|
|
|
"string": {
|
|
"name": "string.quoted.double.flux",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"beginCaptures": { "0": { "name": "punctuation.definition.string.begin.flux" } },
|
|
"endCaptures": { "0": { "name": "punctuation.definition.string.end.flux" } },
|
|
"patterns": [ { "include": "#escape-sequence" } ]
|
|
},
|
|
|
|
"char": {
|
|
"name": "string.quoted.single.flux",
|
|
"begin": "'",
|
|
"end": "'",
|
|
"beginCaptures": { "0": { "name": "punctuation.definition.string.begin.flux" } },
|
|
"endCaptures": { "0": { "name": "punctuation.definition.string.end.flux" } },
|
|
"patterns": [ { "include": "#escape-sequence" } ]
|
|
},
|
|
|
|
"escape-sequence": {
|
|
"name": "constant.character.escape.flux",
|
|
"match": "\\\\([nrt\\\\\"'0]|u\\{[0-9a-fA-F]{1,6}\\})"
|
|
},
|
|
|
|
"number": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Floating-point: 3.14, 1.0e-9, 2e4",
|
|
"name": "constant.numeric.float.flux",
|
|
"match": "\\b\\d[\\d_]*\\.\\d[\\d_]*(?:[eE][+-]?\\d[\\d_]*)?\\b|\\b\\d[\\d_]*[eE][+-]?\\d[\\d_]*\\b"
|
|
},
|
|
{
|
|
"comment": "Hexadecimal integer: 0xFF, 0xDEAD_BEEF",
|
|
"name": "constant.numeric.integer.hex.flux",
|
|
"match": "\\b0x[0-9a-fA-F][0-9a-fA-F_]*\\b"
|
|
},
|
|
{
|
|
"comment": "Octal integer: 0o77",
|
|
"name": "constant.numeric.integer.octal.flux",
|
|
"match": "\\b0o[0-7][0-7_]*\\b"
|
|
},
|
|
{
|
|
"comment": "Binary integer: 0b1010",
|
|
"name": "constant.numeric.integer.binary.flux",
|
|
"match": "\\b0b[01][01_]*\\b"
|
|
},
|
|
{
|
|
"comment": "Decimal integer: 42, 1_000_000",
|
|
"name": "constant.numeric.integer.decimal.flux",
|
|
"match": "\\b\\d[\\d_]*\\b"
|
|
}
|
|
]
|
|
},
|
|
|
|
"fn-def": {
|
|
"comment": "Highlight function name after `fn`",
|
|
"match": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.declaration.function.flux" },
|
|
"2": { "name": "entity.name.function.flux" }
|
|
}
|
|
},
|
|
|
|
"struct-def": {
|
|
"comment": "Highlight struct name after `struct`",
|
|
"match": "\\b(struct)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.declaration.type.flux" },
|
|
"2": { "name": "entity.name.type.struct.flux" }
|
|
}
|
|
},
|
|
|
|
"control-keywords": {
|
|
"name": "keyword.control.flux",
|
|
"match": "\\b(if|else|while|loop|break|continue|return)\\b"
|
|
},
|
|
|
|
"decl-keywords": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.other.let.flux",
|
|
"match": "\\blet\\b"
|
|
},
|
|
{
|
|
"name": "storage.modifier.mut.flux",
|
|
"match": "\\bmut\\b"
|
|
}
|
|
]
|
|
},
|
|
|
|
"type-keywords": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Primitive numeric types",
|
|
"name": "support.type.primitive.flux",
|
|
"match": "\\b(u8|u16|u32|u64|i8|i16|i32|i64|f32|f64)\\b"
|
|
},
|
|
{
|
|
"comment": "Other primitive types",
|
|
"name": "support.type.primitive.flux",
|
|
"match": "\\b(bool|char)\\b"
|
|
},
|
|
{
|
|
"comment": "Opaque pointer keyword",
|
|
"name": "support.type.opaque.flux",
|
|
"match": "\\bopaque\\b"
|
|
}
|
|
]
|
|
},
|
|
|
|
"boolean-literals": {
|
|
"name": "constant.language.boolean.flux",
|
|
"match": "\\b(true|false)\\b"
|
|
},
|
|
|
|
"operator-keywords": {
|
|
"name": "keyword.operator.logical.flux",
|
|
"match": "\\b(and|or)\\b"
|
|
},
|
|
|
|
"operators": {
|
|
"patterns": [
|
|
{
|
|
"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 — negative lookbehind excludes all compound-assign prefixes",
|
|
"name": "keyword.operator.assignment.flux",
|
|
"match": "(?<![=!<>+\\-*/%&|^])=(?!=)"
|
|
},
|
|
{
|
|
"comment": "Mutable pointer type prefix *mut — must precede arithmetic *",
|
|
"match": "(\\*)(mut)\\b",
|
|
"captures": {
|
|
"1": { "name": "keyword.operator.type.pointer.flux" },
|
|
"2": { "name": "storage.modifier.mut.flux" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "Arithmetic: + - * / %",
|
|
"name": "keyword.operator.arithmetic.flux",
|
|
"match": "[+\\-*/%]"
|
|
},
|
|
{
|
|
"comment": "Bitwise and unary: & | ^ ~ !",
|
|
"name": "keyword.operator.bitwise.flux",
|
|
"match": "[&|^~!]"
|
|
}
|
|
]
|
|
},
|
|
|
|
"punctuation": {
|
|
"patterns": [
|
|
{ "name": "punctuation.terminator.statement.flux", "match": ";" },
|
|
{ "name": "punctuation.separator.comma.flux", "match": "," },
|
|
{ "name": "punctuation.accessor.dot.flux", "match": "\\." },
|
|
{ "name": "punctuation.separator.colon.flux", "match": ":" },
|
|
{ "name": "punctuation.brackets.round.flux", "match": "[()]" },
|
|
{ "name": "punctuation.brackets.square.flux", "match": "[\\[\\]]" },
|
|
{ "name": "punctuation.brackets.curly.flux", "match": "[{}]" }
|
|
]
|
|
}
|
|
|
|
}
|
|
}
|