@felixtensor/tree-sitter-mlir 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felixtensor/tree-sitter-mlir",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "MLIR grammar for tree-sitter",
5
5
  "type": "module",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "node-gyp-build": "^4.8.4"
37
37
  },
38
38
  "devDependencies": {
39
+ "node-gyp": "^12.4.0",
39
40
  "prebuildify": "^6.0.1",
40
- "tree-sitter": "^0.25.0",
41
41
  "tree-sitter-cli": "^0.26.9"
42
42
  },
43
43
  "peerDependencies": {
@@ -11,11 +11,17 @@
11
11
  (func_operation name: _ @function.builtin)
12
12
  (module_operation name: _ @function.builtin)
13
13
  (func_operation ["private" "public" "attributes"] @keyword)
14
+ (function_specifier) @keyword
14
15
  (module_operation "attributes" @keyword)
15
16
 
16
17
  ;; Dialect operations (e.g., arith.addi)
17
18
  (custom_op_name) @function.builtin
18
- (generic_operation (string_literal) @function.builtin)
19
+ (custom_operation ["array" "sparse" "tensor" "vector"] @keyword)
20
+ (custom_operation ["+" "-" "*" "/" "&" "|" "~"] @operator)
21
+ (custom_operation "?" @punctuation.special)
22
+ (custom_operation "loc" @keyword)
23
+ (custom_operation "module(" @keyword)
24
+ (custom_operation ">" @punctuation.bracket)
19
25
 
20
26
  ;; Symbols (@name)
21
27
  (symbol_ref_id) @string.special.symbol
@@ -42,20 +48,48 @@
42
48
  (dim_list "x" @punctuation.delimiter)
43
49
  (dimension_separator) @punctuation.delimiter
44
50
  (vector_dim_list "x" @punctuation.delimiter)
51
+ (dim_list ["?" "*"] @punctuation.special)
52
+ (dialect_dim_list ["?" "*"] @punctuation.special)
45
53
 
46
54
  [(attribute_alias) (attribute_alias_def) (dialect_attribute) (builtin_attribute) (dictionary_attribute)] @attribute
47
55
 
48
56
  ;; Specific attribute content
57
+ (properties ["<{" "}>"] @punctuation.bracket)
58
+ (affine_map "affine_map" @keyword)
59
+ (affine_set "affine_set" @keyword)
49
60
  (affine_map ["max" "min" "symbol"] @keyword)
50
61
  (affine_set ["max" "min" "symbol"] @keyword)
62
+ (affine_map
63
+ ["dense" "sparse" "compressed" "singleton" "loose_compressed" "n_out_of_m"]
64
+ @keyword)
65
+ (affine_set
66
+ ["dense" "sparse" "compressed" "singleton" "loose_compressed" "n_out_of_m"]
67
+ @keyword)
68
+ (affine_map ["+" "-" "*" "==" ">=" "<="] @operator)
69
+ (affine_set ["+" "-" "*" "==" ">=" "<="] @operator)
70
+ (strided_layout "strided" @keyword)
51
71
  (strided_layout "offset" @keyword)
52
- ["ceildiv" "floordiv" "mod"] @keyword.operator
72
+ (strided_layout ["?" "*"] @punctuation.special)
73
+ (distinct_attribute "distinct" @keyword)
74
+ (dense_resource_literal "dense_resource" @keyword)
75
+ ["ceildiv" "floordiv" "mod"] @operator
76
+ (pretty_dialect_item_body
77
+ ["array" "dense" "opaque" "sparse" "tensor" "vector"] @keyword)
78
+ (pretty_dialect_item_body ["?" "*"] @punctuation.special)
53
79
 
54
80
  ;; ── Literals ────────────────────────────────────────────────────────────────
55
81
  [(integer_literal) (float_literal) (complex_literal)] @number
56
82
  (bool_literal) @boolean
57
- [(tensor_literal) (dense_resource_literal) (array_literal) (unit_literal) (uninitialized_literal)] @constant.builtin
83
+ [(tensor_literal) (array_literal) (unit_literal) (uninitialized_literal)] @constant.builtin
84
+ (tensor_literal ["dense" "sparse"] @keyword)
85
+ (array_literal "array" @keyword)
58
86
  (string_literal) @string
87
+ (generic_operation (string_literal) @function.builtin)
88
+
89
+ ;; Escape sequences inside strings (\n, \t, \", \\, \HH) overlay on @string;
90
+ ;; malformed escapes are flagged distinctly rather than silently colored.
91
+ (escape_sequence) @string.escape
92
+ (invalid_escape) @error
59
93
 
60
94
  ;; ── SSA Variables (%name) ───────────────────────────────────────────────────
61
95
  ;; General uses and results (catch-all, overridden by more specific rules below)
@@ -67,17 +101,31 @@
67
101
  (block_arg_list (value_use) @variable.parameter)
68
102
 
69
103
  ;; ── Control Flow ────────────────────────────────────────────────────────────
70
- (caret_id) @label
104
+ (caret_id) @tag
71
105
  (trailing_location "loc" @keyword)
106
+ (callsite_location ["callsite" "at"] @keyword)
107
+ (fused_location "fused" @keyword)
108
+ (location "to" @keyword)
109
+ (unknown_location) @constant.builtin
72
110
  (variadic) @punctuation.special
73
111
 
112
+ ;; ── External Resource Blocks ───────────────────────────────────────────────
113
+ (external_resources ["{-#" "#-}"] @punctuation.bracket)
114
+
74
115
  ;; ── Punctuation ─────────────────────────────────────────────────────────────
75
116
  ["(" ")" "{" "}" "[" "]" "<" ">"] @punctuation.bracket
76
117
  ["," ":"] @punctuation.delimiter
77
118
  ["=" "->" "::"] @operator
78
119
 
79
- ;; Catch-all for bare keywords in Op bodies (ins, outs, etc.)
80
- (bare_id) @keyword
120
+ ;; Catch-all for bare keywords in custom operation bodies (ins, outs, etc.).
121
+ ;; Keep this scoped to direct custom_operation children so attribute keys,
122
+ ;; affine dimensions, and pretty dialect payload identifiers do not all become
123
+ ;; keywords.
124
+ (custom_operation (bare_id) @keyword)
125
+
126
+ ;; Dense resource handles override the bare_id catch-all above.
127
+ (dense_resource_literal (bare_id) @constant.builtin)
81
128
 
82
129
  ;; Dictionary attribute keys override the bare_id catch-all above
83
130
  (attribute_entry (bare_id) @attribute)
131
+ (attribute_entry (string_literal) @attribute)
package/src/parser.c CHANGED
@@ -76085,7 +76085,7 @@ TS_PUBLIC const TSLanguage *tree_sitter_mlir(void) {
76085
76085
  .metadata = {
76086
76086
  .major_version = 0,
76087
76087
  .minor_version = 1,
76088
- .patch_version = 5,
76088
+ .patch_version = 6,
76089
76089
  },
76090
76090
  };
76091
76091
  return &language;
Binary file
package/tree-sitter.json CHANGED
@@ -8,11 +8,14 @@
8
8
  "scope": "source.mlir",
9
9
  "file-types": ["mlir"],
10
10
  "injection-regex": "^mlir$",
11
- "class-name": "TreeSitterMlir"
11
+ "class-name": "TreeSitterMlir",
12
+ "highlights": "queries/highlights.scm",
13
+ "locals": "queries/locals.scm",
14
+ "injections": "queries/injections.scm"
12
15
  }
13
16
  ],
14
17
  "metadata": {
15
- "version": "0.1.5",
18
+ "version": "0.1.6",
16
19
  "license": "Apache-2.0 WITH LLVM-exception",
17
20
  "description": "MLIR grammar for tree-sitter",
18
21
  "authors": [