@algosail/tree-sitter 0.1.3 → 0.1.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/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)*
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.4",
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
  {
@@ -850,34 +850,6 @@
850
850
  }
851
851
  ],
852
852
  "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
853
  [
882
854
  "group"
883
855
  ],
@@ -890,16 +862,6 @@
890
862
  [
891
863
  "field"
892
864
  ],
893
- [
894
- "word"
895
- ],
896
- [
897
- "group_def"
898
- ],
899
- [
900
- "tag",
901
- "group"
902
- ],
903
865
  [
904
866
  "word",
905
867
  "_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,
@@ -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