@algosail/tree-sitter 0.1.3 → 0.1.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/grammar.js CHANGED
@@ -1,32 +1,22 @@
1
1
  /// <reference types="tree-sitter-cli/dsl" />
2
2
  // @ts-check
3
3
 
4
- const UPPERNAME = /[A-Z][a-zA-Z0-9_]*/
5
- const LOWERNAME = /[a-z][a-zA-Z0-9_]*/
6
-
7
4
  module.exports = grammar({
8
5
  name: 'sail',
9
6
 
10
7
  extras: ($) => [/\s+/],
11
8
 
12
9
  conflicts: ($) => [
13
- [$.comment, $.signature],
14
- [$.comment, $.sig_quotation],
15
-
16
- [$.module_def, $.module_ref],
17
- [$.group_def, $.group_ref],
18
- [$.tag_def, $.tag_ref],
19
- [$.map_def, $.map_ref],
20
- [$.field_def, $.field_ref],
21
-
10
+ // GLR self-conflicts: after the rule's main tokens, '(' is ambiguous —
11
+ // it could be the doc comment for THIS node or the start of the NEXT
12
+ // top-level construct. Cannot be resolved by LALR(1).
22
13
  [$.group],
23
14
  [$.tag],
24
15
  [$.map],
25
16
  [$.field],
26
- [$.word],
27
17
 
28
- [$.group_def],
29
- [$.tag, $.group],
18
+ // After word_def + sig + optional(doc), a comment is ambiguous:
19
+ // it could be the doc field OR an _expr in the body.
30
20
  [$.word, $._expr],
31
21
  ],
32
22
 
@@ -35,7 +25,7 @@ module.exports = grammar({
35
25
  _top_level: ($) => choice($.comment, $.import, $.group, $.map, $.word),
36
26
 
37
27
  // ~Module
38
- module_def: ($) => /~[A-Z][a-zA-Z0-9_]*/,
28
+ module_def: ($) => /\+[A-Z][a-zA-Z0-9_]*/,
39
29
  // ~Module
40
30
  module_ref: ($) => /~[A-Z][a-zA-Z0-9_]*/,
41
31
  // &Group
@@ -107,9 +97,9 @@ module.exports = grammar({
107
97
  comment: ($) => seq('(', optional($.comment_content), ')'),
108
98
  comment_content: ($) => repeat1(choice(/[^()]+/, $.comment)),
109
99
 
110
- // Import: +path/or/+pkg Alias
111
- import: ($) => seq(field('path', $.path), field('module', $.module_def)),
112
- path: ($) => /\+[^\s]+/,
100
+ // Import: +Alias path/or/+pkg
101
+ import: ($) => seq(field('module', $.module_def), field('path', $.path)),
102
+ path: ($) => /[^\s]+/,
113
103
  // seq('+', field('url', alias(/[^\s]+/, $.url))),
114
104
 
115
105
  // Tag group: &Name typeParam* (#TagCase typeParam*)*
@@ -127,11 +117,8 @@ module.exports = grammar({
127
117
  optional(field('doc', $.comment)),
128
118
  ),
129
119
  group_type: ($) =>
130
- seq(
131
- field('group', choice($.group_ref, $.module_group_ref)),
132
- optional(field('params', $._generic)),
133
- ),
134
- _generic: ($) => seq('{', repeat($._generic_content), '}'),
120
+ seq(field('group', choice($.group_ref, $.module_group_ref)), optional($._generic)),
121
+ _generic: ($) => seq('{', field('params', repeat($._generic_content)), '}'),
135
122
  _generic_content: ($) => choice($.type, $.group_type, $.map_ref, $.module_map_ref),
136
123
 
137
124
  // Map definition: %Name (.field Type)*
@@ -154,7 +141,7 @@ module.exports = grammar({
154
141
  field('name_def', $.word_def),
155
142
  field('sig', $.signature),
156
143
  optional(field('doc', $.comment)),
157
- repeat($._expr),
144
+ field('body', repeat($._expr)),
158
145
  ),
159
146
  ),
160
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algosail/tree-sitter",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Tree-sitter grammar for the Sail language",
5
5
  "main": "bindings/node",
6
6
  "types": "bindings/node",
package/src/grammar.json CHANGED
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "module_def": {
38
38
  "type": "PATTERN",
39
- "value": "~[A-Z][a-zA-Z0-9_]*"
39
+ "value": "\\+[A-Z][a-zA-Z0-9_]*"
40
40
  },
41
41
  "module_ref": {
42
42
  "type": "PATTERN",
@@ -202,25 +202,25 @@
202
202
  "members": [
203
203
  {
204
204
  "type": "FIELD",
205
- "name": "path",
205
+ "name": "module",
206
206
  "content": {
207
207
  "type": "SYMBOL",
208
- "name": "path"
208
+ "name": "module_def"
209
209
  }
210
210
  },
211
211
  {
212
212
  "type": "FIELD",
213
- "name": "module",
213
+ "name": "path",
214
214
  "content": {
215
215
  "type": "SYMBOL",
216
- "name": "module_def"
216
+ "name": "path"
217
217
  }
218
218
  }
219
219
  ]
220
220
  },
221
221
  "path": {
222
222
  "type": "PATTERN",
223
- "value": "\\+[^\\s]+"
223
+ "value": "[^\\s]+"
224
224
  },
225
225
  "group": {
226
226
  "type": "SEQ",
@@ -334,12 +334,8 @@
334
334
  "type": "CHOICE",
335
335
  "members": [
336
336
  {
337
- "type": "FIELD",
338
- "name": "params",
339
- "content": {
340
- "type": "SYMBOL",
341
- "name": "_generic"
342
- }
337
+ "type": "SYMBOL",
338
+ "name": "_generic"
343
339
  },
344
340
  {
345
341
  "type": "BLANK"
@@ -356,10 +352,14 @@
356
352
  "value": "{"
357
353
  },
358
354
  {
359
- "type": "REPEAT",
355
+ "type": "FIELD",
356
+ "name": "params",
360
357
  "content": {
361
- "type": "SYMBOL",
362
- "name": "_generic_content"
358
+ "type": "REPEAT",
359
+ "content": {
360
+ "type": "SYMBOL",
361
+ "name": "_generic_content"
362
+ }
363
363
  }
364
364
  },
365
365
  {
@@ -522,10 +522,14 @@
522
522
  ]
523
523
  },
524
524
  {
525
- "type": "REPEAT",
525
+ "type": "FIELD",
526
+ "name": "body",
526
527
  "content": {
527
- "type": "SYMBOL",
528
- "name": "_expr"
528
+ "type": "REPEAT",
529
+ "content": {
530
+ "type": "SYMBOL",
531
+ "name": "_expr"
532
+ }
529
533
  }
530
534
  }
531
535
  ]
@@ -850,34 +854,6 @@
850
854
  }
851
855
  ],
852
856
  "conflicts": [
853
- [
854
- "comment",
855
- "signature"
856
- ],
857
- [
858
- "comment",
859
- "sig_quotation"
860
- ],
861
- [
862
- "module_def",
863
- "module_ref"
864
- ],
865
- [
866
- "group_def",
867
- "group_ref"
868
- ],
869
- [
870
- "tag_def",
871
- "tag_ref"
872
- ],
873
- [
874
- "map_def",
875
- "map_ref"
876
- ],
877
- [
878
- "field_def",
879
- "field_ref"
880
- ],
881
857
  [
882
858
  "group"
883
859
  ],
@@ -890,16 +866,6 @@
890
866
  [
891
867
  "field"
892
868
  ],
893
- [
894
- "word"
895
- ],
896
- [
897
- "group_def"
898
- ],
899
- [
900
- "tag",
901
- "group"
902
- ],
903
869
  [
904
870
  "word",
905
871
  "_expr"
@@ -29,6 +29,11 @@
29
29
  ]
30
30
  }
31
31
  },
32
+ {
33
+ "type": "effect_add",
34
+ "named": true,
35
+ "fields": {}
36
+ },
32
37
  {
33
38
  "type": "field",
34
39
  "named": true,
@@ -164,14 +169,6 @@
164
169
  {
165
170
  "type": "type",
166
171
  "named": true
167
- },
168
- {
169
- "type": "{",
170
- "named": false
171
- },
172
- {
173
- "type": "}",
174
- "named": false
175
172
  }
176
173
  ]
177
174
  }
@@ -249,6 +246,11 @@
249
246
  "named": true,
250
247
  "fields": {}
251
248
  },
249
+ {
250
+ "type": "module_def",
251
+ "named": true,
252
+ "fields": {}
253
+ },
252
254
  {
253
255
  "type": "quotation",
254
256
  "named": true,
@@ -563,6 +565,72 @@
563
565
  "type": "word",
564
566
  "named": true,
565
567
  "fields": {
568
+ "body": {
569
+ "multiple": true,
570
+ "required": false,
571
+ "types": [
572
+ {
573
+ "type": "builtin_word",
574
+ "named": true
575
+ },
576
+ {
577
+ "type": "comment",
578
+ "named": true
579
+ },
580
+ {
581
+ "type": "default_pattern",
582
+ "named": true
583
+ },
584
+ {
585
+ "type": "field_ref",
586
+ "named": true
587
+ },
588
+ {
589
+ "type": "module_field_ref",
590
+ "named": true
591
+ },
592
+ {
593
+ "type": "module_tag_ref",
594
+ "named": true
595
+ },
596
+ {
597
+ "type": "module_word_ref",
598
+ "named": true
599
+ },
600
+ {
601
+ "type": "quotation",
602
+ "named": true
603
+ },
604
+ {
605
+ "type": "raw_string",
606
+ "named": true
607
+ },
608
+ {
609
+ "type": "raw_value",
610
+ "named": true
611
+ },
612
+ {
613
+ "type": "slot_pop",
614
+ "named": true
615
+ },
616
+ {
617
+ "type": "slot_push",
618
+ "named": true
619
+ },
620
+ {
621
+ "type": "tag_pattern",
622
+ "named": true
623
+ },
624
+ {
625
+ "type": "tag_ref",
626
+ "named": true
627
+ },
628
+ {
629
+ "type": "word_ref",
630
+ "named": true
631
+ }
632
+ ]
633
+ },
566
634
  "doc": {
567
635
  "multiple": false,
568
636
  "required": false,
@@ -593,72 +661,6 @@
593
661
  }
594
662
  ]
595
663
  }
596
- },
597
- "children": {
598
- "multiple": true,
599
- "required": false,
600
- "types": [
601
- {
602
- "type": "builtin_word",
603
- "named": true
604
- },
605
- {
606
- "type": "comment",
607
- "named": true
608
- },
609
- {
610
- "type": "default_pattern",
611
- "named": true
612
- },
613
- {
614
- "type": "field_ref",
615
- "named": true
616
- },
617
- {
618
- "type": "module_field_ref",
619
- "named": true
620
- },
621
- {
622
- "type": "module_tag_ref",
623
- "named": true
624
- },
625
- {
626
- "type": "module_word_ref",
627
- "named": true
628
- },
629
- {
630
- "type": "quotation",
631
- "named": true
632
- },
633
- {
634
- "type": "raw_string",
635
- "named": true
636
- },
637
- {
638
- "type": "raw_value",
639
- "named": true
640
- },
641
- {
642
- "type": "slot_pop",
643
- "named": true
644
- },
645
- {
646
- "type": "slot_push",
647
- "named": true
648
- },
649
- {
650
- "type": "tag_pattern",
651
- "named": true
652
- },
653
- {
654
- "type": "tag_ref",
655
- "named": true
656
- },
657
- {
658
- "type": "word_ref",
659
- "named": true
660
- }
661
- ]
662
664
  }
663
665
  },
664
666
  {
@@ -685,10 +687,6 @@
685
687
  "type": "default_pattern",
686
688
  "named": true
687
689
  },
688
- {
689
- "type": "effect_add",
690
- "named": true
691
- },
692
690
  {
693
691
  "type": "effect_remove",
694
692
  "named": true
@@ -701,10 +699,6 @@
701
699
  "type": "field_ref",
702
700
  "named": true
703
701
  },
704
- {
705
- "type": "module_def",
706
- "named": true
707
- },
708
702
  {
709
703
  "type": "module_field_ref",
710
704
  "named": true