@willbooster/tree-sitter-c-sharp 1.0.10 → 1.0.12
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 +19 -19
- package/package.json +1 -1
- package/src/node-types.json +4 -0
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -1205,7 +1205,9 @@ module.exports = grammar({
|
|
|
1205
1205
|
|
|
1206
1206
|
assignment_expression: ($) =>
|
|
1207
1207
|
seq(
|
|
1208
|
-
|
|
1208
|
+
// An invocation can return a reference (`Unsafe.Add(ref x, i) = v`). It ends with `)`, so `=` after it adds few
|
|
1209
|
+
// parse states, unlike making any expression assignable.
|
|
1210
|
+
field('left', choice($.lvalue_expression, $.invocation_expression)),
|
|
1209
1211
|
field('operator', choice('=', '+=', '-=', '*=', '/=', '%=', '&=', '^=', '|=', '<<=', '>>=', '>>>=', '??=')),
|
|
1210
1212
|
field('right', $.expression)
|
|
1211
1213
|
),
|
|
@@ -1251,19 +1253,15 @@ module.exports = grammar({
|
|
|
1251
1253
|
|
|
1252
1254
|
postfix_unary_expression: ($) => prec(PREC.POSTFIX, seq(postfixOperand($), choice('++', '--', '!'))),
|
|
1253
1255
|
|
|
1256
|
+
// `&` and `*` have rules of their own (`_address_of_expression`, `_pointer_indirection_expression`, and
|
|
1257
|
+
// `_value_indirection_expression`), aliased to this node. The dynamic precedence of `+`, `-`, and `^` is explained
|
|
1258
|
+
// at `_pointer_indirection_expression`.
|
|
1254
1259
|
prefix_unary_expression: ($) =>
|
|
1255
1260
|
prec(
|
|
1256
1261
|
PREC.UNARY,
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
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
|
|
1262
|
+
choice(
|
|
1263
|
+
seq(choice('++', '--', '!', '~'), $.expression),
|
|
1264
|
+
prec.dynamic(-2, seq(choice('+', '-', '^'), $.expression))
|
|
1267
1265
|
)
|
|
1268
1266
|
),
|
|
1269
1267
|
|
|
@@ -1275,12 +1273,13 @@ module.exports = grammar({
|
|
|
1275
1273
|
// form's operand lets `=` follow every expression that can be the operand, which grows the parser by about 4,800
|
|
1276
1274
|
// states and nearly doubles the Wasm build, while these operands add about 550.
|
|
1277
1275
|
//
|
|
1278
|
-
// Dynamic precedences: an assignable dereference -2, a read-only one -4, a read-only cast +1,
|
|
1279
|
-
// -
|
|
1280
|
-
// literal, or a keyword (C# spec §12.9.8 Cast expressions), and these values keep
|
|
1281
|
-
//
|
|
1282
|
-
//
|
|
1283
|
-
// (-2), not a cast of `[0]` (-
|
|
1276
|
+
// Dynamic precedences: an assignable dereference -2, a read-only one -4, a read-only cast +1, an assignable cast -1,
|
|
1277
|
+
// and a unary `+`, `-`, `^`, or `&` -2. C# reads a parenthesized name as a cast only when the token after `)` is
|
|
1278
|
+
// `~`, `!`, `(`, an identifier, a literal, or a keyword (C# spec §12.9.8 Cast expressions), and these values keep
|
|
1279
|
+
// that reading: `(a) * b`, `(a) - b`, and `(a) & b` are binary expressions (0), not casts of `*b`, `-b`, or `&b`
|
|
1280
|
+
// (+1 - 2); `*(p) + 1` and `*(p) & x` apply to a dereference of `(p)` (-2), not to a dereference of a cast of `+1`
|
|
1281
|
+
// or `&x` (-5); `*(b)[0]` dereferences an element access (-2), not a cast of `[0]` (-3). Where both casts fit, they
|
|
1282
|
+
// give the same tree.
|
|
1284
1283
|
_pointer_indirection_expression: ($) =>
|
|
1285
1284
|
prec.dynamic(
|
|
1286
1285
|
-2,
|
|
@@ -1327,9 +1326,10 @@ module.exports = grammar({
|
|
|
1327
1326
|
// Address-of is split out from `prefix_unary_expression` and takes only a variable: an lvalue, or an invocation,
|
|
1328
1327
|
// which can return a reference (`&span.GetPinnableReference()`). If a cast could take `&` before any expression,
|
|
1329
1328
|
// 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.
|
|
1329
|
+
// `(b > 0)` is not a variable, that reading fails and `&&` stays one token. The dynamic precedence is explained at
|
|
1330
|
+
// `_pointer_indirection_expression`.
|
|
1331
1331
|
_address_of_expression: ($) =>
|
|
1332
|
-
prec.right(PREC.UNARY, seq('&', choice($.lvalue_expression, $.invocation_expression))),
|
|
1332
|
+
prec.dynamic(-2, prec.right(PREC.UNARY, seq('&', choice($.lvalue_expression, $.invocation_expression)))),
|
|
1333
1333
|
|
|
1334
1334
|
query_expression: ($) => seq($.from_clause, $._query_body),
|
|
1335
1335
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|