@algosail/tree-sitter 0.1.1 → 0.1.3

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/src/grammar.json CHANGED
@@ -18,26 +18,144 @@
18
18
  },
19
19
  {
20
20
  "type": "SYMBOL",
21
- "name": "module_def"
21
+ "name": "import"
22
22
  },
23
23
  {
24
24
  "type": "SYMBOL",
25
- "name": "import_decl"
25
+ "name": "group"
26
26
  },
27
27
  {
28
28
  "type": "SYMBOL",
29
- "name": "tag_group"
29
+ "name": "map"
30
30
  },
31
31
  {
32
32
  "type": "SYMBOL",
33
- "name": "map_def"
34
- },
35
- {
36
- "type": "SYMBOL",
37
- "name": "word_def"
33
+ "name": "word"
38
34
  }
39
35
  ]
40
36
  },
37
+ "module_def": {
38
+ "type": "PATTERN",
39
+ "value": "~[A-Z][a-zA-Z0-9_]*"
40
+ },
41
+ "module_ref": {
42
+ "type": "PATTERN",
43
+ "value": "~[A-Z][a-zA-Z0-9_]*"
44
+ },
45
+ "group_def": {
46
+ "type": "PATTERN",
47
+ "value": "&[A-Z][a-zA-Z0-9_]*"
48
+ },
49
+ "group_ref": {
50
+ "type": "PATTERN",
51
+ "value": "&[A-Z][a-zA-Z0-9_]*"
52
+ },
53
+ "tag_def": {
54
+ "type": "PATTERN",
55
+ "value": "#[A-Z][a-zA-Z0-9_]*"
56
+ },
57
+ "tag_ref": {
58
+ "type": "PATTERN",
59
+ "value": "#[A-Z][a-zA-Z0-9_]*"
60
+ },
61
+ "tag_pattern": {
62
+ "type": "PATTERN",
63
+ "value": "\\_[A-Z][a-zA-Z0-9_]*"
64
+ },
65
+ "default_pattern": {
66
+ "type": "TOKEN",
67
+ "content": {
68
+ "type": "STRING",
69
+ "value": "_"
70
+ }
71
+ },
72
+ "map_def": {
73
+ "type": "PATTERN",
74
+ "value": "\\$[A-Z][a-zA-Z0-9_]*"
75
+ },
76
+ "map_ref": {
77
+ "type": "PATTERN",
78
+ "value": "\\$[A-Z][a-zA-Z0-9_]*"
79
+ },
80
+ "field_def": {
81
+ "type": "PATTERN",
82
+ "value": "\\.[a-z][a-zA-Z0-9_]*"
83
+ },
84
+ "field_ref": {
85
+ "type": "PATTERN",
86
+ "value": "\\$[A-Z][a-zA-Z0-9_]*\\.[a-z][a-zA-Z0-9_]*"
87
+ },
88
+ "word_def": {
89
+ "type": "PATTERN",
90
+ "value": "@[a-z][a-zA-Z0-9_]*"
91
+ },
92
+ "word_ref": {
93
+ "type": "PATTERN",
94
+ "value": "\\/[a-z][a-zA-Z0-9_]*"
95
+ },
96
+ "module_group_ref": {
97
+ "type": "PATTERN",
98
+ "value": "~[A-Z][a-zA-Z0-9_]*&[A-Z][a-zA-Z0-9_]*"
99
+ },
100
+ "module_tag_ref": {
101
+ "type": "PATTERN",
102
+ "value": "~[A-Z][a-zA-Z0-9_]*#[A-Z][a-zA-Z0-9_]*"
103
+ },
104
+ "module_map_ref": {
105
+ "type": "PATTERN",
106
+ "value": "~[A-Z][a-zA-Z0-9_]*\\$[A-Z][a-zA-Z0-9_]*"
107
+ },
108
+ "module_field_ref": {
109
+ "type": "PATTERN",
110
+ "value": "~[A-Z][a-zA-Z0-9_]*\\$[A-Z][a-zA-Z0-9_]*\\.[a-z][a-zA-Z0-9_]*"
111
+ },
112
+ "module_word_ref": {
113
+ "type": "PATTERN",
114
+ "value": "~[A-Z][a-zA-Z0-9_]*\\/[a-z][a-zA-Z0-9_]*"
115
+ },
116
+ "type": {
117
+ "type": "PATTERN",
118
+ "value": "[A-Z][a-zA-Z0-9_]*"
119
+ },
120
+ "type_var": {
121
+ "type": "PATTERN",
122
+ "value": "[a-z][a-zA-Z0-9_]*"
123
+ },
124
+ "spread": {
125
+ "type": "PATTERN",
126
+ "value": "\\.\\.[a-z][a-zA-Z0-9_]*"
127
+ },
128
+ "effect_add": {
129
+ "type": "PATTERN",
130
+ "value": "\\+[A-Z][a-zA-Z0-9_]*"
131
+ },
132
+ "effect_remove": {
133
+ "type": "PATTERN",
134
+ "value": "\\-[A-Z][a-zA-Z0-9_]*"
135
+ },
136
+ "slot_push": {
137
+ "type": "PATTERN",
138
+ "value": ":[a-z][a-zA-Z0-9_]*"
139
+ },
140
+ "slot_pop": {
141
+ "type": "PATTERN",
142
+ "value": ";[a-z][a-zA-Z0-9_]*"
143
+ },
144
+ "raw_string": {
145
+ "type": "PATTERN",
146
+ "value": "\\'[^\\']*\\'"
147
+ },
148
+ "raw_value": {
149
+ "type": "TOKEN",
150
+ "content": {
151
+ "type": "PREC",
152
+ "value": -1,
153
+ "content": {
154
+ "type": "PATTERN",
155
+ "value": "[^\\s\\[\\]()']+"
156
+ }
157
+ }
158
+ },
41
159
  "comment": {
42
160
  "type": "SEQ",
43
161
  "members": [
@@ -64,22 +182,22 @@
64
182
  ]
65
183
  },
66
184
  "comment_content": {
67
- "type": "PATTERN",
68
- "value": "[^()]+"
69
- },
70
- "module_def": {
71
- "type": "FIELD",
72
- "name": "name",
185
+ "type": "REPEAT1",
73
186
  "content": {
74
- "type": "SYMBOL",
75
- "name": "module_name"
187
+ "type": "CHOICE",
188
+ "members": [
189
+ {
190
+ "type": "PATTERN",
191
+ "value": "[^()]+"
192
+ },
193
+ {
194
+ "type": "SYMBOL",
195
+ "name": "comment"
196
+ }
197
+ ]
76
198
  }
77
199
  },
78
- "module_name": {
79
- "type": "PATTERN",
80
- "value": "![A-Z][a-zA-Z0-9_]*"
81
- },
82
- "import_decl": {
200
+ "import": {
83
201
  "type": "SEQ",
84
202
  "members": [
85
203
  {
@@ -87,107 +205,227 @@
87
205
  "name": "path",
88
206
  "content": {
89
207
  "type": "SYMBOL",
90
- "name": "import_path"
208
+ "name": "path"
91
209
  }
92
210
  },
93
211
  {
94
212
  "type": "FIELD",
95
- "name": "alias",
213
+ "name": "module",
96
214
  "content": {
97
215
  "type": "SYMBOL",
98
- "name": "module_alias"
216
+ "name": "module_def"
99
217
  }
100
218
  }
101
219
  ]
102
220
  },
103
- "import_path": {
104
- "type": "PATTERN",
105
- "value": "\\|[^\\s]+"
106
- },
107
- "module_alias": {
221
+ "path": {
108
222
  "type": "PATTERN",
109
- "value": "~[A-Z][a-zA-Z0-9_]*"
223
+ "value": "\\+[^\\s]+"
110
224
  },
111
- "tag_group": {
225
+ "group": {
112
226
  "type": "SEQ",
113
227
  "members": [
114
228
  {
115
229
  "type": "FIELD",
116
- "name": "name",
230
+ "name": "def",
117
231
  "content": {
118
232
  "type": "SYMBOL",
119
- "name": "tag_group_name"
233
+ "name": "group_def"
120
234
  }
121
235
  },
122
236
  {
123
237
  "type": "REPEAT",
124
238
  "content": {
125
239
  "type": "SYMBOL",
126
- "name": "type_variable"
240
+ "name": "type_var"
127
241
  }
128
242
  },
243
+ {
244
+ "type": "CHOICE",
245
+ "members": [
246
+ {
247
+ "type": "FIELD",
248
+ "name": "doc",
249
+ "content": {
250
+ "type": "SYMBOL",
251
+ "name": "comment"
252
+ }
253
+ },
254
+ {
255
+ "type": "BLANK"
256
+ }
257
+ ]
258
+ },
129
259
  {
130
260
  "type": "REPEAT",
131
261
  "content": {
132
262
  "type": "SYMBOL",
133
- "name": "tag_def"
263
+ "name": "tag"
134
264
  }
135
265
  }
136
266
  ]
137
267
  },
138
- "tag_group_name": {
139
- "type": "PATTERN",
140
- "value": "&[A-Z][a-zA-Z0-9_]*"
141
- },
142
- "tag_def": {
268
+ "tag": {
143
269
  "type": "SEQ",
144
270
  "members": [
145
271
  {
146
272
  "type": "FIELD",
147
- "name": "name",
273
+ "name": "def",
148
274
  "content": {
149
275
  "type": "SYMBOL",
150
- "name": "tag_name"
276
+ "name": "tag_def"
277
+ }
278
+ },
279
+ {
280
+ "type": "CHOICE",
281
+ "members": [
282
+ {
283
+ "type": "FIELD",
284
+ "name": "type_param",
285
+ "content": {
286
+ "type": "SYMBOL",
287
+ "name": "type_var"
288
+ }
289
+ },
290
+ {
291
+ "type": "BLANK"
292
+ }
293
+ ]
294
+ },
295
+ {
296
+ "type": "CHOICE",
297
+ "members": [
298
+ {
299
+ "type": "FIELD",
300
+ "name": "doc",
301
+ "content": {
302
+ "type": "SYMBOL",
303
+ "name": "comment"
304
+ }
305
+ },
306
+ {
307
+ "type": "BLANK"
308
+ }
309
+ ]
310
+ }
311
+ ]
312
+ },
313
+ "group_type": {
314
+ "type": "SEQ",
315
+ "members": [
316
+ {
317
+ "type": "FIELD",
318
+ "name": "group",
319
+ "content": {
320
+ "type": "CHOICE",
321
+ "members": [
322
+ {
323
+ "type": "SYMBOL",
324
+ "name": "group_ref"
325
+ },
326
+ {
327
+ "type": "SYMBOL",
328
+ "name": "module_group_ref"
329
+ }
330
+ ]
151
331
  }
152
332
  },
333
+ {
334
+ "type": "CHOICE",
335
+ "members": [
336
+ {
337
+ "type": "FIELD",
338
+ "name": "params",
339
+ "content": {
340
+ "type": "SYMBOL",
341
+ "name": "_generic"
342
+ }
343
+ },
344
+ {
345
+ "type": "BLANK"
346
+ }
347
+ ]
348
+ }
349
+ ]
350
+ },
351
+ "_generic": {
352
+ "type": "SEQ",
353
+ "members": [
354
+ {
355
+ "type": "STRING",
356
+ "value": "{"
357
+ },
153
358
  {
154
359
  "type": "REPEAT",
155
360
  "content": {
156
361
  "type": "SYMBOL",
157
- "name": "type_variable"
362
+ "name": "_generic_content"
158
363
  }
364
+ },
365
+ {
366
+ "type": "STRING",
367
+ "value": "}"
159
368
  }
160
369
  ]
161
370
  },
162
- "tag_name": {
163
- "type": "PATTERN",
164
- "value": ">[A-Z][a-zA-Z0-9_]*"
371
+ "_generic_content": {
372
+ "type": "CHOICE",
373
+ "members": [
374
+ {
375
+ "type": "SYMBOL",
376
+ "name": "type"
377
+ },
378
+ {
379
+ "type": "SYMBOL",
380
+ "name": "group_type"
381
+ },
382
+ {
383
+ "type": "SYMBOL",
384
+ "name": "map_ref"
385
+ },
386
+ {
387
+ "type": "SYMBOL",
388
+ "name": "module_map_ref"
389
+ }
390
+ ]
165
391
  },
166
- "map_def": {
392
+ "map": {
167
393
  "type": "SEQ",
168
394
  "members": [
169
395
  {
170
396
  "type": "FIELD",
171
- "name": "name",
397
+ "name": "def",
172
398
  "content": {
173
399
  "type": "SYMBOL",
174
- "name": "map_name"
400
+ "name": "map_def"
175
401
  }
176
402
  },
403
+ {
404
+ "type": "CHOICE",
405
+ "members": [
406
+ {
407
+ "type": "FIELD",
408
+ "name": "doc",
409
+ "content": {
410
+ "type": "SYMBOL",
411
+ "name": "comment"
412
+ }
413
+ },
414
+ {
415
+ "type": "BLANK"
416
+ }
417
+ ]
418
+ },
177
419
  {
178
420
  "type": "REPEAT",
179
421
  "content": {
180
422
  "type": "SYMBOL",
181
- "name": "map_field"
423
+ "name": "field"
182
424
  }
183
425
  }
184
426
  ]
185
427
  },
186
- "map_name": {
187
- "type": "PATTERN",
188
- "value": "%[A-Z][a-zA-Z0-9_]*"
189
- },
190
- "map_field": {
428
+ "field": {
191
429
  "type": "SEQ",
192
430
  "members": [
193
431
  {
@@ -195,7 +433,7 @@
195
433
  "name": "key",
196
434
  "content": {
197
435
  "type": "SYMBOL",
198
- "name": "map_field_name"
436
+ "name": "field_def"
199
437
  }
200
438
  },
201
439
  {
@@ -203,16 +441,49 @@
203
441
  "name": "type",
204
442
  "content": {
205
443
  "type": "SYMBOL",
206
- "name": "type_name"
444
+ "name": "_field_types"
207
445
  }
446
+ },
447
+ {
448
+ "type": "CHOICE",
449
+ "members": [
450
+ {
451
+ "type": "FIELD",
452
+ "name": "doc",
453
+ "content": {
454
+ "type": "SYMBOL",
455
+ "name": "comment"
456
+ }
457
+ },
458
+ {
459
+ "type": "BLANK"
460
+ }
461
+ ]
208
462
  }
209
463
  ]
210
464
  },
211
- "map_field_name": {
212
- "type": "PATTERN",
213
- "value": ":[a-z][a-zA-Z0-9_]*"
465
+ "_field_types": {
466
+ "type": "CHOICE",
467
+ "members": [
468
+ {
469
+ "type": "SYMBOL",
470
+ "name": "type"
471
+ },
472
+ {
473
+ "type": "SYMBOL",
474
+ "name": "group_type"
475
+ },
476
+ {
477
+ "type": "SYMBOL",
478
+ "name": "map_ref"
479
+ },
480
+ {
481
+ "type": "SYMBOL",
482
+ "name": "module_map_ref"
483
+ }
484
+ ]
214
485
  },
215
- "word_def": {
486
+ "word": {
216
487
  "type": "PREC_RIGHT",
217
488
  "value": 0,
218
489
  "content": {
@@ -220,10 +491,10 @@
220
491
  "members": [
221
492
  {
222
493
  "type": "FIELD",
223
- "name": "name",
494
+ "name": "name_def",
224
495
  "content": {
225
496
  "type": "SYMBOL",
226
- "name": "word_name"
497
+ "name": "word_def"
227
498
  }
228
499
  },
229
500
  {
@@ -234,6 +505,22 @@
234
505
  "name": "signature"
235
506
  }
236
507
  },
508
+ {
509
+ "type": "CHOICE",
510
+ "members": [
511
+ {
512
+ "type": "FIELD",
513
+ "name": "doc",
514
+ "content": {
515
+ "type": "SYMBOL",
516
+ "name": "comment"
517
+ }
518
+ },
519
+ {
520
+ "type": "BLANK"
521
+ }
522
+ ]
523
+ },
237
524
  {
238
525
  "type": "REPEAT",
239
526
  "content": {
@@ -244,10 +531,6 @@
244
531
  ]
245
532
  }
246
533
  },
247
- "word_name": {
248
- "type": "PATTERN",
249
- "value": "@[a-z][a-zA-Z0-9_]*"
250
- },
251
534
  "signature": {
252
535
  "type": "SEQ",
253
536
  "members": [
@@ -303,11 +586,11 @@
303
586
  },
304
587
  {
305
588
  "type": "SYMBOL",
306
- "name": "type_name"
589
+ "name": "type"
307
590
  },
308
591
  {
309
592
  "type": "SYMBOL",
310
- "name": "type_variable"
593
+ "name": "type_var"
311
594
  },
312
595
  {
313
596
  "type": "SYMBOL",
@@ -316,6 +599,18 @@
316
599
  {
317
600
  "type": "SYMBOL",
318
601
  "name": "sig_quotation"
602
+ },
603
+ {
604
+ "type": "SYMBOL",
605
+ "name": "group_type"
606
+ },
607
+ {
608
+ "type": "SYMBOL",
609
+ "name": "map_ref"
610
+ },
611
+ {
612
+ "type": "SYMBOL",
613
+ "name": "module_map_ref"
319
614
  }
320
615
  ]
321
616
  },
@@ -370,26 +665,6 @@
370
665
  }
371
666
  ]
372
667
  },
373
- "effect_add": {
374
- "type": "PATTERN",
375
- "value": "\\+[A-Z][a-zA-Z0-9_]*"
376
- },
377
- "effect_remove": {
378
- "type": "PATTERN",
379
- "value": "-[A-Z][a-zA-Z0-9_]*"
380
- },
381
- "spread": {
382
- "type": "PATTERN",
383
- "value": "\\.\\.[a-zA-Z][a-zA-Z0-9_]*"
384
- },
385
- "type_name": {
386
- "type": "PATTERN",
387
- "value": "[A-Z][a-zA-Z0-9_]*"
388
- },
389
- "type_variable": {
390
- "type": "PATTERN",
391
- "value": "[a-z][a-zA-Z0-9_]*"
392
- },
393
668
  "_expr": {
394
669
  "type": "CHOICE",
395
670
  "members": [
@@ -407,19 +682,19 @@
407
682
  },
408
683
  {
409
684
  "type": "SYMBOL",
410
- "name": "word_call"
685
+ "name": "word_ref"
411
686
  },
412
687
  {
413
688
  "type": "SYMBOL",
414
- "name": "module_call"
689
+ "name": "module_word_ref"
415
690
  },
416
691
  {
417
692
  "type": "SYMBOL",
418
- "name": "map_access"
693
+ "name": "tag_ref"
419
694
  },
420
695
  {
421
696
  "type": "SYMBOL",
422
- "name": "tag_constructor"
697
+ "name": "module_tag_ref"
423
698
  },
424
699
  {
425
700
  "type": "SYMBOL",
@@ -427,23 +702,31 @@
427
702
  },
428
703
  {
429
704
  "type": "SYMBOL",
430
- "name": "slot_push"
705
+ "name": "default_pattern"
431
706
  },
432
707
  {
433
708
  "type": "SYMBOL",
434
- "name": "slot_pop"
709
+ "name": "field_ref"
435
710
  },
436
711
  {
437
712
  "type": "SYMBOL",
438
- "name": "raw_string"
713
+ "name": "module_field_ref"
714
+ },
715
+ {
716
+ "type": "SYMBOL",
717
+ "name": "slot_push"
718
+ },
719
+ {
720
+ "type": "SYMBOL",
721
+ "name": "slot_pop"
439
722
  },
440
723
  {
441
724
  "type": "SYMBOL",
442
- "name": "number"
725
+ "name": "raw_string"
443
726
  },
444
727
  {
445
728
  "type": "SYMBOL",
446
- "name": "identifier"
729
+ "name": "raw_value"
447
730
  }
448
731
  ]
449
732
  },
@@ -558,46 +841,6 @@
558
841
  }
559
842
  ]
560
843
  }
561
- },
562
- "word_call": {
563
- "type": "PATTERN",
564
- "value": "\\/[a-z][a-zA-Z0-9_]*"
565
- },
566
- "module_call": {
567
- "type": "PATTERN",
568
- "value": "~[A-Z][a-zA-Z0-9_]*(\\/[a-zA-Z][a-zA-Z0-9_]*)?"
569
- },
570
- "map_access": {
571
- "type": "PATTERN",
572
- "value": "\\*[A-Z][a-zA-Z0-9_]*\\/[a-z][a-zA-Z0-9_]*"
573
- },
574
- "tag_constructor": {
575
- "type": "PATTERN",
576
- "value": "#[A-Z][a-zA-Z0-9_]*"
577
- },
578
- "tag_pattern": {
579
- "type": "PATTERN",
580
- "value": "_[A-Z][a-zA-Z0-9_]*"
581
- },
582
- "slot_push": {
583
- "type": "PATTERN",
584
- "value": "\\.[a-z][a-zA-Z0-9_]*"
585
- },
586
- "slot_pop": {
587
- "type": "PATTERN",
588
- "value": ",[a-z][a-zA-Z0-9_]*"
589
- },
590
- "raw_string": {
591
- "type": "PATTERN",
592
- "value": "\\'[^\\']*\\'"
593
- },
594
- "number": {
595
- "type": "PATTERN",
596
- "value": "[0-9]+(\\.[0-9]+)?"
597
- },
598
- "identifier": {
599
- "type": "PATTERN",
600
- "value": "[a-zA-Z_][a-zA-Z0-9_]*"
601
844
  }
602
845
  },
603
846
  "extras": [
@@ -616,15 +859,50 @@
616
859
  "sig_quotation"
617
860
  ],
618
861
  [
619
- "word_def"
862
+ "module_def",
863
+ "module_ref"
864
+ ],
865
+ [
866
+ "group_def",
867
+ "group_ref"
620
868
  ],
621
869
  [
622
870
  "tag_def",
623
- "tag_group"
871
+ "tag_ref"
872
+ ],
873
+ [
874
+ "map_def",
875
+ "map_ref"
876
+ ],
877
+ [
878
+ "field_def",
879
+ "field_ref"
880
+ ],
881
+ [
882
+ "group"
883
+ ],
884
+ [
885
+ "tag"
886
+ ],
887
+ [
888
+ "map"
889
+ ],
890
+ [
891
+ "field"
892
+ ],
893
+ [
894
+ "word"
895
+ ],
896
+ [
897
+ "group_def"
898
+ ],
899
+ [
900
+ "tag",
901
+ "group"
624
902
  ],
625
903
  [
626
- "type_variable",
627
- "identifier"
904
+ "word",
905
+ "_expr"
628
906
  ]
629
907
  ],
630
908
  "precedences": [],