@willbooster/tree-sitter-c-sharp 1.0.10 → 1.0.11

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
@@ -1251,19 +1251,15 @@ module.exports = grammar({
1251
1251
 
1252
1252
  postfix_unary_expression: ($) => prec(PREC.POSTFIX, seq(postfixOperand($), choice('++', '--', '!'))),
1253
1253
 
1254
+ // `&` and `*` have rules of their own (`_address_of_expression`, `_pointer_indirection_expression`, and
1255
+ // `_value_indirection_expression`), aliased to this node. The dynamic precedence of `+`, `-`, and `^` is explained
1256
+ // at `_pointer_indirection_expression`.
1254
1257
  prefix_unary_expression: ($) =>
1255
1258
  prec(
1256
1259
  PREC.UNARY,
1257
- seq(
1258
- // `&` and `*` are intentionally NOT in this choice list:
1259
- // * `&` → `_address_of_expression` (operand restricted to lvalue
1260
- // — see comment on that rule for the #413 rationale)
1261
- // * `*` → `_pointer_indirection_expression` and
1262
- // `_value_indirection_expression`
1263
- // They are aliased back to `prefix_unary_expression` so the
1264
- // public AST is unaffected.
1265
- choice('++', '--', '+', '-', '!', '~', '^'),
1266
- $.expression
1260
+ choice(
1261
+ seq(choice('++', '--', '!', '~'), $.expression),
1262
+ prec.dynamic(-2, seq(choice('+', '-', '^'), $.expression))
1267
1263
  )
1268
1264
  ),
1269
1265
 
@@ -1275,12 +1271,13 @@ module.exports = grammar({
1275
1271
  // form's operand lets `=` follow every expression that can be the operand, which grows the parser by about 4,800
1276
1272
  // states and nearly doubles the Wasm build, while these operands add about 550.
1277
1273
  //
1278
- // Dynamic precedences: an assignable dereference -2, a read-only one -4, a read-only cast +1, and an assignable cast
1279
- // -1. C# reads a parenthesized name as a cast only when the token after `)` is `~`, `!`, `(`, an identifier, a
1280
- // literal, or a keyword (C# spec §12.9.8 Cast expressions), and these values keep that reading: `(a) * b` is a
1281
- // multiplication (0), not a cast of `*b` (+1 - 2); `*(p) + 1` and `*(p) & x` apply to a dereference of `(p)` (-2),
1282
- // not to a dereference of a cast of `+1` or `&x` (-4 + 1 or -2 - 1); `*(b)[0]` dereferences an element access
1283
- // (-2), not a cast of `[0]` (-2 - 1). Where both casts fit, they give the same tree.
1274
+ // Dynamic precedences: an assignable dereference -2, a read-only one -4, a read-only cast +1, an assignable cast -1,
1275
+ // and a unary `+`, `-`, `^`, or `&` -2. C# reads a parenthesized name as a cast only when the token after `)` is
1276
+ // `~`, `!`, `(`, an identifier, a literal, or a keyword (C# spec §12.9.8 Cast expressions), and these values keep
1277
+ // that reading: `(a) * b`, `(a) - b`, and `(a) & b` are binary expressions (0), not casts of `*b`, `-b`, or `&b`
1278
+ // (+1 - 2); `*(p) + 1` and `*(p) & x` apply to a dereference of `(p)` (-2), not to a dereference of a cast of `+1`
1279
+ // or `&x` (-5); `*(b)[0]` dereferences an element access (-2), not a cast of `[0]` (-3). Where both casts fit, they
1280
+ // give the same tree.
1284
1281
  _pointer_indirection_expression: ($) =>
1285
1282
  prec.dynamic(
1286
1283
  -2,
@@ -1327,9 +1324,10 @@ module.exports = grammar({
1327
1324
  // Address-of is split out from `prefix_unary_expression` and takes only a variable: an lvalue, or an invocation,
1328
1325
  // which can return a reference (`&span.GetPinnableReference()`). If a cast could take `&` before any expression,
1329
1326
  // the lexer would split `&&` into two `&` tokens and `(a) && (b > 0)` would read as a cast of `&(&(b > 0))`; as
1330
- // `(b > 0)` is not a variable, that reading fails and `&&` stays one token.
1327
+ // `(b > 0)` is not a variable, that reading fails and `&&` stays one token. The dynamic precedence is explained at
1328
+ // `_pointer_indirection_expression`.
1331
1329
  _address_of_expression: ($) =>
1332
- prec.right(PREC.UNARY, seq('&', choice($.lvalue_expression, $.invocation_expression))),
1330
+ prec.dynamic(-2, prec.right(PREC.UNARY, seq('&', choice($.lvalue_expression, $.invocation_expression)))),
1333
1331
 
1334
1332
  query_expression: ($) => seq($.from_clause, $._query_body),
1335
1333
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "1.0.10",
22
+ "version": "1.0.11",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [