@gram-data/tree-sitter-gram 0.1.9 → 0.1.11

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
@@ -11,18 +11,18 @@ module.exports = grammar({
11
11
  pattern: $ => commaSep1($.pattern_element),
12
12
 
13
13
  pattern_element: $ => seq(
14
- optional(repeat($.annotation)),
15
- choice(
14
+ field("annotations", optional(repeat($.annotation))),
15
+ field("element", choice(
16
16
  $.subject,
17
17
  $._path,
18
18
  $._reference
19
- )
19
+ ))
20
20
  ),
21
21
 
22
22
  // ABKNOTE -- consider the naming of the two parts of a subject
23
23
  // attributes & association
24
24
  // information & association
25
- subject: $ => seq("[", optional(field("attributes", $._attributes)), optional(field("association", $._association)),"]"),
25
+ subject: $ => seq("[", field("attributes", optional($._attributes)), field("association", optional($._association)),"]"),
26
26
 
27
27
  annotation: $ => seq(
28
28
  "@",
@@ -37,7 +37,7 @@ module.exports = grammar({
37
37
  $.node
38
38
  ),
39
39
 
40
- node: $ => seq(token("("), optional($._attributes), token(")")),
40
+ node: $ => seq(token("("), field("attributes", optional($._attributes)), token(")")),
41
41
 
42
42
  relationship: $ => seq(field("left", $.node), field("value", $._relationship_value), field("right", $._path)),
43
43
 
@@ -66,27 +66,25 @@ module.exports = grammar({
66
66
  $.pictograph
67
67
  ),
68
68
 
69
- labels: $ => repeat1($.label),
69
+ _binder: $ => token(/::?/),
70
70
 
71
- label: $ => seq(field("binder", $.binder), $.symbol),
71
+ labels: $ => repeat1($.label),
72
72
 
73
- binder: $ => choice(token(":"), token("::")),
73
+ label: $ => seq($._binder, field("symbol", $.symbol)),
74
74
 
75
75
  record: $ => seq("{", commaSep($.property), "}"),
76
76
 
77
- property: $ => seq(
78
- field('key', $._key),
79
- field('binder', $.binder),
80
- field('value', $._value),
81
- optional(field('cardinality', choice('!', '?', '*', '+')))
82
- ),
83
-
84
-
85
77
  _key: $ => choice(
86
78
  $.symbol,
87
79
  $._string_literal
88
80
  ),
89
81
 
82
+ property: $ => seq(
83
+ field('key', $._key),
84
+ $._binder,
85
+ field('value', $._value)
86
+ ),
87
+
90
88
  symbol: $ => token(/[a-zA-Z_][0-9a-zA-Z_.\-@]*/),
91
89
 
92
90
 
@@ -168,20 +166,26 @@ module.exports = grammar({
168
166
  },
169
167
 
170
168
  _relationship_value: $ => choice(
171
- $.single_undirected,
172
- $.single_bidirectional,
173
- $.single_right,
174
- $.single_left,
175
- $.double_undirected,
176
- $.double_bidirectional,
177
- $.double_right,
178
- $.double_left,
179
- $.squiggle_undirected,
180
- $.squiggle_bidirectional,
181
- $.squiggle_right,
182
- $.squiggle_left,
169
+ alias($.single_undirected, $.undirected),
170
+ alias($.double_undirected, $.undirected),
171
+ alias($.squiggle_undirected, $.undirected),
172
+ alias($.single_bidirectional, $.bidirectional),
173
+ alias($.double_bidirectional, $.bidirectional),
174
+ alias($.squiggle_bidirectional, $.bidirectional),
175
+ alias($.single_left, $.left),
176
+ alias($.double_left, $.left),
177
+ alias($.squiggle_left, $.left),
178
+ alias($.single_right, $.right),
179
+ alias($.double_right, $.right),
180
+ alias($.squiggle_right, $.right)
183
181
  ),
184
-
182
+
183
+ // undirected: $ => alias(choice(
184
+ // $.single_undirected,
185
+ // $.double_undirected,
186
+ // $.squiggle_undirected
187
+ // ), $.undirected),
188
+
185
189
  single_undirected: $ => seq("-", optional(seq("[", $._attributes, "]")), "-"),
186
190
  single_bidirectional: $ => seq("<-", optional(seq("[", $._attributes, "]")), "->"),
187
191
  single_right: $ => seq("-", optional(seq("[", $._attributes, "]")), "->"),
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@gram-data/tree-sitter-gram",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "subject-oriented notation for structured data",
5
5
  "homepage": "https://gram-data.github.io",
6
- "repository": "github:gram-data/tree-sitter-gram",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/gram-data/tree-sitter-gram.git"
9
+ },
7
10
  "main": "bindings/node",
8
11
  "types": "bindings/node",
9
12
  "scripts": {
@@ -29,11 +32,11 @@
29
32
  "author": "",
30
33
  "license": "ISC",
31
34
  "dependencies": {
32
- "node-gyp-build": "^4.8.4",
33
- "node-addon-api": "^8.3.0"
35
+ "node-addon-api": "^8.5.0",
36
+ "node-gyp-build": "^4.8.4"
34
37
  },
35
38
  "peerDependencies": {
36
- "tree-sitter": "^0.21.0"
39
+ "tree-sitter": "^0.25.0"
37
40
  },
38
41
  "peerDependenciesMeta": {
39
42
  "tree_sitter": {
@@ -41,9 +44,9 @@
41
44
  }
42
45
  },
43
46
  "devDependencies": {
44
- "eslint": "^9.17.0",
45
- "node-gyp": "^11.0.0",
47
+ "eslint": "^9.37.0",
48
+ "node-gyp": "^11.4.2",
46
49
  "prebuildify": "^6.0.1",
47
- "tree-sitter-cli": "^0.24.5"
50
+ "tree-sitter-cli": "^0.25.10"
48
51
  }
49
- }
52
+ }
package/src/grammar.json CHANGED
@@ -59,36 +59,44 @@
59
59
  "type": "SEQ",
60
60
  "members": [
61
61
  {
62
- "type": "CHOICE",
63
- "members": [
64
- {
65
- "type": "REPEAT",
66
- "content": {
67
- "type": "SYMBOL",
68
- "name": "annotation"
62
+ "type": "FIELD",
63
+ "name": "annotations",
64
+ "content": {
65
+ "type": "CHOICE",
66
+ "members": [
67
+ {
68
+ "type": "REPEAT",
69
+ "content": {
70
+ "type": "SYMBOL",
71
+ "name": "annotation"
72
+ }
73
+ },
74
+ {
75
+ "type": "BLANK"
69
76
  }
70
- },
71
- {
72
- "type": "BLANK"
73
- }
74
- ]
77
+ ]
78
+ }
75
79
  },
76
80
  {
77
- "type": "CHOICE",
78
- "members": [
79
- {
80
- "type": "SYMBOL",
81
- "name": "subject"
82
- },
83
- {
84
- "type": "SYMBOL",
85
- "name": "_path"
86
- },
87
- {
88
- "type": "SYMBOL",
89
- "name": "_reference"
90
- }
91
- ]
81
+ "type": "FIELD",
82
+ "name": "element",
83
+ "content": {
84
+ "type": "CHOICE",
85
+ "members": [
86
+ {
87
+ "type": "SYMBOL",
88
+ "name": "subject"
89
+ },
90
+ {
91
+ "type": "SYMBOL",
92
+ "name": "_path"
93
+ },
94
+ {
95
+ "type": "SYMBOL",
96
+ "name": "_reference"
97
+ }
98
+ ]
99
+ }
92
100
  }
93
101
  ]
94
102
  },
@@ -100,36 +108,36 @@
100
108
  "value": "["
101
109
  },
102
110
  {
103
- "type": "CHOICE",
104
- "members": [
105
- {
106
- "type": "FIELD",
107
- "name": "attributes",
108
- "content": {
111
+ "type": "FIELD",
112
+ "name": "attributes",
113
+ "content": {
114
+ "type": "CHOICE",
115
+ "members": [
116
+ {
109
117
  "type": "SYMBOL",
110
118
  "name": "_attributes"
119
+ },
120
+ {
121
+ "type": "BLANK"
111
122
  }
112
- },
113
- {
114
- "type": "BLANK"
115
- }
116
- ]
123
+ ]
124
+ }
117
125
  },
118
126
  {
119
- "type": "CHOICE",
120
- "members": [
121
- {
122
- "type": "FIELD",
123
- "name": "association",
124
- "content": {
127
+ "type": "FIELD",
128
+ "name": "association",
129
+ "content": {
130
+ "type": "CHOICE",
131
+ "members": [
132
+ {
125
133
  "type": "SYMBOL",
126
134
  "name": "_association"
135
+ },
136
+ {
137
+ "type": "BLANK"
127
138
  }
128
- },
129
- {
130
- "type": "BLANK"
131
- }
132
- ]
139
+ ]
140
+ }
133
141
  },
134
142
  {
135
143
  "type": "STRING",
@@ -194,16 +202,20 @@
194
202
  }
195
203
  },
196
204
  {
197
- "type": "CHOICE",
198
- "members": [
199
- {
200
- "type": "SYMBOL",
201
- "name": "_attributes"
202
- },
203
- {
204
- "type": "BLANK"
205
- }
206
- ]
205
+ "type": "FIELD",
206
+ "name": "attributes",
207
+ "content": {
208
+ "type": "CHOICE",
209
+ "members": [
210
+ {
211
+ "type": "SYMBOL",
212
+ "name": "_attributes"
213
+ },
214
+ {
215
+ "type": "BLANK"
216
+ }
217
+ ]
218
+ }
207
219
  },
208
220
  {
209
221
  "type": "TOKEN",
@@ -430,6 +442,13 @@
430
442
  }
431
443
  ]
432
444
  },
445
+ "_binder": {
446
+ "type": "TOKEN",
447
+ "content": {
448
+ "type": "PATTERN",
449
+ "value": "::?"
450
+ }
451
+ },
433
452
  "labels": {
434
453
  "type": "REPEAT1",
435
454
  "content": {
@@ -440,35 +459,16 @@
440
459
  "label": {
441
460
  "type": "SEQ",
442
461
  "members": [
443
- {
444
- "type": "FIELD",
445
- "name": "binder",
446
- "content": {
447
- "type": "SYMBOL",
448
- "name": "binder"
449
- }
450
- },
451
462
  {
452
463
  "type": "SYMBOL",
453
- "name": "symbol"
454
- }
455
- ]
456
- },
457
- "binder": {
458
- "type": "CHOICE",
459
- "members": [
460
- {
461
- "type": "TOKEN",
462
- "content": {
463
- "type": "STRING",
464
- "value": ":"
465
- }
464
+ "name": "_binder"
466
465
  },
467
466
  {
468
- "type": "TOKEN",
467
+ "type": "FIELD",
468
+ "name": "symbol",
469
469
  "content": {
470
- "type": "STRING",
471
- "value": "::"
470
+ "type": "SYMBOL",
471
+ "name": "symbol"
472
472
  }
473
473
  }
474
474
  ]
@@ -519,6 +519,19 @@
519
519
  }
520
520
  ]
521
521
  },
522
+ "_key": {
523
+ "type": "CHOICE",
524
+ "members": [
525
+ {
526
+ "type": "SYMBOL",
527
+ "name": "symbol"
528
+ },
529
+ {
530
+ "type": "SYMBOL",
531
+ "name": "_string_literal"
532
+ }
533
+ ]
534
+ },
522
535
  "property": {
523
536
  "type": "SEQ",
524
537
  "members": [
@@ -531,12 +544,8 @@
531
544
  }
532
545
  },
533
546
  {
534
- "type": "FIELD",
535
- "name": "binder",
536
- "content": {
537
- "type": "SYMBOL",
538
- "name": "binder"
539
- }
547
+ "type": "SYMBOL",
548
+ "name": "_binder"
540
549
  },
541
550
  {
542
551
  "type": "FIELD",
@@ -545,52 +554,6 @@
545
554
  "type": "SYMBOL",
546
555
  "name": "_value"
547
556
  }
548
- },
549
- {
550
- "type": "CHOICE",
551
- "members": [
552
- {
553
- "type": "FIELD",
554
- "name": "cardinality",
555
- "content": {
556
- "type": "CHOICE",
557
- "members": [
558
- {
559
- "type": "STRING",
560
- "value": "!"
561
- },
562
- {
563
- "type": "STRING",
564
- "value": "?"
565
- },
566
- {
567
- "type": "STRING",
568
- "value": "*"
569
- },
570
- {
571
- "type": "STRING",
572
- "value": "+"
573
- }
574
- ]
575
- }
576
- },
577
- {
578
- "type": "BLANK"
579
- }
580
- ]
581
- }
582
- ]
583
- },
584
- "_key": {
585
- "type": "CHOICE",
586
- "members": [
587
- {
588
- "type": "SYMBOL",
589
- "name": "symbol"
590
- },
591
- {
592
- "type": "SYMBOL",
593
- "name": "_string_literal"
594
557
  }
595
558
  ]
596
559
  },
@@ -810,52 +773,112 @@
810
773
  "type": "CHOICE",
811
774
  "members": [
812
775
  {
813
- "type": "SYMBOL",
814
- "name": "single_undirected"
776
+ "type": "ALIAS",
777
+ "content": {
778
+ "type": "SYMBOL",
779
+ "name": "single_undirected"
780
+ },
781
+ "named": true,
782
+ "value": "undirected"
815
783
  },
816
784
  {
817
- "type": "SYMBOL",
818
- "name": "single_bidirectional"
785
+ "type": "ALIAS",
786
+ "content": {
787
+ "type": "SYMBOL",
788
+ "name": "double_undirected"
789
+ },
790
+ "named": true,
791
+ "value": "undirected"
819
792
  },
820
793
  {
821
- "type": "SYMBOL",
822
- "name": "single_right"
794
+ "type": "ALIAS",
795
+ "content": {
796
+ "type": "SYMBOL",
797
+ "name": "squiggle_undirected"
798
+ },
799
+ "named": true,
800
+ "value": "undirected"
823
801
  },
824
802
  {
825
- "type": "SYMBOL",
826
- "name": "single_left"
803
+ "type": "ALIAS",
804
+ "content": {
805
+ "type": "SYMBOL",
806
+ "name": "single_bidirectional"
807
+ },
808
+ "named": true,
809
+ "value": "bidirectional"
827
810
  },
828
811
  {
829
- "type": "SYMBOL",
830
- "name": "double_undirected"
812
+ "type": "ALIAS",
813
+ "content": {
814
+ "type": "SYMBOL",
815
+ "name": "double_bidirectional"
816
+ },
817
+ "named": true,
818
+ "value": "bidirectional"
831
819
  },
832
820
  {
833
- "type": "SYMBOL",
834
- "name": "double_bidirectional"
821
+ "type": "ALIAS",
822
+ "content": {
823
+ "type": "SYMBOL",
824
+ "name": "squiggle_bidirectional"
825
+ },
826
+ "named": true,
827
+ "value": "bidirectional"
835
828
  },
836
829
  {
837
- "type": "SYMBOL",
838
- "name": "double_right"
830
+ "type": "ALIAS",
831
+ "content": {
832
+ "type": "SYMBOL",
833
+ "name": "single_left"
834
+ },
835
+ "named": true,
836
+ "value": "left"
839
837
  },
840
838
  {
841
- "type": "SYMBOL",
842
- "name": "double_left"
839
+ "type": "ALIAS",
840
+ "content": {
841
+ "type": "SYMBOL",
842
+ "name": "double_left"
843
+ },
844
+ "named": true,
845
+ "value": "left"
843
846
  },
844
847
  {
845
- "type": "SYMBOL",
846
- "name": "squiggle_undirected"
848
+ "type": "ALIAS",
849
+ "content": {
850
+ "type": "SYMBOL",
851
+ "name": "squiggle_left"
852
+ },
853
+ "named": true,
854
+ "value": "left"
847
855
  },
848
856
  {
849
- "type": "SYMBOL",
850
- "name": "squiggle_bidirectional"
857
+ "type": "ALIAS",
858
+ "content": {
859
+ "type": "SYMBOL",
860
+ "name": "single_right"
861
+ },
862
+ "named": true,
863
+ "value": "right"
851
864
  },
852
865
  {
853
- "type": "SYMBOL",
854
- "name": "squiggle_right"
866
+ "type": "ALIAS",
867
+ "content": {
868
+ "type": "SYMBOL",
869
+ "name": "double_right"
870
+ },
871
+ "named": true,
872
+ "value": "right"
855
873
  },
856
874
  {
857
- "type": "SYMBOL",
858
- "name": "squiggle_left"
875
+ "type": "ALIAS",
876
+ "content": {
877
+ "type": "SYMBOL",
878
+ "name": "squiggle_right"
879
+ },
880
+ "named": true,
881
+ "value": "right"
859
882
  }
860
883
  ]
861
884
  },
@@ -1326,5 +1349,6 @@
1326
1349
  "precedences": [],
1327
1350
  "externals": [],
1328
1351
  "inline": [],
1329
- "supertypes": []
1330
- }
1352
+ "supertypes": [],
1353
+ "reserved": {}
1354
+ }