@algosail/tree-sitter 0.1.5 → 0.1.7

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,6 +1,8 @@
1
1
  /// <reference types="tree-sitter-cli/dsl" />
2
2
  // @ts-check
3
3
 
4
+ const { builtinWords } = require('@algosail/builtins')
5
+
4
6
  module.exports = grammar({
5
7
  name: 'sail',
6
8
 
@@ -57,6 +59,8 @@ module.exports = grammar({
57
59
  module_group_ref: ($) => /~[A-Z][a-zA-Z0-9_]*&[A-Z][a-zA-Z0-9_]*/,
58
60
  // ~Module#Tag
59
61
  module_tag_ref: ($) => /~[A-Z][a-zA-Z0-9_]*#[A-Z][a-zA-Z0-9_]*/,
62
+ // ~Module#Tag
63
+ module_tag_pattern: ($) => /~[A-Z][a-zA-Z0-9_]*\_[A-Z][a-zA-Z0-9_]*/,
60
64
  // ~Module$Map
61
65
  module_map_ref: ($) => /~[A-Z][a-zA-Z0-9_]*\$[A-Z][a-zA-Z0-9_]*/,
62
66
  // ~Module$Map.field
@@ -77,10 +81,10 @@ module.exports = grammar({
77
81
  effect_remove: ($) => /\-[A-Z][a-zA-Z0-9_]*/,
78
82
 
79
83
  // :name
80
- slot_push: ($) => /:[a-z][a-zA-Z0-9_]*/,
84
+ slot_write: ($) => /:[a-z][a-zA-Z0-9_]*/,
81
85
 
82
86
  // ;name
83
- slot_pop: ($) => /;[a-z][a-zA-Z0-9_]*/,
87
+ slot_read: ($) => /;[a-z][a-zA-Z0-9_]*/,
84
88
 
85
89
  // 'raw string literal'
86
90
  raw_string: ($) => /\'[^\']*\'/,
@@ -180,11 +184,12 @@ module.exports = grammar({
180
184
  $.tag_ref,
181
185
  $.module_tag_ref,
182
186
  $.tag_pattern,
187
+ $.module_tag_pattern,
183
188
  $.default_pattern,
184
189
  $.field_ref,
185
190
  $.module_field_ref,
186
- $.slot_push,
187
- $.slot_pop,
191
+ $.slot_write,
192
+ $.slot_read,
188
193
  $.raw_string,
189
194
  $.raw_value,
190
195
  ),
@@ -194,31 +199,6 @@ module.exports = grammar({
194
199
 
195
200
  // All-caps stack-manipulation and control-flow builtins.
196
201
  // Listed as a single token() so they take priority over $.identifier.
197
- builtin_word: ($) =>
198
- token(
199
- choice(
200
- 'DUP',
201
- 'SWAP',
202
- 'DROP',
203
- 'OVER',
204
- 'ROT',
205
- 'ROTR',
206
- 'NIP',
207
- 'TUCK',
208
- 'DUP2',
209
- 'DROP2',
210
- 'SWAP2',
211
- 'CALL',
212
- 'MATCH',
213
- 'COMPOSE',
214
- 'IF',
215
- 'MAP',
216
- 'GETL',
217
- 'SETL',
218
- 'UPDL',
219
- 'APP',
220
- 'ERROR',
221
- ),
222
- ),
202
+ builtin_word: ($) => token(choice(...Object.keys(builtinWords))),
223
203
  },
224
204
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algosail/tree-sitter",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Tree-sitter grammar for the Sail language",
5
5
  "main": "bindings/node",
6
6
  "types": "bindings/node",
@@ -39,5 +39,8 @@
39
39
  "queries/*",
40
40
  "src/**",
41
41
  "*.wasm"
42
- ]
42
+ ],
43
+ "dependencies": {
44
+ "@algosail/builtins": "^0.0.1"
45
+ }
43
46
  }
package/src/grammar.json CHANGED
@@ -101,6 +101,10 @@
101
101
  "type": "PATTERN",
102
102
  "value": "~[A-Z][a-zA-Z0-9_]*#[A-Z][a-zA-Z0-9_]*"
103
103
  },
104
+ "module_tag_pattern": {
105
+ "type": "PATTERN",
106
+ "value": "~[A-Z][a-zA-Z0-9_]*\\_[A-Z][a-zA-Z0-9_]*"
107
+ },
104
108
  "module_map_ref": {
105
109
  "type": "PATTERN",
106
110
  "value": "~[A-Z][a-zA-Z0-9_]*\\$[A-Z][a-zA-Z0-9_]*"
@@ -133,11 +137,11 @@
133
137
  "type": "PATTERN",
134
138
  "value": "\\-[A-Z][a-zA-Z0-9_]*"
135
139
  },
136
- "slot_push": {
140
+ "slot_write": {
137
141
  "type": "PATTERN",
138
142
  "value": ":[a-z][a-zA-Z0-9_]*"
139
143
  },
140
- "slot_pop": {
144
+ "slot_read": {
141
145
  "type": "PATTERN",
142
146
  "value": ";[a-z][a-zA-Z0-9_]*"
143
147
  },
@@ -704,6 +708,10 @@
704
708
  "type": "SYMBOL",
705
709
  "name": "tag_pattern"
706
710
  },
711
+ {
712
+ "type": "SYMBOL",
713
+ "name": "module_tag_pattern"
714
+ },
707
715
  {
708
716
  "type": "SYMBOL",
709
717
  "name": "default_pattern"
@@ -718,11 +726,11 @@
718
726
  },
719
727
  {
720
728
  "type": "SYMBOL",
721
- "name": "slot_push"
729
+ "name": "slot_write"
722
730
  },
723
731
  {
724
732
  "type": "SYMBOL",
725
- "name": "slot_pop"
733
+ "name": "slot_read"
726
734
  },
727
735
  {
728
736
  "type": "SYMBOL",
@@ -814,34 +822,6 @@
814
822
  {
815
823
  "type": "STRING",
816
824
  "value": "COMPOSE"
817
- },
818
- {
819
- "type": "STRING",
820
- "value": "IF"
821
- },
822
- {
823
- "type": "STRING",
824
- "value": "MAP"
825
- },
826
- {
827
- "type": "STRING",
828
- "value": "GETL"
829
- },
830
- {
831
- "type": "STRING",
832
- "value": "SETL"
833
- },
834
- {
835
- "type": "STRING",
836
- "value": "UPDL"
837
- },
838
- {
839
- "type": "STRING",
840
- "value": "APP"
841
- },
842
- {
843
- "type": "STRING",
844
- "value": "ERROR"
845
825
  }
846
826
  ]
847
827
  }
@@ -279,6 +279,10 @@
279
279
  "type": "module_field_ref",
280
280
  "named": true
281
281
  },
282
+ {
283
+ "type": "module_tag_pattern",
284
+ "named": true
285
+ },
282
286
  {
283
287
  "type": "module_tag_ref",
284
288
  "named": true
@@ -300,11 +304,11 @@
300
304
  "named": true
301
305
  },
302
306
  {
303
- "type": "slot_pop",
307
+ "type": "slot_read",
304
308
  "named": true
305
309
  },
306
310
  {
307
- "type": "slot_push",
311
+ "type": "slot_write",
308
312
  "named": true
309
313
  },
310
314
  {
@@ -589,6 +593,10 @@
589
593
  "type": "module_field_ref",
590
594
  "named": true
591
595
  },
596
+ {
597
+ "type": "module_tag_pattern",
598
+ "named": true
599
+ },
592
600
  {
593
601
  "type": "module_tag_ref",
594
602
  "named": true
@@ -610,11 +618,11 @@
610
618
  "named": true
611
619
  },
612
620
  {
613
- "type": "slot_pop",
621
+ "type": "slot_read",
614
622
  "named": true
615
623
  },
616
624
  {
617
- "type": "slot_push",
625
+ "type": "slot_write",
618
626
  "named": true
619
627
  },
620
628
  {
@@ -711,6 +719,10 @@
711
719
  "type": "module_map_ref",
712
720
  "named": true
713
721
  },
722
+ {
723
+ "type": "module_tag_pattern",
724
+ "named": true
725
+ },
714
726
  {
715
727
  "type": "module_tag_ref",
716
728
  "named": true
@@ -736,11 +748,11 @@
736
748
  "named": true
737
749
  },
738
750
  {
739
- "type": "slot_pop",
751
+ "type": "slot_read",
740
752
  "named": true
741
753
  },
742
754
  {
743
- "type": "slot_push",
755
+ "type": "slot_write",
744
756
  "named": true
745
757
  },
746
758
  {