@felixtensor/tree-sitter-mlir 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![CI](https://github.com/felixtensor/tree-sitter-mlir/actions/workflows/ci.yml/badge.svg)](https://github.com/felixtensor/tree-sitter-mlir/actions/workflows/ci.yml)
4
4
  [![crates.io](https://img.shields.io/crates/v/tree-sitter-mlir.svg?logo=rust)](https://crates.io/crates/tree-sitter-mlir)
5
5
  [![PyPI](https://img.shields.io/pypi/v/tree-sitter-mlir.svg?logo=pypi&logoColor=white)](https://pypi.org/project/tree-sitter-mlir/)
6
+ [![npm](https://img.shields.io/npm/v/@felixtensor/tree-sitter-mlir.svg?logo=npm)](https://www.npmjs.com/package/@felixtensor/tree-sitter-mlir)
6
7
 
7
8
  [MLIR](https://mlir.llvm.org) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
8
9
 
package/grammar.js CHANGED
@@ -250,18 +250,22 @@ export default grammar({
250
250
  prec(2, $.type), // !type, i32, memref<...>, etc.
251
251
  $.attribute, // #attr, {dict}, affine_map<...>
252
252
  $.region, // { ... } (regions with operations)
253
+ $._custom_body_value_group, // {%v : type, ...}
253
254
  $._custom_body_paren, // ( ... )
254
255
  $._custom_body_bracket, // [ ... ]
255
256
  $._custom_body_angle_group, // < ... >
256
257
  $._literal, // 42, 3.14, "string", true, dense<...>
257
258
  'array', // property names may collide with array<...>
259
+ 'vector', // OpenACC keyword may collide with vector<...>
258
260
  'ceildiv', 'floordiv', 'mod', // inline affine keywords
259
261
  $.bare_id, // keywords: to, from, step, ins, outs, etc.
260
- ',', '=', ':', '->', '*', '+', '-', '/', '&', '|', '~',
262
+ ',', '=', ':', '->', '*', '?', $.dimension_separator, '+', '-', '/', '&', '|', '~',
261
263
  ),
262
264
 
263
265
  _custom_body_paren: $ => seq('(', repeat($._nested_custom_body_element), ')'),
264
266
  _custom_body_bracket: $ => seq('[', repeat($._nested_custom_body_element), ']'),
267
+ _custom_body_value_group: $ => seq('{', $.value_use, ':', $.type,
268
+ repeat(seq(',', $.value_use, ':', $.type)), '}'),
265
269
  _custom_body_angle_group: $ => seq('<', repeat($._nested_custom_body_element), '>'),
266
270
  // Only nested groups accept `trailing_location` as a body element.
267
271
  // At the top level it is omitted on purpose so the operation rule
@@ -271,11 +275,11 @@ export default grammar({
271
275
 
272
276
  // =========================================================================
273
277
  // Blocks
274
- // block ::= block-label operation+
278
+ // block ::= block-label operation*
275
279
  // block-label ::= block-id block-arg-list? `:`
276
280
  // caret-id ::= `^` suffix-id
277
281
  // =========================================================================
278
- block: $ => seq($.block_label, repeat1($.operation)),
282
+ block: $ => seq($.block_label, repeat($.operation)),
279
283
  block_label: $ => seq($._block_id, optional($.block_arg_list), ':'),
280
284
  _block_id: $ => $.caret_id,
281
285
  caret_id: $ => seq('^', $._suffix_id),
@@ -336,9 +340,9 @@ export default grammar({
336
340
  $.type,
337
341
  prec(2, $.attribute),
338
342
  $._literal,
339
- 'dense', 'sparse', 'array',
343
+ 'dense', 'sparse', 'array', 'vector',
340
344
  $.bare_id,
341
- ',', ':', '=', '->', '(', ')', '[', ']', '{', '}', '*',
345
+ ',', ':', '=', '->', '(', ')', '[', ']', '{', '}', '*', '?',
342
346
  '@', '#',
343
347
  token(prec(-1, /[^<>]/))
344
348
  )),
@@ -400,7 +404,7 @@ export default grammar({
400
404
  optional(seq(',', $.tensor_encoding)), '>'),
401
405
  tensor_encoding: $ => $.attribute_value,
402
406
 
403
- vector_type: $ => seq(token('vector'), '<', repeat($.vector_dim_list), $._prim_type, '>'),
407
+ vector_type: $ => prec(1, seq(token('vector'), '<', repeat($.vector_dim_list), $._prim_type, '>')),
404
408
  vector_dim_list: $ => prec.left(choice(seq($._static_dim_list, 'x',
405
409
  optional(seq('[', $._static_dim_list, ']', 'x'))), seq('[', $._static_dim_list, ']', 'x'))),
406
410
  _static_dim_list: $ => seq($.dimension_size, repeat(seq('x', $.dimension_size))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felixtensor/tree-sitter-mlir",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MLIR grammar for tree-sitter",
5
5
  "type": "module",
6
6
  "repository": {
package/src/grammar.json CHANGED
@@ -2005,6 +2005,10 @@
2005
2005
  "type": "SYMBOL",
2006
2006
  "name": "region"
2007
2007
  },
2008
+ {
2009
+ "type": "SYMBOL",
2010
+ "name": "_custom_body_value_group"
2011
+ },
2008
2012
  {
2009
2013
  "type": "SYMBOL",
2010
2014
  "name": "_custom_body_paren"
@@ -2025,6 +2029,10 @@
2025
2029
  "type": "STRING",
2026
2030
  "value": "array"
2027
2031
  },
2032
+ {
2033
+ "type": "STRING",
2034
+ "value": "vector"
2035
+ },
2028
2036
  {
2029
2037
  "type": "STRING",
2030
2038
  "value": "ceildiv"
@@ -2061,6 +2069,14 @@
2061
2069
  "type": "STRING",
2062
2070
  "value": "*"
2063
2071
  },
2072
+ {
2073
+ "type": "STRING",
2074
+ "value": "?"
2075
+ },
2076
+ {
2077
+ "type": "SYMBOL",
2078
+ "name": "dimension_separator"
2079
+ },
2064
2080
  {
2065
2081
  "type": "STRING",
2066
2082
  "value": "+"
@@ -2127,6 +2143,55 @@
2127
2143
  }
2128
2144
  ]
2129
2145
  },
2146
+ "_custom_body_value_group": {
2147
+ "type": "SEQ",
2148
+ "members": [
2149
+ {
2150
+ "type": "STRING",
2151
+ "value": "{"
2152
+ },
2153
+ {
2154
+ "type": "SYMBOL",
2155
+ "name": "value_use"
2156
+ },
2157
+ {
2158
+ "type": "STRING",
2159
+ "value": ":"
2160
+ },
2161
+ {
2162
+ "type": "SYMBOL",
2163
+ "name": "type"
2164
+ },
2165
+ {
2166
+ "type": "REPEAT",
2167
+ "content": {
2168
+ "type": "SEQ",
2169
+ "members": [
2170
+ {
2171
+ "type": "STRING",
2172
+ "value": ","
2173
+ },
2174
+ {
2175
+ "type": "SYMBOL",
2176
+ "name": "value_use"
2177
+ },
2178
+ {
2179
+ "type": "STRING",
2180
+ "value": ":"
2181
+ },
2182
+ {
2183
+ "type": "SYMBOL",
2184
+ "name": "type"
2185
+ }
2186
+ ]
2187
+ }
2188
+ },
2189
+ {
2190
+ "type": "STRING",
2191
+ "value": "}"
2192
+ }
2193
+ ]
2194
+ },
2130
2195
  "_custom_body_angle_group": {
2131
2196
  "type": "SEQ",
2132
2197
  "members": [
@@ -2168,7 +2233,7 @@
2168
2233
  "name": "block_label"
2169
2234
  },
2170
2235
  {
2171
- "type": "REPEAT1",
2236
+ "type": "REPEAT",
2172
2237
  "content": {
2173
2238
  "type": "SYMBOL",
2174
2239
  "name": "operation"
@@ -2803,6 +2868,10 @@
2803
2868
  "type": "STRING",
2804
2869
  "value": "array"
2805
2870
  },
2871
+ {
2872
+ "type": "STRING",
2873
+ "value": "vector"
2874
+ },
2806
2875
  {
2807
2876
  "type": "SYMBOL",
2808
2877
  "name": "bare_id"
@@ -2851,6 +2920,10 @@
2851
2920
  "type": "STRING",
2852
2921
  "value": "*"
2853
2922
  },
2923
+ {
2924
+ "type": "STRING",
2925
+ "value": "?"
2926
+ },
2854
2927
  {
2855
2928
  "type": "STRING",
2856
2929
  "value": "@"
@@ -3503,35 +3576,39 @@
3503
3576
  "name": "attribute_value"
3504
3577
  },
3505
3578
  "vector_type": {
3506
- "type": "SEQ",
3507
- "members": [
3508
- {
3509
- "type": "TOKEN",
3510
- "content": {
3579
+ "type": "PREC",
3580
+ "value": 1,
3581
+ "content": {
3582
+ "type": "SEQ",
3583
+ "members": [
3584
+ {
3585
+ "type": "TOKEN",
3586
+ "content": {
3587
+ "type": "STRING",
3588
+ "value": "vector"
3589
+ }
3590
+ },
3591
+ {
3511
3592
  "type": "STRING",
3512
- "value": "vector"
3513
- }
3514
- },
3515
- {
3516
- "type": "STRING",
3517
- "value": "<"
3518
- },
3519
- {
3520
- "type": "REPEAT",
3521
- "content": {
3593
+ "value": "<"
3594
+ },
3595
+ {
3596
+ "type": "REPEAT",
3597
+ "content": {
3598
+ "type": "SYMBOL",
3599
+ "name": "vector_dim_list"
3600
+ }
3601
+ },
3602
+ {
3522
3603
  "type": "SYMBOL",
3523
- "name": "vector_dim_list"
3604
+ "name": "_prim_type"
3605
+ },
3606
+ {
3607
+ "type": "STRING",
3608
+ "value": ">"
3524
3609
  }
3525
- },
3526
- {
3527
- "type": "SYMBOL",
3528
- "name": "_prim_type"
3529
- },
3530
- {
3531
- "type": "STRING",
3532
- "value": ">"
3533
- }
3534
- ]
3610
+ ]
3611
+ }
3535
3612
  },
3536
3613
  "vector_dim_list": {
3537
3614
  "type": "PREC_LEFT",
@@ -598,6 +598,10 @@
598
598
  "type": "bool_literal",
599
599
  "named": true
600
600
  },
601
+ {
602
+ "type": "dimension_separator",
603
+ "named": true
604
+ },
601
605
  {
602
606
  "type": "float_literal",
603
607
  "named": true