@konomanoasa/tree-sitter-query 0.2.0 → 0.3.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/Cargo.toml +1 -1
- package/README.md +5 -1
- package/grammar.js +46 -48
- package/package.json +7 -6
- package/src/grammar.json +239 -183
- package/src/node-types.json +1 -1
- package/src/parser.c +1887 -1762
- package/test/bindings.test.rs +150 -265
- package/tree-sitter.json +1 -1
package/src/grammar.json
CHANGED
|
@@ -3,35 +3,48 @@
|
|
|
3
3
|
"name": "query",
|
|
4
4
|
"rules": {
|
|
5
5
|
"query": {
|
|
6
|
-
"type": "REPEAT",
|
|
7
|
-
"content": {
|
|
8
|
-
"type": "SYMBOL",
|
|
9
|
-
"name": "_member"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"_member": {
|
|
13
6
|
"type": "CHOICE",
|
|
14
7
|
"members": [
|
|
15
8
|
{
|
|
16
9
|
"type": "SYMBOL",
|
|
17
|
-
"name": "
|
|
10
|
+
"name": "_members"
|
|
18
11
|
},
|
|
12
|
+
{
|
|
13
|
+
"type": "BLANK"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"_members": {
|
|
18
|
+
"type": "SEQ",
|
|
19
|
+
"members": [
|
|
19
20
|
{
|
|
20
21
|
"type": "SYMBOL",
|
|
21
|
-
"name": "
|
|
22
|
+
"name": "_member"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "CHOICE",
|
|
26
|
+
"members": [
|
|
27
|
+
{
|
|
28
|
+
"type": "SYMBOL",
|
|
29
|
+
"name": "_members"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "BLANK"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
22
35
|
}
|
|
23
36
|
]
|
|
24
37
|
},
|
|
25
|
-
"
|
|
38
|
+
"_member": {
|
|
26
39
|
"type": "CHOICE",
|
|
27
40
|
"members": [
|
|
28
41
|
{
|
|
29
42
|
"type": "SYMBOL",
|
|
30
|
-
"name": "
|
|
43
|
+
"name": "_matching_child_pattern"
|
|
31
44
|
},
|
|
32
45
|
{
|
|
33
46
|
"type": "SYMBOL",
|
|
34
|
-
"name": "
|
|
47
|
+
"name": "_call_only_member"
|
|
35
48
|
}
|
|
36
49
|
]
|
|
37
50
|
},
|
|
@@ -48,6 +61,19 @@
|
|
|
48
61
|
}
|
|
49
62
|
]
|
|
50
63
|
},
|
|
64
|
+
"_call_only_member": {
|
|
65
|
+
"type": "CHOICE",
|
|
66
|
+
"members": [
|
|
67
|
+
{
|
|
68
|
+
"type": "SYMBOL",
|
|
69
|
+
"name": "_call_only_child_pattern"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "SYMBOL",
|
|
73
|
+
"name": "_call"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
51
77
|
"pattern": {
|
|
52
78
|
"type": "SEQ",
|
|
53
79
|
"members": [
|
|
@@ -154,66 +180,56 @@
|
|
|
154
180
|
}
|
|
155
181
|
]
|
|
156
182
|
},
|
|
157
|
-
"
|
|
158
|
-
"type": "
|
|
183
|
+
"_delimited": {
|
|
184
|
+
"type": "CHOICE",
|
|
159
185
|
"members": [
|
|
160
186
|
{
|
|
161
|
-
"type": "
|
|
162
|
-
"name": "
|
|
163
|
-
"content": {
|
|
164
|
-
"type": "CHOICE",
|
|
165
|
-
"members": [
|
|
166
|
-
{
|
|
167
|
-
"type": "SYMBOL",
|
|
168
|
-
"name": "_delimited"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"type": "SYMBOL",
|
|
172
|
-
"name": "string"
|
|
173
|
-
}
|
|
174
|
-
]
|
|
175
|
-
}
|
|
187
|
+
"type": "SYMBOL",
|
|
188
|
+
"name": "node_pattern"
|
|
176
189
|
},
|
|
177
190
|
{
|
|
178
|
-
"type": "
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"name": "capture",
|
|
185
|
-
"content": {
|
|
186
|
-
"type": "SYMBOL",
|
|
187
|
-
"name": "capture"
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"type": "FIELD",
|
|
192
|
-
"name": "quantifier",
|
|
193
|
-
"content": {
|
|
194
|
-
"type": "SYMBOL",
|
|
195
|
-
"name": "quantifier"
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
}
|
|
191
|
+
"type": "SYMBOL",
|
|
192
|
+
"name": "group"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"type": "SYMBOL",
|
|
196
|
+
"name": "alternation"
|
|
200
197
|
}
|
|
201
198
|
]
|
|
202
199
|
},
|
|
203
|
-
"
|
|
200
|
+
"_matching_child_pattern": {
|
|
204
201
|
"type": "CHOICE",
|
|
205
202
|
"members": [
|
|
206
203
|
{
|
|
207
204
|
"type": "SYMBOL",
|
|
208
|
-
"name": "
|
|
205
|
+
"name": "pattern"
|
|
209
206
|
},
|
|
210
207
|
{
|
|
211
208
|
"type": "SYMBOL",
|
|
212
|
-
"name": "
|
|
209
|
+
"name": "field_constraint"
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
"_call_only_child_pattern": {
|
|
214
|
+
"type": "CHOICE",
|
|
215
|
+
"members": [
|
|
216
|
+
{
|
|
217
|
+
"type": "ALIAS",
|
|
218
|
+
"content": {
|
|
219
|
+
"type": "SYMBOL",
|
|
220
|
+
"name": "_call_only_pattern"
|
|
221
|
+
},
|
|
222
|
+
"named": true,
|
|
223
|
+
"value": "pattern"
|
|
213
224
|
},
|
|
214
225
|
{
|
|
215
|
-
"type": "
|
|
216
|
-
"
|
|
226
|
+
"type": "ALIAS",
|
|
227
|
+
"content": {
|
|
228
|
+
"type": "SYMBOL",
|
|
229
|
+
"name": "_call_only_field_constraint"
|
|
230
|
+
},
|
|
231
|
+
"named": true,
|
|
232
|
+
"value": "field_constraint"
|
|
217
233
|
}
|
|
218
234
|
]
|
|
219
235
|
},
|
|
@@ -272,7 +288,7 @@
|
|
|
272
288
|
"type": "REPEAT",
|
|
273
289
|
"content": {
|
|
274
290
|
"type": "SYMBOL",
|
|
275
|
-
"name": "
|
|
291
|
+
"name": "_non_matching_child"
|
|
276
292
|
}
|
|
277
293
|
},
|
|
278
294
|
{
|
|
@@ -309,7 +325,7 @@
|
|
|
309
325
|
"members": [
|
|
310
326
|
{
|
|
311
327
|
"type": "SYMBOL",
|
|
312
|
-
"name": "
|
|
328
|
+
"name": "_non_matching_child"
|
|
313
329
|
},
|
|
314
330
|
{
|
|
315
331
|
"type": "SEQ",
|
|
@@ -364,56 +380,7 @@
|
|
|
364
380
|
}
|
|
365
381
|
]
|
|
366
382
|
},
|
|
367
|
-
"
|
|
368
|
-
"type": "CHOICE",
|
|
369
|
-
"members": [
|
|
370
|
-
{
|
|
371
|
-
"type": "SYMBOL",
|
|
372
|
-
"name": "_matching_child_pattern"
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
"type": "SYMBOL",
|
|
376
|
-
"name": "_call_only_child_pattern"
|
|
377
|
-
}
|
|
378
|
-
]
|
|
379
|
-
},
|
|
380
|
-
"_matching_child_pattern": {
|
|
381
|
-
"type": "CHOICE",
|
|
382
|
-
"members": [
|
|
383
|
-
{
|
|
384
|
-
"type": "SYMBOL",
|
|
385
|
-
"name": "pattern"
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
"type": "SYMBOL",
|
|
389
|
-
"name": "field_constraint"
|
|
390
|
-
}
|
|
391
|
-
]
|
|
392
|
-
},
|
|
393
|
-
"_call_only_child_pattern": {
|
|
394
|
-
"type": "CHOICE",
|
|
395
|
-
"members": [
|
|
396
|
-
{
|
|
397
|
-
"type": "ALIAS",
|
|
398
|
-
"content": {
|
|
399
|
-
"type": "SYMBOL",
|
|
400
|
-
"name": "_call_only_pattern"
|
|
401
|
-
},
|
|
402
|
-
"named": true,
|
|
403
|
-
"value": "pattern"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
"type": "ALIAS",
|
|
407
|
-
"content": {
|
|
408
|
-
"type": "SYMBOL",
|
|
409
|
-
"name": "_call_only_field_constraint"
|
|
410
|
-
},
|
|
411
|
-
"named": true,
|
|
412
|
-
"value": "field_constraint"
|
|
413
|
-
}
|
|
414
|
-
]
|
|
415
|
-
},
|
|
416
|
-
"_node_annotation": {
|
|
383
|
+
"_non_matching_child": {
|
|
417
384
|
"type": "CHOICE",
|
|
418
385
|
"members": [
|
|
419
386
|
{
|
|
@@ -709,7 +676,7 @@
|
|
|
709
676
|
"type": "ALIAS",
|
|
710
677
|
"content": {
|
|
711
678
|
"type": "SYMBOL",
|
|
712
|
-
"name": "
|
|
679
|
+
"name": "_group_start_pattern"
|
|
713
680
|
},
|
|
714
681
|
"named": true,
|
|
715
682
|
"value": "pattern"
|
|
@@ -718,32 +685,37 @@
|
|
|
718
685
|
"type": "SEQ",
|
|
719
686
|
"members": [
|
|
720
687
|
{
|
|
721
|
-
"type": "
|
|
722
|
-
"
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
{
|
|
730
|
-
"type": "
|
|
688
|
+
"type": "SEQ",
|
|
689
|
+
"members": [
|
|
690
|
+
{
|
|
691
|
+
"type": "SYMBOL",
|
|
692
|
+
"name": "_call_only_group_start"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"type": "REPEAT",
|
|
696
|
+
"content": {
|
|
697
|
+
"type": "SEQ",
|
|
731
698
|
"members": [
|
|
732
699
|
{
|
|
733
|
-
"type": "
|
|
734
|
-
"
|
|
700
|
+
"type": "CHOICE",
|
|
701
|
+
"members": [
|
|
702
|
+
{
|
|
703
|
+
"type": "SYMBOL",
|
|
704
|
+
"name": "anchor"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"type": "BLANK"
|
|
708
|
+
}
|
|
709
|
+
]
|
|
735
710
|
},
|
|
736
711
|
{
|
|
737
|
-
"type": "
|
|
712
|
+
"type": "SYMBOL",
|
|
713
|
+
"name": "_call_only_member"
|
|
738
714
|
}
|
|
739
715
|
]
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
"type": "SYMBOL",
|
|
743
|
-
"name": "_call_only_member"
|
|
744
716
|
}
|
|
745
|
-
|
|
746
|
-
|
|
717
|
+
}
|
|
718
|
+
]
|
|
747
719
|
},
|
|
748
720
|
{
|
|
749
721
|
"type": "SEQ",
|
|
@@ -800,40 +772,91 @@
|
|
|
800
772
|
}
|
|
801
773
|
]
|
|
802
774
|
},
|
|
803
|
-
"
|
|
775
|
+
"_group_start_pattern": {
|
|
804
776
|
"type": "SEQ",
|
|
805
777
|
"members": [
|
|
806
778
|
{
|
|
807
|
-
"type": "
|
|
808
|
-
"
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
779
|
+
"type": "FIELD",
|
|
780
|
+
"name": "body",
|
|
781
|
+
"content": {
|
|
782
|
+
"type": "CHOICE",
|
|
783
|
+
"members": [
|
|
784
|
+
{
|
|
785
|
+
"type": "SYMBOL",
|
|
786
|
+
"name": "_delimited"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"type": "SYMBOL",
|
|
790
|
+
"name": "string"
|
|
791
|
+
}
|
|
792
|
+
]
|
|
793
|
+
}
|
|
813
794
|
},
|
|
814
795
|
{
|
|
815
796
|
"type": "REPEAT",
|
|
816
797
|
"content": {
|
|
817
|
-
"type": "
|
|
798
|
+
"type": "CHOICE",
|
|
818
799
|
"members": [
|
|
819
800
|
{
|
|
820
|
-
"type": "
|
|
801
|
+
"type": "FIELD",
|
|
802
|
+
"name": "capture",
|
|
803
|
+
"content": {
|
|
804
|
+
"type": "SYMBOL",
|
|
805
|
+
"name": "capture"
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"type": "FIELD",
|
|
810
|
+
"name": "quantifier",
|
|
811
|
+
"content": {
|
|
812
|
+
"type": "SYMBOL",
|
|
813
|
+
"name": "quantifier"
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
]
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
]
|
|
820
|
+
},
|
|
821
|
+
"_call_only_group": {
|
|
822
|
+
"type": "SEQ",
|
|
823
|
+
"members": [
|
|
824
|
+
{
|
|
825
|
+
"type": "STRING",
|
|
826
|
+
"value": "("
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
"type": "SEQ",
|
|
830
|
+
"members": [
|
|
831
|
+
{
|
|
832
|
+
"type": "SYMBOL",
|
|
833
|
+
"name": "_call_only_group_start"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
"type": "REPEAT",
|
|
837
|
+
"content": {
|
|
838
|
+
"type": "SEQ",
|
|
821
839
|
"members": [
|
|
822
840
|
{
|
|
823
|
-
"type": "
|
|
824
|
-
"
|
|
841
|
+
"type": "CHOICE",
|
|
842
|
+
"members": [
|
|
843
|
+
{
|
|
844
|
+
"type": "SYMBOL",
|
|
845
|
+
"name": "anchor"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"type": "BLANK"
|
|
849
|
+
}
|
|
850
|
+
]
|
|
825
851
|
},
|
|
826
852
|
{
|
|
827
|
-
"type": "
|
|
853
|
+
"type": "SYMBOL",
|
|
854
|
+
"name": "_call_only_member"
|
|
828
855
|
}
|
|
829
856
|
]
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
"type": "SYMBOL",
|
|
833
|
-
"name": "_call_only_member"
|
|
834
857
|
}
|
|
835
|
-
|
|
836
|
-
|
|
858
|
+
}
|
|
859
|
+
]
|
|
837
860
|
},
|
|
838
861
|
{
|
|
839
862
|
"type": "STRING",
|
|
@@ -934,6 +957,10 @@
|
|
|
934
957
|
"type": "STRING",
|
|
935
958
|
"value": "."
|
|
936
959
|
},
|
|
960
|
+
"wildcard": {
|
|
961
|
+
"type": "STRING",
|
|
962
|
+
"value": "_"
|
|
963
|
+
},
|
|
937
964
|
"capture": {
|
|
938
965
|
"type": "SEQ",
|
|
939
966
|
"members": [
|
|
@@ -1120,10 +1147,6 @@
|
|
|
1120
1147
|
}
|
|
1121
1148
|
]
|
|
1122
1149
|
},
|
|
1123
|
-
"wildcard": {
|
|
1124
|
-
"type": "STRING",
|
|
1125
|
-
"value": "_"
|
|
1126
|
-
},
|
|
1127
1150
|
"string": {
|
|
1128
1151
|
"type": "SEQ",
|
|
1129
1152
|
"members": [
|
|
@@ -1173,14 +1196,55 @@
|
|
|
1173
1196
|
}
|
|
1174
1197
|
},
|
|
1175
1198
|
{
|
|
1176
|
-
"type": "
|
|
1177
|
-
"
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1199
|
+
"type": "CHOICE",
|
|
1200
|
+
"members": [
|
|
1201
|
+
{
|
|
1202
|
+
"type": "IMMEDIATE_TOKEN",
|
|
1203
|
+
"content": {
|
|
1204
|
+
"type": "STRING",
|
|
1205
|
+
"value": "\""
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
"type": "SEQ",
|
|
1210
|
+
"members": [
|
|
1211
|
+
{
|
|
1212
|
+
"type": "SYMBOL",
|
|
1213
|
+
"name": "_string_line_break"
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
"type": "SYMBOL",
|
|
1217
|
+
"name": "_unmatchable"
|
|
1218
|
+
}
|
|
1219
|
+
]
|
|
1220
|
+
}
|
|
1221
|
+
]
|
|
1181
1222
|
}
|
|
1182
1223
|
]
|
|
1183
1224
|
},
|
|
1225
|
+
"_string_line_break": {
|
|
1226
|
+
"type": "IMMEDIATE_TOKEN",
|
|
1227
|
+
"content": {
|
|
1228
|
+
"type": "PATTERN",
|
|
1229
|
+
"value": "\\n"
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
"_unmatchable": {
|
|
1233
|
+
"type": "TOKEN",
|
|
1234
|
+
"content": {
|
|
1235
|
+
"type": "SEQ",
|
|
1236
|
+
"members": [
|
|
1237
|
+
{
|
|
1238
|
+
"type": "STRING",
|
|
1239
|
+
"value": "\\"
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
"type": "PATTERN",
|
|
1243
|
+
"value": "[^\\s\\S]"
|
|
1244
|
+
}
|
|
1245
|
+
]
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1184
1248
|
"string_content": {
|
|
1185
1249
|
"type": "IMMEDIATE_TOKEN",
|
|
1186
1250
|
"content": {
|
|
@@ -1196,25 +1260,8 @@
|
|
|
1196
1260
|
"value": "[^\"\\\\\\n]+"
|
|
1197
1261
|
},
|
|
1198
1262
|
{
|
|
1199
|
-
"type": "
|
|
1200
|
-
"
|
|
1201
|
-
{
|
|
1202
|
-
"type": "STRING",
|
|
1203
|
-
"value": "\u0000"
|
|
1204
|
-
},
|
|
1205
|
-
{
|
|
1206
|
-
"type": "CHOICE",
|
|
1207
|
-
"members": [
|
|
1208
|
-
{
|
|
1209
|
-
"type": "PATTERN",
|
|
1210
|
-
"value": "[^\"\\\\\\n]+"
|
|
1211
|
-
},
|
|
1212
|
-
{
|
|
1213
|
-
"type": "BLANK"
|
|
1214
|
-
}
|
|
1215
|
-
]
|
|
1216
|
-
}
|
|
1217
|
-
]
|
|
1263
|
+
"type": "STRING",
|
|
1264
|
+
"value": "\u0000"
|
|
1218
1265
|
}
|
|
1219
1266
|
]
|
|
1220
1267
|
}
|
|
@@ -1224,19 +1271,28 @@
|
|
|
1224
1271
|
"escape_sequence": {
|
|
1225
1272
|
"type": "IMMEDIATE_TOKEN",
|
|
1226
1273
|
"content": {
|
|
1227
|
-
"type": "
|
|
1274
|
+
"type": "SEQ",
|
|
1228
1275
|
"members": [
|
|
1229
1276
|
{
|
|
1230
|
-
"type": "
|
|
1231
|
-
"value": "
|
|
1277
|
+
"type": "STRING",
|
|
1278
|
+
"value": "\\"
|
|
1232
1279
|
},
|
|
1233
1280
|
{
|
|
1234
|
-
"type": "
|
|
1235
|
-
"
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1281
|
+
"type": "CHOICE",
|
|
1282
|
+
"members": [
|
|
1283
|
+
{
|
|
1284
|
+
"type": "PATTERN",
|
|
1285
|
+
"value": ".|\\n"
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
"type": "PREC",
|
|
1289
|
+
"value": 1,
|
|
1290
|
+
"content": {
|
|
1291
|
+
"type": "STRING",
|
|
1292
|
+
"value": "\u0000"
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
]
|
|
1240
1296
|
}
|
|
1241
1297
|
]
|
|
1242
1298
|
}
|