@hew-lang/tree-sitter-hew 1.4.1 → 1.4.4

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/grammar.js CHANGED
@@ -22,6 +22,7 @@ const PREC = {
22
22
  SHIFT: 12, // << >>
23
23
  ADD: 13, // + - &+ &-
24
24
  MUL: 15, // * / % &*
25
+ CAST: 16, // as (below every prefix: `-x as T` is `(-x) as T`)
25
26
  UNARY: 17, // ! - ~ clone
26
27
  TRY: 18, // ?
27
28
  TASK: 19, // await fork
@@ -559,10 +560,12 @@ export default grammar({
559
560
  // SupervisorField (spec grammar.ebnf:142-144):
560
561
  // "strategy" ":" SupervisorStrategy
561
562
  // "intensity" ":" IntLit "within" DurationLit
563
+ // "backoff" ":" Expression
562
564
  // `within` is a contextual keyword used only here. DurationLit is reused.
563
565
  supervisor_field: $ => choice(
564
566
  seq('strategy', ':', field('strategy', $.supervisor_strategy_value), ';'),
565
567
  seq('intensity', ':', field('restarts', $.integer_literal), 'within', field('window', $.duration_literal), ';'),
568
+ seq('backoff', ':', field('backoff', $.expression), ';'),
566
569
  ),
567
570
 
568
571
  child_spec: $ => seq(
@@ -579,6 +582,7 @@ export default grammar({
579
582
  child_clause: $ => choice(
580
583
  seq('count', ':', $.integer_literal),
581
584
  seq('restart', ':', choice('permanent', 'transient', 'temporary')),
585
+ seq('backoff', ':', field('backoff', $.expression)),
582
586
  seq('stop', ':', $.expression),
583
587
  seq('wired_to', ':', '{', repeat(seq($.identifier, optional(seq(':', $.identifier)), optional(','))), '}'),
584
588
  ),
@@ -961,13 +965,14 @@ export default grammar({
961
965
 
962
966
  match_arm: $ => prec(3, seq(
963
967
  $._match_arm_head,
964
- field('value', choice($._block_arm_value, seq($.expression, ','))),
968
+ field('value', choice(seq($._block_arm_value, optional(',')), seq($.expression, ','))),
965
969
  )),
966
970
 
967
971
  _match_final_arm: $ => prec(3, seq($._match_arm_head, field('value', $.expression))),
968
972
 
969
973
  // Match and select share the compiler's source-token classification:
970
- // brace-bodied expressions end at `}`, while other expressions need `,`.
974
+ // brace-bodied arms may add one comma, while expression arms need it
975
+ // before the next arm.
971
976
  _block_arm_value: $ => choice(
972
977
  $.block,
973
978
  $.if_expression,
@@ -1259,7 +1264,7 @@ export default grammar({
1259
1264
  '?',
1260
1265
  )),
1261
1266
 
1262
- cast_expression: $ => prec(PREC.POSTFIX, seq(
1267
+ cast_expression: $ => prec.left(PREC.CAST, seq(
1263
1268
  field('value', $.expression),
1264
1269
  'as',
1265
1270
  field('type', $._type),
@@ -1475,7 +1480,7 @@ export default grammar({
1475
1480
  // stays usable as an ordinary name everywhere else.
1476
1481
  select_arm: $ => prec(3, seq(
1477
1482
  $._select_arm_head,
1478
- field('body', choice($._block_arm_value, seq($.expression, ','))),
1483
+ field('body', choice(seq($._block_arm_value, optional(',')), seq($.expression, ','))),
1479
1484
  )),
1480
1485
 
1481
1486
  _select_arm_head: $ => choice(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hew-lang/tree-sitter-hew",
3
- "version": "1.4.1",
3
+ "version": "1.4.4",
4
4
  "description": "Hew grammar for tree-sitter",
5
5
  "type": "module",
6
6
  "repository": {
@@ -24,7 +24,8 @@
24
24
  (failure_return "fails" @keyword)
25
25
  (return_error_expression "error" @keyword)
26
26
  (defer_statement "err" @keyword)
27
- (child_clause ["count" "stop"] @keyword)
27
+ (child_clause ["count" "stop" "backoff"] @keyword)
28
+ (supervisor_field "backoff" @keyword)
28
29
 
29
30
  "receive" @keyword
30
31
 
package/src/grammar.json CHANGED
@@ -3129,6 +3129,31 @@
3129
3129
  "value": ";"
3130
3130
  }
3131
3131
  ]
3132
+ },
3133
+ {
3134
+ "type": "SEQ",
3135
+ "members": [
3136
+ {
3137
+ "type": "STRING",
3138
+ "value": "backoff"
3139
+ },
3140
+ {
3141
+ "type": "STRING",
3142
+ "value": ":"
3143
+ },
3144
+ {
3145
+ "type": "FIELD",
3146
+ "name": "backoff",
3147
+ "content": {
3148
+ "type": "SYMBOL",
3149
+ "name": "expression"
3150
+ }
3151
+ },
3152
+ {
3153
+ "type": "STRING",
3154
+ "value": ";"
3155
+ }
3156
+ ]
3132
3157
  }
3133
3158
  ]
3134
3159
  },
@@ -3243,6 +3268,27 @@
3243
3268
  }
3244
3269
  ]
3245
3270
  },
3271
+ {
3272
+ "type": "SEQ",
3273
+ "members": [
3274
+ {
3275
+ "type": "STRING",
3276
+ "value": "backoff"
3277
+ },
3278
+ {
3279
+ "type": "STRING",
3280
+ "value": ":"
3281
+ },
3282
+ {
3283
+ "type": "FIELD",
3284
+ "name": "backoff",
3285
+ "content": {
3286
+ "type": "SYMBOL",
3287
+ "name": "expression"
3288
+ }
3289
+ }
3290
+ ]
3291
+ },
3246
3292
  {
3247
3293
  "type": "SEQ",
3248
3294
  "members": [
@@ -5995,8 +6041,25 @@
5995
6041
  "type": "CHOICE",
5996
6042
  "members": [
5997
6043
  {
5998
- "type": "SYMBOL",
5999
- "name": "_block_arm_value"
6044
+ "type": "SEQ",
6045
+ "members": [
6046
+ {
6047
+ "type": "SYMBOL",
6048
+ "name": "_block_arm_value"
6049
+ },
6050
+ {
6051
+ "type": "CHOICE",
6052
+ "members": [
6053
+ {
6054
+ "type": "STRING",
6055
+ "value": ","
6056
+ },
6057
+ {
6058
+ "type": "BLANK"
6059
+ }
6060
+ ]
6061
+ }
6062
+ ]
6000
6063
  },
6001
6064
  {
6002
6065
  "type": "SEQ",
@@ -7854,8 +7917,8 @@
7854
7917
  }
7855
7918
  },
7856
7919
  "cast_expression": {
7857
- "type": "PREC",
7858
- "value": 20,
7920
+ "type": "PREC_LEFT",
7921
+ "value": 16,
7859
7922
  "content": {
7860
7923
  "type": "SEQ",
7861
7924
  "members": [
@@ -9371,8 +9434,25 @@
9371
9434
  "type": "CHOICE",
9372
9435
  "members": [
9373
9436
  {
9374
- "type": "SYMBOL",
9375
- "name": "_block_arm_value"
9437
+ "type": "SEQ",
9438
+ "members": [
9439
+ {
9440
+ "type": "SYMBOL",
9441
+ "name": "_block_arm_value"
9442
+ },
9443
+ {
9444
+ "type": "CHOICE",
9445
+ "members": [
9446
+ {
9447
+ "type": "STRING",
9448
+ "value": ","
9449
+ },
9450
+ {
9451
+ "type": "BLANK"
9452
+ }
9453
+ ]
9454
+ }
9455
+ ]
9376
9456
  },
9377
9457
  {
9378
9458
  "type": "SEQ",
@@ -1426,7 +1426,18 @@
1426
1426
  {
1427
1427
  "type": "child_clause",
1428
1428
  "named": true,
1429
- "fields": {},
1429
+ "fields": {
1430
+ "backoff": {
1431
+ "multiple": false,
1432
+ "required": false,
1433
+ "types": [
1434
+ {
1435
+ "type": "expression",
1436
+ "named": true
1437
+ }
1438
+ ]
1439
+ }
1440
+ },
1430
1441
  "children": {
1431
1442
  "multiple": true,
1432
1443
  "required": false,
@@ -6060,6 +6071,16 @@
6060
6071
  "type": "supervisor_field",
6061
6072
  "named": true,
6062
6073
  "fields": {
6074
+ "backoff": {
6075
+ "multiple": false,
6076
+ "required": false,
6077
+ "types": [
6078
+ {
6079
+ "type": "expression",
6080
+ "named": true
6081
+ }
6082
+ ]
6083
+ },
6063
6084
  "restarts": {
6064
6085
  "multiple": false,
6065
6086
  "required": false,
@@ -7394,6 +7415,10 @@
7394
7415
  "type": "await",
7395
7416
  "named": false
7396
7417
  },
7418
+ {
7419
+ "type": "backoff",
7420
+ "named": false
7421
+ },
7397
7422
  {
7398
7423
  "type": "block",
7399
7424
  "named": false
@@ -7976,4 +8001,4 @@
7976
8001
  "type": "~",
7977
8002
  "named": false
7978
8003
  }
7979
- ]
8004
+ ]