@ast-grep/lang-javascript 0.0.3 → 0.0.5
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/index.js +24 -2
- package/package.json +6 -6
- package/prebuilds/prebuild-Linux-X64/parser.so +0 -0
- package/prebuilds/prebuild-Windows-X64/parser.so +0 -0
- package/prebuilds/prebuild-macOS-ARM64/parser.so +0 -0
- package/src/grammar.json +375 -45
- package/src/node-types.json +64 -4
- package/src/parser.c +62263 -51518
- package/src/tree_sitter/array.h +2 -1
- package/src/tree_sitter/parser.h +27 -7
- package/type.d.ts +31 -4
package/index.js
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
const path = require('node:path')
|
|
2
|
-
const
|
|
2
|
+
const fs = require('node:fs')
|
|
3
|
+
const { resolvePrebuild } = require('@ast-grep/setup-lang')
|
|
4
|
+
|
|
5
|
+
function getLibPath() {
|
|
6
|
+
const prebuild = resolvePrebuild(__dirname)
|
|
7
|
+
if (prebuild) {
|
|
8
|
+
return prebuild
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const native = path.join(__dirname, 'parser.so')
|
|
12
|
+
if (fs.existsSync(native)) {
|
|
13
|
+
return native
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
throw new Error('No parser found. Please ensure the parser is built or a prebuild is available.')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let libPath
|
|
3
20
|
|
|
4
21
|
module.exports = {
|
|
5
|
-
libraryPath
|
|
22
|
+
get libraryPath() {
|
|
23
|
+
if (!libPath) {
|
|
24
|
+
libPath = getLibPath()
|
|
25
|
+
}
|
|
26
|
+
return libPath
|
|
27
|
+
},
|
|
6
28
|
extensions: ['cjs', 'js', 'mjs', 'jsx'],
|
|
7
29
|
languageSymbol: 'tree_sitter_javascript',
|
|
8
30
|
expandoChar: '$',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ast-grep/lang-javascript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ast-grep/setup-lang": "0.0.
|
|
21
|
+
"@ast-grep/setup-lang": "0.0.5"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"tree-sitter-cli": "0.25.
|
|
24
|
+
"tree-sitter-cli": "0.25.8"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"tree-sitter-cli": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@ast-grep/nursery": "0.0.
|
|
33
|
-
"tree-sitter-cli": "0.25.
|
|
34
|
-
"tree-sitter-javascript": "0.
|
|
32
|
+
"@ast-grep/nursery": "0.0.8",
|
|
33
|
+
"tree-sitter-cli": "0.25.8",
|
|
34
|
+
"tree-sitter-javascript": "0.25.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -292,6 +292,10 @@
|
|
|
292
292
|
{
|
|
293
293
|
"type": "SYMBOL",
|
|
294
294
|
"name": "string"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"type": "STRING",
|
|
298
|
+
"value": "default"
|
|
295
299
|
}
|
|
296
300
|
]
|
|
297
301
|
},
|
|
@@ -317,6 +321,10 @@
|
|
|
317
321
|
{
|
|
318
322
|
"type": "SYMBOL",
|
|
319
323
|
"name": "variable_declaration"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"type": "SYMBOL",
|
|
327
|
+
"name": "using_declaration"
|
|
320
328
|
}
|
|
321
329
|
]
|
|
322
330
|
},
|
|
@@ -760,6 +768,66 @@
|
|
|
760
768
|
}
|
|
761
769
|
]
|
|
762
770
|
},
|
|
771
|
+
"using_declaration": {
|
|
772
|
+
"type": "SEQ",
|
|
773
|
+
"members": [
|
|
774
|
+
{
|
|
775
|
+
"type": "FIELD",
|
|
776
|
+
"name": "kind",
|
|
777
|
+
"content": {
|
|
778
|
+
"type": "CHOICE",
|
|
779
|
+
"members": [
|
|
780
|
+
{
|
|
781
|
+
"type": "STRING",
|
|
782
|
+
"value": "using"
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
"type": "SEQ",
|
|
786
|
+
"members": [
|
|
787
|
+
{
|
|
788
|
+
"type": "STRING",
|
|
789
|
+
"value": "await"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
"type": "STRING",
|
|
793
|
+
"value": "using"
|
|
794
|
+
}
|
|
795
|
+
]
|
|
796
|
+
}
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
"type": "SEQ",
|
|
802
|
+
"members": [
|
|
803
|
+
{
|
|
804
|
+
"type": "SYMBOL",
|
|
805
|
+
"name": "variable_declarator"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"type": "REPEAT",
|
|
809
|
+
"content": {
|
|
810
|
+
"type": "SEQ",
|
|
811
|
+
"members": [
|
|
812
|
+
{
|
|
813
|
+
"type": "STRING",
|
|
814
|
+
"value": ","
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"type": "SYMBOL",
|
|
818
|
+
"name": "variable_declarator"
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
]
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"type": "SYMBOL",
|
|
827
|
+
"name": "_semicolon"
|
|
828
|
+
}
|
|
829
|
+
]
|
|
830
|
+
},
|
|
763
831
|
"variable_declarator": {
|
|
764
832
|
"type": "SEQ",
|
|
765
833
|
"members": [
|
|
@@ -773,6 +841,15 @@
|
|
|
773
841
|
"type": "SYMBOL",
|
|
774
842
|
"name": "identifier"
|
|
775
843
|
},
|
|
844
|
+
{
|
|
845
|
+
"type": "ALIAS",
|
|
846
|
+
"content": {
|
|
847
|
+
"type": "STRING",
|
|
848
|
+
"value": "of"
|
|
849
|
+
},
|
|
850
|
+
"named": true,
|
|
851
|
+
"value": "identifier"
|
|
852
|
+
},
|
|
776
853
|
{
|
|
777
854
|
"type": "SYMBOL",
|
|
778
855
|
"name": "_destructuring_pattern"
|
|
@@ -1108,6 +1185,15 @@
|
|
|
1108
1185
|
"type": "SYMBOL",
|
|
1109
1186
|
"name": "identifier"
|
|
1110
1187
|
},
|
|
1188
|
+
{
|
|
1189
|
+
"type": "ALIAS",
|
|
1190
|
+
"content": {
|
|
1191
|
+
"type": "STRING",
|
|
1192
|
+
"value": "of"
|
|
1193
|
+
},
|
|
1194
|
+
"named": true,
|
|
1195
|
+
"value": "identifier"
|
|
1196
|
+
},
|
|
1111
1197
|
{
|
|
1112
1198
|
"type": "SYMBOL",
|
|
1113
1199
|
"name": "_destructuring_pattern"
|
|
@@ -1159,6 +1245,84 @@
|
|
|
1159
1245
|
"type": "SYMBOL",
|
|
1160
1246
|
"name": "identifier"
|
|
1161
1247
|
},
|
|
1248
|
+
{
|
|
1249
|
+
"type": "ALIAS",
|
|
1250
|
+
"content": {
|
|
1251
|
+
"type": "STRING",
|
|
1252
|
+
"value": "of"
|
|
1253
|
+
},
|
|
1254
|
+
"named": true,
|
|
1255
|
+
"value": "identifier"
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
"type": "SYMBOL",
|
|
1259
|
+
"name": "_destructuring_pattern"
|
|
1260
|
+
}
|
|
1261
|
+
]
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
"type": "CHOICE",
|
|
1266
|
+
"members": [
|
|
1267
|
+
{
|
|
1268
|
+
"type": "SYMBOL",
|
|
1269
|
+
"name": "_automatic_semicolon"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
"type": "BLANK"
|
|
1273
|
+
}
|
|
1274
|
+
]
|
|
1275
|
+
}
|
|
1276
|
+
]
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"type": "SEQ",
|
|
1280
|
+
"members": [
|
|
1281
|
+
{
|
|
1282
|
+
"type": "FIELD",
|
|
1283
|
+
"name": "kind",
|
|
1284
|
+
"content": {
|
|
1285
|
+
"type": "CHOICE",
|
|
1286
|
+
"members": [
|
|
1287
|
+
{
|
|
1288
|
+
"type": "STRING",
|
|
1289
|
+
"value": "using"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"type": "SEQ",
|
|
1293
|
+
"members": [
|
|
1294
|
+
{
|
|
1295
|
+
"type": "STRING",
|
|
1296
|
+
"value": "await"
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
"type": "STRING",
|
|
1300
|
+
"value": "using"
|
|
1301
|
+
}
|
|
1302
|
+
]
|
|
1303
|
+
}
|
|
1304
|
+
]
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
"type": "FIELD",
|
|
1309
|
+
"name": "left",
|
|
1310
|
+
"content": {
|
|
1311
|
+
"type": "CHOICE",
|
|
1312
|
+
"members": [
|
|
1313
|
+
{
|
|
1314
|
+
"type": "SYMBOL",
|
|
1315
|
+
"name": "identifier"
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
"type": "ALIAS",
|
|
1319
|
+
"content": {
|
|
1320
|
+
"type": "STRING",
|
|
1321
|
+
"value": "of"
|
|
1322
|
+
},
|
|
1323
|
+
"named": true,
|
|
1324
|
+
"value": "identifier"
|
|
1325
|
+
},
|
|
1162
1326
|
{
|
|
1163
1327
|
"type": "SYMBOL",
|
|
1164
1328
|
"name": "_destructuring_pattern"
|
|
@@ -3581,13 +3745,17 @@
|
|
|
3581
3745
|
"name": "private_property_identifier"
|
|
3582
3746
|
},
|
|
3583
3747
|
{
|
|
3584
|
-
"type": "
|
|
3748
|
+
"type": "RESERVED",
|
|
3585
3749
|
"content": {
|
|
3586
|
-
"type": "
|
|
3587
|
-
"
|
|
3750
|
+
"type": "ALIAS",
|
|
3751
|
+
"content": {
|
|
3752
|
+
"type": "SYMBOL",
|
|
3753
|
+
"name": "identifier"
|
|
3754
|
+
},
|
|
3755
|
+
"named": true,
|
|
3756
|
+
"value": "property_identifier"
|
|
3588
3757
|
},
|
|
3589
|
-
"
|
|
3590
|
-
"value": "property_identifier"
|
|
3758
|
+
"context_name": "properties"
|
|
3591
3759
|
}
|
|
3592
3760
|
]
|
|
3593
3761
|
}
|
|
@@ -6512,43 +6680,47 @@
|
|
|
6512
6680
|
]
|
|
6513
6681
|
},
|
|
6514
6682
|
"_property_name": {
|
|
6515
|
-
"type": "
|
|
6516
|
-
"
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
"type": "
|
|
6521
|
-
"
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6683
|
+
"type": "RESERVED",
|
|
6684
|
+
"content": {
|
|
6685
|
+
"type": "CHOICE",
|
|
6686
|
+
"members": [
|
|
6687
|
+
{
|
|
6688
|
+
"type": "ALIAS",
|
|
6689
|
+
"content": {
|
|
6690
|
+
"type": "CHOICE",
|
|
6691
|
+
"members": [
|
|
6692
|
+
{
|
|
6693
|
+
"type": "SYMBOL",
|
|
6694
|
+
"name": "identifier"
|
|
6695
|
+
},
|
|
6696
|
+
{
|
|
6697
|
+
"type": "SYMBOL",
|
|
6698
|
+
"name": "_reserved_identifier"
|
|
6699
|
+
}
|
|
6700
|
+
]
|
|
6701
|
+
},
|
|
6702
|
+
"named": true,
|
|
6703
|
+
"value": "property_identifier"
|
|
6531
6704
|
},
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
]
|
|
6705
|
+
{
|
|
6706
|
+
"type": "SYMBOL",
|
|
6707
|
+
"name": "private_property_identifier"
|
|
6708
|
+
},
|
|
6709
|
+
{
|
|
6710
|
+
"type": "SYMBOL",
|
|
6711
|
+
"name": "string"
|
|
6712
|
+
},
|
|
6713
|
+
{
|
|
6714
|
+
"type": "SYMBOL",
|
|
6715
|
+
"name": "number"
|
|
6716
|
+
},
|
|
6717
|
+
{
|
|
6718
|
+
"type": "SYMBOL",
|
|
6719
|
+
"name": "computed_property_name"
|
|
6720
|
+
}
|
|
6721
|
+
]
|
|
6722
|
+
},
|
|
6723
|
+
"context_name": "properties"
|
|
6552
6724
|
},
|
|
6553
6725
|
"computed_property_name": {
|
|
6554
6726
|
"type": "SEQ",
|
|
@@ -6582,6 +6754,10 @@
|
|
|
6582
6754
|
"type": "STRING",
|
|
6583
6755
|
"value": "async"
|
|
6584
6756
|
},
|
|
6757
|
+
{
|
|
6758
|
+
"type": "STRING",
|
|
6759
|
+
"value": "await"
|
|
6760
|
+
},
|
|
6585
6761
|
{
|
|
6586
6762
|
"type": "STRING",
|
|
6587
6763
|
"value": "static"
|
|
@@ -6631,13 +6807,22 @@
|
|
|
6631
6807
|
],
|
|
6632
6808
|
[
|
|
6633
6809
|
"primary_expression",
|
|
6634
|
-
"
|
|
6635
|
-
|
|
6810
|
+
"await_expression"
|
|
6811
|
+
],
|
|
6812
|
+
[
|
|
6813
|
+
"primary_expression",
|
|
6814
|
+
"await_expression",
|
|
6815
|
+
"_property_name"
|
|
6636
6816
|
],
|
|
6637
6817
|
[
|
|
6638
6818
|
"primary_expression",
|
|
6639
6819
|
"arrow_function"
|
|
6640
6820
|
],
|
|
6821
|
+
[
|
|
6822
|
+
"primary_expression",
|
|
6823
|
+
"arrow_function",
|
|
6824
|
+
"_property_name"
|
|
6825
|
+
],
|
|
6641
6826
|
[
|
|
6642
6827
|
"primary_expression",
|
|
6643
6828
|
"method_definition"
|
|
@@ -6927,5 +7112,150 @@
|
|
|
6927
7112
|
"expression",
|
|
6928
7113
|
"primary_expression",
|
|
6929
7114
|
"pattern"
|
|
6930
|
-
]
|
|
6931
|
-
|
|
7115
|
+
],
|
|
7116
|
+
"reserved": {
|
|
7117
|
+
"global": [
|
|
7118
|
+
{
|
|
7119
|
+
"type": "STRING",
|
|
7120
|
+
"value": "break"
|
|
7121
|
+
},
|
|
7122
|
+
{
|
|
7123
|
+
"type": "STRING",
|
|
7124
|
+
"value": "case"
|
|
7125
|
+
},
|
|
7126
|
+
{
|
|
7127
|
+
"type": "STRING",
|
|
7128
|
+
"value": "catch"
|
|
7129
|
+
},
|
|
7130
|
+
{
|
|
7131
|
+
"type": "STRING",
|
|
7132
|
+
"value": "class"
|
|
7133
|
+
},
|
|
7134
|
+
{
|
|
7135
|
+
"type": "STRING",
|
|
7136
|
+
"value": "const"
|
|
7137
|
+
},
|
|
7138
|
+
{
|
|
7139
|
+
"type": "STRING",
|
|
7140
|
+
"value": "continue"
|
|
7141
|
+
},
|
|
7142
|
+
{
|
|
7143
|
+
"type": "STRING",
|
|
7144
|
+
"value": "debugger"
|
|
7145
|
+
},
|
|
7146
|
+
{
|
|
7147
|
+
"type": "STRING",
|
|
7148
|
+
"value": "default"
|
|
7149
|
+
},
|
|
7150
|
+
{
|
|
7151
|
+
"type": "STRING",
|
|
7152
|
+
"value": "delete"
|
|
7153
|
+
},
|
|
7154
|
+
{
|
|
7155
|
+
"type": "STRING",
|
|
7156
|
+
"value": "do"
|
|
7157
|
+
},
|
|
7158
|
+
{
|
|
7159
|
+
"type": "STRING",
|
|
7160
|
+
"value": "else"
|
|
7161
|
+
},
|
|
7162
|
+
{
|
|
7163
|
+
"type": "STRING",
|
|
7164
|
+
"value": "export"
|
|
7165
|
+
},
|
|
7166
|
+
{
|
|
7167
|
+
"type": "STRING",
|
|
7168
|
+
"value": "extends"
|
|
7169
|
+
},
|
|
7170
|
+
{
|
|
7171
|
+
"type": "STRING",
|
|
7172
|
+
"value": "false"
|
|
7173
|
+
},
|
|
7174
|
+
{
|
|
7175
|
+
"type": "STRING",
|
|
7176
|
+
"value": "finally"
|
|
7177
|
+
},
|
|
7178
|
+
{
|
|
7179
|
+
"type": "STRING",
|
|
7180
|
+
"value": "for"
|
|
7181
|
+
},
|
|
7182
|
+
{
|
|
7183
|
+
"type": "STRING",
|
|
7184
|
+
"value": "function"
|
|
7185
|
+
},
|
|
7186
|
+
{
|
|
7187
|
+
"type": "STRING",
|
|
7188
|
+
"value": "if"
|
|
7189
|
+
},
|
|
7190
|
+
{
|
|
7191
|
+
"type": "STRING",
|
|
7192
|
+
"value": "import"
|
|
7193
|
+
},
|
|
7194
|
+
{
|
|
7195
|
+
"type": "STRING",
|
|
7196
|
+
"value": "in"
|
|
7197
|
+
},
|
|
7198
|
+
{
|
|
7199
|
+
"type": "STRING",
|
|
7200
|
+
"value": "instanceof"
|
|
7201
|
+
},
|
|
7202
|
+
{
|
|
7203
|
+
"type": "STRING",
|
|
7204
|
+
"value": "new"
|
|
7205
|
+
},
|
|
7206
|
+
{
|
|
7207
|
+
"type": "STRING",
|
|
7208
|
+
"value": "null"
|
|
7209
|
+
},
|
|
7210
|
+
{
|
|
7211
|
+
"type": "STRING",
|
|
7212
|
+
"value": "return"
|
|
7213
|
+
},
|
|
7214
|
+
{
|
|
7215
|
+
"type": "STRING",
|
|
7216
|
+
"value": "super"
|
|
7217
|
+
},
|
|
7218
|
+
{
|
|
7219
|
+
"type": "STRING",
|
|
7220
|
+
"value": "switch"
|
|
7221
|
+
},
|
|
7222
|
+
{
|
|
7223
|
+
"type": "STRING",
|
|
7224
|
+
"value": "this"
|
|
7225
|
+
},
|
|
7226
|
+
{
|
|
7227
|
+
"type": "STRING",
|
|
7228
|
+
"value": "throw"
|
|
7229
|
+
},
|
|
7230
|
+
{
|
|
7231
|
+
"type": "STRING",
|
|
7232
|
+
"value": "true"
|
|
7233
|
+
},
|
|
7234
|
+
{
|
|
7235
|
+
"type": "STRING",
|
|
7236
|
+
"value": "try"
|
|
7237
|
+
},
|
|
7238
|
+
{
|
|
7239
|
+
"type": "STRING",
|
|
7240
|
+
"value": "typeof"
|
|
7241
|
+
},
|
|
7242
|
+
{
|
|
7243
|
+
"type": "STRING",
|
|
7244
|
+
"value": "var"
|
|
7245
|
+
},
|
|
7246
|
+
{
|
|
7247
|
+
"type": "STRING",
|
|
7248
|
+
"value": "void"
|
|
7249
|
+
},
|
|
7250
|
+
{
|
|
7251
|
+
"type": "STRING",
|
|
7252
|
+
"value": "while"
|
|
7253
|
+
},
|
|
7254
|
+
{
|
|
7255
|
+
"type": "STRING",
|
|
7256
|
+
"value": "with"
|
|
7257
|
+
}
|
|
7258
|
+
],
|
|
7259
|
+
"properties": []
|
|
7260
|
+
}
|
|
7261
|
+
}
|