@ast-grep/lang-go 0.0.2 → 0.0.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/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 +298 -123
- package/src/node-types.json +37 -11
- package/src/parser.c +22081 -21129
- package/src/tree_sitter/array.h +2 -1
- package/src/tree_sitter/parser.h +27 -7
- package/type.d.ts +37 -11
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: ['go'],
|
|
7
29
|
languageSymbol: 'tree_sitter_go',
|
|
8
30
|
expandoChar: 'µ',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ast-grep/lang-go",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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-go": "0.
|
|
34
|
-
"tree-sitter-cli": "0.25.
|
|
32
|
+
"@ast-grep/nursery": "0.0.8",
|
|
33
|
+
"tree-sitter-go": "0.25.0",
|
|
34
|
+
"tree-sitter-cli": "0.25.8"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -943,62 +943,58 @@
|
|
|
943
943
|
]
|
|
944
944
|
},
|
|
945
945
|
"parameter_declaration": {
|
|
946
|
-
"type": "
|
|
947
|
-
"
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
{
|
|
958
|
-
"type": "
|
|
959
|
-
"name": "
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
"
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
{
|
|
975
|
-
"type": "
|
|
976
|
-
"name": "
|
|
977
|
-
"content": {
|
|
978
|
-
"type": "SYMBOL",
|
|
979
|
-
"name": "identifier"
|
|
980
|
-
}
|
|
946
|
+
"type": "SEQ",
|
|
947
|
+
"members": [
|
|
948
|
+
{
|
|
949
|
+
"type": "CHOICE",
|
|
950
|
+
"members": [
|
|
951
|
+
{
|
|
952
|
+
"type": "SEQ",
|
|
953
|
+
"members": [
|
|
954
|
+
{
|
|
955
|
+
"type": "FIELD",
|
|
956
|
+
"name": "name",
|
|
957
|
+
"content": {
|
|
958
|
+
"type": "SYMBOL",
|
|
959
|
+
"name": "identifier"
|
|
960
|
+
}
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"type": "REPEAT",
|
|
964
|
+
"content": {
|
|
965
|
+
"type": "SEQ",
|
|
966
|
+
"members": [
|
|
967
|
+
{
|
|
968
|
+
"type": "STRING",
|
|
969
|
+
"value": ","
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"type": "FIELD",
|
|
973
|
+
"name": "name",
|
|
974
|
+
"content": {
|
|
975
|
+
"type": "SYMBOL",
|
|
976
|
+
"name": "identifier"
|
|
981
977
|
}
|
|
982
|
-
|
|
983
|
-
|
|
978
|
+
}
|
|
979
|
+
]
|
|
984
980
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
]
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
"type": "FIELD",
|
|
994
|
-
"name": "type",
|
|
995
|
-
"content": {
|
|
996
|
-
"type": "SYMBOL",
|
|
997
|
-
"name": "_type"
|
|
981
|
+
}
|
|
982
|
+
]
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"type": "BLANK"
|
|
998
986
|
}
|
|
987
|
+
]
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
"type": "FIELD",
|
|
991
|
+
"name": "type",
|
|
992
|
+
"content": {
|
|
993
|
+
"type": "SYMBOL",
|
|
994
|
+
"name": "_type"
|
|
999
995
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
996
|
+
}
|
|
997
|
+
]
|
|
1002
998
|
},
|
|
1003
999
|
"variadic_parameter_declaration": {
|
|
1004
1000
|
"type": "SEQ",
|
|
@@ -1044,6 +1040,22 @@
|
|
|
1044
1040
|
"name": "_type_identifier"
|
|
1045
1041
|
}
|
|
1046
1042
|
},
|
|
1043
|
+
{
|
|
1044
|
+
"type": "FIELD",
|
|
1045
|
+
"name": "type_parameters",
|
|
1046
|
+
"content": {
|
|
1047
|
+
"type": "CHOICE",
|
|
1048
|
+
"members": [
|
|
1049
|
+
{
|
|
1050
|
+
"type": "SYMBOL",
|
|
1051
|
+
"name": "type_parameter_list"
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"type": "BLANK"
|
|
1055
|
+
}
|
|
1056
|
+
]
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1047
1059
|
{
|
|
1048
1060
|
"type": "STRING",
|
|
1049
1061
|
"value": "="
|
|
@@ -1084,42 +1096,93 @@
|
|
|
1084
1096
|
"value": "("
|
|
1085
1097
|
},
|
|
1086
1098
|
{
|
|
1087
|
-
"type": "
|
|
1088
|
-
"
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
{
|
|
1108
|
-
"type": "
|
|
1109
|
-
"
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1099
|
+
"type": "CHOICE",
|
|
1100
|
+
"members": [
|
|
1101
|
+
{
|
|
1102
|
+
"type": "SEQ",
|
|
1103
|
+
"members": [
|
|
1104
|
+
{
|
|
1105
|
+
"type": "CHOICE",
|
|
1106
|
+
"members": [
|
|
1107
|
+
{
|
|
1108
|
+
"type": "SYMBOL",
|
|
1109
|
+
"name": "type_spec"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"type": "SYMBOL",
|
|
1113
|
+
"name": "type_alias"
|
|
1114
|
+
}
|
|
1115
|
+
]
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
"type": "REPEAT",
|
|
1119
|
+
"content": {
|
|
1120
|
+
"type": "SEQ",
|
|
1121
|
+
"members": [
|
|
1122
|
+
{
|
|
1123
|
+
"type": "CHOICE",
|
|
1124
|
+
"members": [
|
|
1125
|
+
{
|
|
1126
|
+
"type": "PATTERN",
|
|
1127
|
+
"value": "\\n"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"type": "STRING",
|
|
1131
|
+
"value": ";"
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
"type": "STRING",
|
|
1135
|
+
"value": "\u0000"
|
|
1136
|
+
}
|
|
1137
|
+
]
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
"type": "CHOICE",
|
|
1141
|
+
"members": [
|
|
1142
|
+
{
|
|
1143
|
+
"type": "SYMBOL",
|
|
1144
|
+
"name": "type_spec"
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"type": "SYMBOL",
|
|
1148
|
+
"name": "type_alias"
|
|
1149
|
+
}
|
|
1150
|
+
]
|
|
1151
|
+
}
|
|
1152
|
+
]
|
|
1118
1153
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
"type": "CHOICE",
|
|
1157
|
+
"members": [
|
|
1158
|
+
{
|
|
1159
|
+
"type": "CHOICE",
|
|
1160
|
+
"members": [
|
|
1161
|
+
{
|
|
1162
|
+
"type": "PATTERN",
|
|
1163
|
+
"value": "\\n"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
"type": "STRING",
|
|
1167
|
+
"value": ";"
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
"type": "STRING",
|
|
1171
|
+
"value": "\u0000"
|
|
1172
|
+
}
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"type": "BLANK"
|
|
1177
|
+
}
|
|
1178
|
+
]
|
|
1179
|
+
}
|
|
1180
|
+
]
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
"type": "BLANK"
|
|
1184
|
+
}
|
|
1185
|
+
]
|
|
1123
1186
|
},
|
|
1124
1187
|
{
|
|
1125
1188
|
"type": "STRING",
|
|
@@ -1288,8 +1351,12 @@
|
|
|
1288
1351
|
"name": "slice_type"
|
|
1289
1352
|
},
|
|
1290
1353
|
{
|
|
1291
|
-
"type": "
|
|
1292
|
-
"
|
|
1354
|
+
"type": "PREC_DYNAMIC",
|
|
1355
|
+
"value": 3,
|
|
1356
|
+
"content": {
|
|
1357
|
+
"type": "SYMBOL",
|
|
1358
|
+
"name": "map_type"
|
|
1359
|
+
}
|
|
1293
1360
|
},
|
|
1294
1361
|
{
|
|
1295
1362
|
"type": "SYMBOL",
|
|
@@ -2060,7 +2127,7 @@
|
|
|
2060
2127
|
"members": [
|
|
2061
2128
|
{
|
|
2062
2129
|
"type": "SYMBOL",
|
|
2063
|
-
"name": "
|
|
2130
|
+
"name": "statement_list"
|
|
2064
2131
|
},
|
|
2065
2132
|
{
|
|
2066
2133
|
"type": "BLANK"
|
|
@@ -2073,7 +2140,7 @@
|
|
|
2073
2140
|
}
|
|
2074
2141
|
]
|
|
2075
2142
|
},
|
|
2076
|
-
"
|
|
2143
|
+
"statement_list": {
|
|
2077
2144
|
"type": "CHOICE",
|
|
2078
2145
|
"members": [
|
|
2079
2146
|
{
|
|
@@ -2992,7 +3059,7 @@
|
|
|
2992
3059
|
"members": [
|
|
2993
3060
|
{
|
|
2994
3061
|
"type": "SYMBOL",
|
|
2995
|
-
"name": "
|
|
3062
|
+
"name": "statement_list"
|
|
2996
3063
|
},
|
|
2997
3064
|
{
|
|
2998
3065
|
"type": "BLANK"
|
|
@@ -3017,7 +3084,7 @@
|
|
|
3017
3084
|
"members": [
|
|
3018
3085
|
{
|
|
3019
3086
|
"type": "SYMBOL",
|
|
3020
|
-
"name": "
|
|
3087
|
+
"name": "statement_list"
|
|
3021
3088
|
},
|
|
3022
3089
|
{
|
|
3023
3090
|
"type": "BLANK"
|
|
@@ -3187,7 +3254,7 @@
|
|
|
3187
3254
|
"members": [
|
|
3188
3255
|
{
|
|
3189
3256
|
"type": "SYMBOL",
|
|
3190
|
-
"name": "
|
|
3257
|
+
"name": "statement_list"
|
|
3191
3258
|
},
|
|
3192
3259
|
{
|
|
3193
3260
|
"type": "BLANK"
|
|
@@ -3262,7 +3329,7 @@
|
|
|
3262
3329
|
"members": [
|
|
3263
3330
|
{
|
|
3264
3331
|
"type": "SYMBOL",
|
|
3265
|
-
"name": "
|
|
3332
|
+
"name": "statement_list"
|
|
3266
3333
|
},
|
|
3267
3334
|
{
|
|
3268
3335
|
"type": "BLANK"
|
|
@@ -3669,33 +3736,37 @@
|
|
|
3669
3736
|
"type": "PREC",
|
|
3670
3737
|
"value": 7,
|
|
3671
3738
|
"content": {
|
|
3672
|
-
"type": "
|
|
3673
|
-
"
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
"type": "
|
|
3679
|
-
"name": "
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
"type": "
|
|
3691
|
-
"name": "
|
|
3739
|
+
"type": "PREC_DYNAMIC",
|
|
3740
|
+
"value": 1,
|
|
3741
|
+
"content": {
|
|
3742
|
+
"type": "SEQ",
|
|
3743
|
+
"members": [
|
|
3744
|
+
{
|
|
3745
|
+
"type": "FIELD",
|
|
3746
|
+
"name": "operand",
|
|
3747
|
+
"content": {
|
|
3748
|
+
"type": "SYMBOL",
|
|
3749
|
+
"name": "_expression"
|
|
3750
|
+
}
|
|
3751
|
+
},
|
|
3752
|
+
{
|
|
3753
|
+
"type": "STRING",
|
|
3754
|
+
"value": "["
|
|
3755
|
+
},
|
|
3756
|
+
{
|
|
3757
|
+
"type": "FIELD",
|
|
3758
|
+
"name": "index",
|
|
3759
|
+
"content": {
|
|
3760
|
+
"type": "SYMBOL",
|
|
3761
|
+
"name": "_expression"
|
|
3762
|
+
}
|
|
3763
|
+
},
|
|
3764
|
+
{
|
|
3765
|
+
"type": "STRING",
|
|
3766
|
+
"value": "]"
|
|
3692
3767
|
}
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
"type": "STRING",
|
|
3696
|
-
"value": "]"
|
|
3697
|
-
}
|
|
3698
|
-
]
|
|
3768
|
+
]
|
|
3769
|
+
}
|
|
3699
3770
|
}
|
|
3700
3771
|
},
|
|
3701
3772
|
"slice_expression": {
|
|
@@ -6994,5 +7065,109 @@
|
|
|
6994
7065
|
"_simple_type",
|
|
6995
7066
|
"_statement",
|
|
6996
7067
|
"_simple_statement"
|
|
6997
|
-
]
|
|
6998
|
-
|
|
7068
|
+
],
|
|
7069
|
+
"reserved": {
|
|
7070
|
+
"global": [
|
|
7071
|
+
{
|
|
7072
|
+
"type": "STRING",
|
|
7073
|
+
"value": "break"
|
|
7074
|
+
},
|
|
7075
|
+
{
|
|
7076
|
+
"type": "STRING",
|
|
7077
|
+
"value": "default"
|
|
7078
|
+
},
|
|
7079
|
+
{
|
|
7080
|
+
"type": "STRING",
|
|
7081
|
+
"value": "func"
|
|
7082
|
+
},
|
|
7083
|
+
{
|
|
7084
|
+
"type": "STRING",
|
|
7085
|
+
"value": "interface"
|
|
7086
|
+
},
|
|
7087
|
+
{
|
|
7088
|
+
"type": "STRING",
|
|
7089
|
+
"value": "select"
|
|
7090
|
+
},
|
|
7091
|
+
{
|
|
7092
|
+
"type": "STRING",
|
|
7093
|
+
"value": "case"
|
|
7094
|
+
},
|
|
7095
|
+
{
|
|
7096
|
+
"type": "STRING",
|
|
7097
|
+
"value": "defer"
|
|
7098
|
+
},
|
|
7099
|
+
{
|
|
7100
|
+
"type": "STRING",
|
|
7101
|
+
"value": "go"
|
|
7102
|
+
},
|
|
7103
|
+
{
|
|
7104
|
+
"type": "STRING",
|
|
7105
|
+
"value": "map"
|
|
7106
|
+
},
|
|
7107
|
+
{
|
|
7108
|
+
"type": "STRING",
|
|
7109
|
+
"value": "struct"
|
|
7110
|
+
},
|
|
7111
|
+
{
|
|
7112
|
+
"type": "STRING",
|
|
7113
|
+
"value": "chan"
|
|
7114
|
+
},
|
|
7115
|
+
{
|
|
7116
|
+
"type": "STRING",
|
|
7117
|
+
"value": "else"
|
|
7118
|
+
},
|
|
7119
|
+
{
|
|
7120
|
+
"type": "STRING",
|
|
7121
|
+
"value": "goto"
|
|
7122
|
+
},
|
|
7123
|
+
{
|
|
7124
|
+
"type": "STRING",
|
|
7125
|
+
"value": "package"
|
|
7126
|
+
},
|
|
7127
|
+
{
|
|
7128
|
+
"type": "STRING",
|
|
7129
|
+
"value": "switch"
|
|
7130
|
+
},
|
|
7131
|
+
{
|
|
7132
|
+
"type": "STRING",
|
|
7133
|
+
"value": "const"
|
|
7134
|
+
},
|
|
7135
|
+
{
|
|
7136
|
+
"type": "STRING",
|
|
7137
|
+
"value": "fallthrough"
|
|
7138
|
+
},
|
|
7139
|
+
{
|
|
7140
|
+
"type": "STRING",
|
|
7141
|
+
"value": "if"
|
|
7142
|
+
},
|
|
7143
|
+
{
|
|
7144
|
+
"type": "STRING",
|
|
7145
|
+
"value": "range"
|
|
7146
|
+
},
|
|
7147
|
+
{
|
|
7148
|
+
"type": "STRING",
|
|
7149
|
+
"value": "type"
|
|
7150
|
+
},
|
|
7151
|
+
{
|
|
7152
|
+
"type": "STRING",
|
|
7153
|
+
"value": "continue"
|
|
7154
|
+
},
|
|
7155
|
+
{
|
|
7156
|
+
"type": "STRING",
|
|
7157
|
+
"value": "for"
|
|
7158
|
+
},
|
|
7159
|
+
{
|
|
7160
|
+
"type": "STRING",
|
|
7161
|
+
"value": "import"
|
|
7162
|
+
},
|
|
7163
|
+
{
|
|
7164
|
+
"type": "STRING",
|
|
7165
|
+
"value": "return"
|
|
7166
|
+
},
|
|
7167
|
+
{
|
|
7168
|
+
"type": "STRING",
|
|
7169
|
+
"value": "var"
|
|
7170
|
+
}
|
|
7171
|
+
]
|
|
7172
|
+
}
|
|
7173
|
+
}
|