@willbooster/tree-sitter-javascript 7.0.0 → 7.0.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/grammar.js +39 -24
- package/package.json +1 -1
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter.json +5 -2
package/grammar.js
CHANGED
|
@@ -118,6 +118,12 @@ module.exports = grammar({
|
|
|
118
118
|
sym('_function_context_end'),
|
|
119
119
|
sym('_arrow_context_end'),
|
|
120
120
|
sym('_await_identifier'),
|
|
121
|
+
sym('_generator_function_start'),
|
|
122
|
+
sym('_async_generator_function_start'),
|
|
123
|
+
sym('_yield_keyword'),
|
|
124
|
+
sym('_yield_identifier'),
|
|
125
|
+
sym('_function_signature_start'),
|
|
126
|
+
sym('_async_function_signature_start'),
|
|
121
127
|
],
|
|
122
128
|
|
|
123
129
|
extras: ($) => [$.comment, sym('html_comment'), /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
|
|
@@ -646,7 +652,10 @@ module.exports = grammar({
|
|
|
646
652
|
|
|
647
653
|
yield_expression: ($) =>
|
|
648
654
|
prec.right(
|
|
649
|
-
seq(
|
|
655
|
+
seq(
|
|
656
|
+
alias(sym('_yield_keyword'), 'yield'),
|
|
657
|
+
choice(seq('*', $.expression), optional($.expression), sym('_line_break_ends_statement'))
|
|
658
|
+
)
|
|
650
659
|
),
|
|
651
660
|
|
|
652
661
|
object: ($) =>
|
|
@@ -840,8 +849,7 @@ module.exports = grammar({
|
|
|
840
849
|
...(async ? ['async'] : []),
|
|
841
850
|
'function',
|
|
842
851
|
field('name', optional($.identifier)),
|
|
843
|
-
$._call_signature,
|
|
844
|
-
contextBody(async, field('body', $.statement_block))
|
|
852
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
845
853
|
)
|
|
846
854
|
)
|
|
847
855
|
),
|
|
@@ -860,8 +868,7 @@ module.exports = grammar({
|
|
|
860
868
|
),
|
|
861
869
|
seq(...(async ? ['async'] : []), 'function', field('name', $.identifier))
|
|
862
870
|
),
|
|
863
|
-
$._call_signature,
|
|
864
|
-
contextBody(async, field('body', $.statement_block))
|
|
871
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
865
872
|
)
|
|
866
873
|
)
|
|
867
874
|
),
|
|
@@ -875,8 +882,7 @@ module.exports = grammar({
|
|
|
875
882
|
'function',
|
|
876
883
|
'*',
|
|
877
884
|
field('name', optional($.identifier)),
|
|
878
|
-
$._call_signature,
|
|
879
|
-
contextBody(async, field('body', $.statement_block))
|
|
885
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)), 'generator_function')
|
|
880
886
|
)
|
|
881
887
|
)
|
|
882
888
|
),
|
|
@@ -896,8 +902,7 @@ module.exports = grammar({
|
|
|
896
902
|
),
|
|
897
903
|
seq(...(async ? ['async'] : []), 'function', '*', field('name', $.identifier))
|
|
898
904
|
),
|
|
899
|
-
$._call_signature,
|
|
900
|
-
contextBody(async, field('body', $.statement_block))
|
|
905
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)), 'generator_function')
|
|
901
906
|
)
|
|
902
907
|
)
|
|
903
908
|
),
|
|
@@ -964,8 +969,7 @@ module.exports = grammar({
|
|
|
964
969
|
...(async ? ['async'] : []),
|
|
965
970
|
'function',
|
|
966
971
|
field('name', optional($.identifier)),
|
|
967
|
-
$._call_signature,
|
|
968
|
-
contextBody(async, field('body', $.statement_block))
|
|
972
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)))
|
|
969
973
|
)
|
|
970
974
|
)
|
|
971
975
|
),
|
|
@@ -980,8 +984,7 @@ module.exports = grammar({
|
|
|
980
984
|
'function',
|
|
981
985
|
'*',
|
|
982
986
|
field('name', optional($.identifier)),
|
|
983
|
-
$._call_signature,
|
|
984
|
-
contextBody(async, field('body', $.statement_block))
|
|
987
|
+
functionScope(async, seq($._call_signature, field('body', $.statement_block)), 'generator_function')
|
|
985
988
|
)
|
|
986
989
|
)
|
|
987
990
|
),
|
|
@@ -1487,14 +1490,22 @@ module.exports = grammar({
|
|
|
1487
1490
|
|
|
1488
1491
|
method_definition: ($) =>
|
|
1489
1492
|
functionContext((async) =>
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1493
|
+
choice(
|
|
1494
|
+
...[false, true].map((generator) =>
|
|
1495
|
+
seq(
|
|
1496
|
+
repeat(field('decorator', $.decorator)),
|
|
1497
|
+
optional('static'),
|
|
1498
|
+
...(async ? ['async'] : []),
|
|
1499
|
+
...(generator ? ['*'] : [optional(choice('get', 'set'))]),
|
|
1500
|
+
field('name', $._property_name),
|
|
1501
|
+
field('parameters', $.formal_parameters),
|
|
1502
|
+
functionScope(
|
|
1503
|
+
async,
|
|
1504
|
+
field('body', alias($._class_member_body, $.statement_block)),
|
|
1505
|
+
generator ? 'generator_function' : 'function'
|
|
1506
|
+
)
|
|
1507
|
+
)
|
|
1508
|
+
)
|
|
1498
1509
|
)
|
|
1499
1510
|
),
|
|
1500
1511
|
|
|
@@ -1515,6 +1526,7 @@ module.exports = grammar({
|
|
|
1515
1526
|
alias(
|
|
1516
1527
|
choice(
|
|
1517
1528
|
$.identifier,
|
|
1529
|
+
sym('_yield_identifier'),
|
|
1518
1530
|
$._escaped_let,
|
|
1519
1531
|
...CONTEXTUAL_KEYWORDS.map((word) =>
|
|
1520
1532
|
word === 'await' ? choice(sym('_await_keyword'), sym('_await_identifier')) : word
|
|
@@ -1545,6 +1557,7 @@ module.exports = grammar({
|
|
|
1545
1557
|
|
|
1546
1558
|
_reserved_identifier: ($) =>
|
|
1547
1559
|
choice(
|
|
1560
|
+
sym('_yield_identifier'),
|
|
1548
1561
|
...MEMBER_MODIFIERS,
|
|
1549
1562
|
$._escaped_let,
|
|
1550
1563
|
...CONTEXTUAL_KEYWORDS.map((word) =>
|
|
@@ -1590,8 +1603,10 @@ function functionContext(makeRule) {
|
|
|
1590
1603
|
}
|
|
1591
1604
|
/**
|
|
1592
1605
|
* @param {boolean} async
|
|
1593
|
-
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral}
|
|
1606
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
|
|
1607
|
+
* @param {'function_signature' | 'generator_function' | 'function'} [kind]
|
|
1594
1608
|
*/
|
|
1595
|
-
function
|
|
1596
|
-
|
|
1609
|
+
function functionScope(async, content, kind = 'function_signature') {
|
|
1610
|
+
const name = kind === 'function' && !async ? 'sync_function' : `${async ? 'async_' : ''}${kind}`;
|
|
1611
|
+
return seq(sym(`_${name}_start`), content, sym('_function_context_end'));
|
|
1597
1612
|
}
|
package/package.json
CHANGED
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -20,11 +20,14 @@
|
|
|
20
20
|
"injections": "queries/injections.scm",
|
|
21
21
|
"locals": "queries/locals.scm",
|
|
22
22
|
"tags": "queries/tags.scm",
|
|
23
|
-
"injection-regex": "^(js|javascript)$"
|
|
23
|
+
"injection-regex": "^(js|javascript)$",
|
|
24
|
+
"external-files": [
|
|
25
|
+
"src/function_context.h"
|
|
26
|
+
]
|
|
24
27
|
}
|
|
25
28
|
],
|
|
26
29
|
"metadata": {
|
|
27
|
-
"version": "7.0.
|
|
30
|
+
"version": "7.0.1",
|
|
28
31
|
"license": "MIT",
|
|
29
32
|
"description": "JavaScript grammar for tree-sitter",
|
|
30
33
|
"authors": [
|