@gram-data/tree-sitter-gram 0.2.2 → 0.2.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/editors/README.md CHANGED
@@ -57,8 +57,8 @@ Popular editors we'd love to see integrations for:
57
57
 
58
58
  All editor integrations should support these Gram language features:
59
59
 
60
- - **Subjects**: `[attributes]` and `[:type attributes]`
61
- - **Nodes**: `(attributes)`
60
+ - **Subjects**: `[subject]` and `[:type subject]`
61
+ - **Nodes**: `(subject)`
62
62
  - **Relationships**: `->`, `--`, `<-`, `<--`, `<->`, `<-->`
63
63
  - **Data types**: strings, numbers, booleans, null, arrays, objects
64
64
  - **Annotations**: `@key(value)`
@@ -80,7 +80,7 @@ Once installed, the extension automatically provides syntax highlighting for any
80
80
 
81
81
  The extension provides highlighting for:
82
82
 
83
- - **Subjects**: `[...]` and `[:type ...]` brackets
83
+ - **Brackets**: `[...]` and `[:type ...]` bracket notation (containing subjects)
84
84
  - **Nodes**: `(...)` parentheses
85
85
  - **Relationships**: `->`, `--`, `<-`, `<-->`, etc.
86
86
  - **Strings**: Single, double, and backtick quoted strings
@@ -1,6 +1,6 @@
1
1
  id = "gram"
2
2
  name = "Gram Language Support"
3
- version = "0.2.1"
3
+ version = "0.2.4"
4
4
  schema_version = 1
5
5
  authors = ["Gram Data Contributors"]
6
6
  description = "Support for Gram notation - a subject-oriented notation for structured data"
@@ -8,4 +8,4 @@ description = "Support for Gram notation - a subject-oriented notation for struc
8
8
  # path = "grammars/tree-sitter-gram"
9
9
  [grammars.gram]
10
10
  repository = "https://github.com/gram-data/tree-sitter-gram"
11
- rev = "9ea6cc1fb412128bc4197cc717a8e77e907472ec"
11
+ rev = "d6c1b944723c508fde78bc77a39718d6e93e5b8d"
@@ -39,19 +39,16 @@
39
39
  ] @punctuation.delimiter
40
40
 
41
41
  ; Field names in records and maps
42
- (property key: (symbol) @property)
43
- (property key: (string_literal) @property)
44
- (property key: (integer) @property)
45
- (mapping key: (symbol) @property)
46
- (mapping key: (string_literal) @property)
47
- (mapping key: (integer) @property)
42
+ (record_property key: (symbol) @property)
43
+ (record_property key: (string_literal) @property)
44
+ (record_property key: (integer) @property)
45
+ (map_entry key: (symbol) @property)
46
+ (map_entry key: (string_literal) @property)
47
+ (map_entry key: (integer) @property)
48
48
 
49
49
  ; Annotation keys
50
50
  (annotation key: (symbol) @attribute)
51
51
 
52
- ; Annotations inside nodes
53
- (node annotations: (annotations) @attribute)
54
-
55
52
  ; Annotations inside relationship arrows
56
53
  [
57
54
  (right_arrow annotations: (annotations) @attribute)
@@ -60,14 +57,14 @@
60
57
  (bidirectional_arrow annotations: (annotations) @attribute)
61
58
  ]
62
59
 
63
- ; Subject brackets (special highlighting)
64
- (subject) @type
60
+ ; Bracket notation (special highlighting)
61
+ (subject_pattern) @type
65
62
 
66
63
  ; Node with labels
67
- (node (labels (symbol) @type))
64
+ (node_pattern (labels (symbol) @type))
68
65
 
69
66
  ; Relationship arrows (special highlighting for graph syntax)
70
- (relationship) @keyword
67
+ (relationship_pattern) @keyword
71
68
 
72
69
  ; Arrow operators in relationships
73
70
  (right_arrow) @operator
package/grammar.js CHANGED
@@ -7,54 +7,55 @@ module.exports = grammar({
7
7
  ],
8
8
 
9
9
  rules: {
10
- gram: ($) => seq(field("root", optional($.record)), repeat($.pattern)),
10
+ // top-level rule, forming an outer pattern shaped like `[ record | sequence-of-top-level-elements ]`
11
+ gram: ($) => seq(field("root", optional($.record)), repeat($.annotated_pattern)),
11
12
 
12
- pattern: ($) =>
13
+ // top-level elements are annotated patterns shaped like `[annotation-record | pattern-elements]`
14
+ annotated_pattern: ($) =>
13
15
  seq(
14
16
  field("annotations", optional($.annotations)),
15
- field("elements", commaSep1($._pattern_element)),
17
+ field("elements", commaSep1($._annotated_pattern_element)),
16
18
  ),
17
- _pattern_element: ($) => choice($.subject, $._path),
19
+ _annotated_pattern_element: ($) => choice($.subject_pattern, $._path_pattern),
18
20
 
19
- subject: ($) =>
21
+ subject_pattern: ($) =>
20
22
  seq(
21
23
  "[",
22
- field("attributes", optional($._attributes)),
23
- field("pattern", optional(seq("|", $.sub_pattern))),
24
+ field("subject", optional($._subject)),
25
+ field("elements", optional(seq("|", $.subject_pattern_elements))),
24
26
  "]",
25
27
  ),
26
28
 
27
- sub_pattern: ($) => commaSep1($._sub_pattern_element),
29
+ subject_pattern_elements: ($) => commaSep1($._subject_pattern_element),
28
30
 
29
- _sub_pattern_element: ($) => choice($.subject, $._path, $.reference),
31
+ _subject_pattern_element: ($) => choice($.subject_pattern, $._path_pattern, $.pattern_reference),
30
32
 
31
33
  annotations: ($) => repeat1($.annotation),
32
34
 
33
35
  annotation: ($) =>
34
36
  seq("@", field("key", $.symbol), "(", field("value", $._value), ")"),
35
37
 
36
- _path: ($) => choice($.relationship, $.node),
38
+ _path_pattern: ($) => choice($.relationship_pattern, $.node_pattern),
37
39
 
38
- node: ($) =>
40
+ node_pattern: ($) =>
39
41
  seq(
40
42
  "(",
41
- field("annotations", optional($.annotations)),
42
- field("attributes", optional($._attributes)),
43
+ field("subject", optional($._subject)),
43
44
  ")",
44
45
  ),
45
46
 
46
- relationship: ($) =>
47
+ relationship_pattern: ($) =>
47
48
  seq(
48
- field("left", $.node),
49
+ field("left", $.node_pattern),
49
50
  field("kind", $._relationship_kind),
50
- field("right", $._path),
51
+ field("right", $._path_pattern),
51
52
  ),
52
53
 
53
- reference: ($) => field("identifier", $._identifier),
54
+ pattern_reference: ($) => field("identifier", $._identifier),
54
55
 
55
56
  _identifier: ($) => choice($.symbol, $.string_literal, $.integer),
56
57
 
57
- _attributes: ($) =>
58
+ _subject: ($) =>
58
59
  choice(
59
60
  choice(
60
61
  field("identifier", $._identifier),
@@ -99,18 +100,18 @@ module.exports = grammar({
99
100
 
100
101
  _label: ($) => seq(choice(":", "::"), $.symbol),
101
102
 
102
- record: ($) => seq("{", commaSep($.property), "}"),
103
+ record: ($) => seq("{", commaSep($.record_property), "}"),
103
104
 
104
- property: ($) =>
105
+ record_property: ($) =>
105
106
  seq(
106
107
  field("key", $._identifier),
107
108
  choice(":", "::"),
108
109
  field("value", $._value),
109
110
  ),
110
111
 
111
- map: ($) => seq("{", commaSep($.mapping), "}"),
112
+ map: ($) => seq("{", commaSep($.map_entry), "}"),
112
113
 
113
- mapping: ($) =>
114
+ map_entry: ($) =>
114
115
  seq(field("key", $._identifier), ":", field("value", $._scalar_value)),
115
116
 
116
117
  symbol: ($) => token(/[a-zA-Z_][0-9a-zA-Z_.\-@]*/),
@@ -230,7 +231,7 @@ module.exports = grammar({
230
231
  seq(
231
232
  "[",
232
233
  field("annotations", optional($.annotations)),
233
- field("attributes", optional($._attributes)),
234
+ field("subject", optional($._subject)),
234
235
  "]",
235
236
  ),
236
237
  ),
@@ -242,7 +243,7 @@ module.exports = grammar({
242
243
  seq(
243
244
  "[",
244
245
  field("annotations", optional($.annotations)),
245
- field("attributes", optional($._attributes)),
246
+ field("subject", optional($._subject)),
246
247
  "]",
247
248
  ),
248
249
  ),
@@ -254,7 +255,7 @@ module.exports = grammar({
254
255
  seq(
255
256
  "[",
256
257
  field("annotations", optional($.annotations)),
257
- field("attributes", optional($._attributes)),
258
+ field("subject", optional($._subject)),
258
259
  "]",
259
260
  ),
260
261
  ),
@@ -270,7 +271,7 @@ module.exports = grammar({
270
271
  seq(
271
272
  "[",
272
273
  field("annotations", optional($.annotations)),
273
- field("attributes", optional($._attributes)),
274
+ field("subject", optional($._subject)),
274
275
  "]",
275
276
  ),
276
277
  ),
@@ -282,7 +283,7 @@ module.exports = grammar({
282
283
  seq(
283
284
  "[",
284
285
  field("annotations", optional($.annotations)),
285
- field("attributes", optional($._attributes)),
286
+ field("subject", optional($._subject)),
286
287
  "]",
287
288
  ),
288
289
  ),
@@ -294,7 +295,7 @@ module.exports = grammar({
294
295
  seq(
295
296
  "[",
296
297
  field("annotations", optional($.annotations)),
297
- field("attributes", optional($._attributes)),
298
+ field("subject", optional($._subject)),
298
299
  "]",
299
300
  ),
300
301
  ),
@@ -310,7 +311,7 @@ module.exports = grammar({
310
311
  seq(
311
312
  "[",
312
313
  field("annotations", optional($.annotations)),
313
- field("attributes", optional($._attributes)),
314
+ field("subject", optional($._subject)),
314
315
  "]",
315
316
  ),
316
317
  ),
@@ -322,7 +323,7 @@ module.exports = grammar({
322
323
  seq(
323
324
  "[",
324
325
  field("annotations", optional($.annotations)),
325
- field("attributes", optional($._attributes)),
326
+ field("subject", optional($._subject)),
326
327
  "]",
327
328
  ),
328
329
  ),
@@ -334,7 +335,7 @@ module.exports = grammar({
334
335
  seq(
335
336
  "[",
336
337
  field("annotations", optional($.annotations)),
337
- field("attributes", optional($._attributes)),
338
+ field("subject", optional($._subject)),
338
339
  "]",
339
340
  ),
340
341
  ),
@@ -350,7 +351,7 @@ module.exports = grammar({
350
351
  seq(
351
352
  "[",
352
353
  field("annotations", optional($.annotations)),
353
- field("attributes", optional($._attributes)),
354
+ field("subject", optional($._subject)),
354
355
  "]",
355
356
  ),
356
357
  ),
@@ -362,7 +363,7 @@ module.exports = grammar({
362
363
  seq(
363
364
  "[",
364
365
  field("annotations", optional($.annotations)),
365
- field("attributes", optional($._attributes)),
366
+ field("subject", optional($._subject)),
366
367
  "]",
367
368
  ),
368
369
  ),
@@ -374,7 +375,7 @@ module.exports = grammar({
374
375
  seq(
375
376
  "[",
376
377
  field("annotations", optional($.annotations)),
377
- field("attributes", optional($._attributes)),
378
+ field("subject", optional($._subject)),
378
379
  "]",
379
380
  ),
380
381
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gram-data/tree-sitter-gram",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "subject-oriented notation for structured data",
5
5
  "homepage": "https://gram-data.github.io",
6
6
  "repository": {
@@ -39,19 +39,16 @@
39
39
  ] @punctuation.delimiter
40
40
 
41
41
  ; Field names in records and maps
42
- (property key: (symbol) @property)
43
- (property key: (string_literal) @property)
44
- (property key: (integer) @property)
45
- (mapping key: (symbol) @property)
46
- (mapping key: (string_literal) @property)
47
- (mapping key: (integer) @property)
42
+ (record_property key: (symbol) @property)
43
+ (record_property key: (string_literal) @property)
44
+ (record_property key: (integer) @property)
45
+ (map_entry key: (symbol) @property)
46
+ (map_entry key: (string_literal) @property)
47
+ (map_entry key: (integer) @property)
48
48
 
49
49
  ; Annotation keys
50
50
  (annotation key: (symbol) @attribute)
51
51
 
52
- ; Annotations inside nodes
53
- (node annotations: (annotations) @attribute)
54
-
55
52
  ; Annotations inside relationship arrows
56
53
  [
57
54
  (right_arrow annotations: (annotations) @attribute)
@@ -60,14 +57,14 @@
60
57
  (bidirectional_arrow annotations: (annotations) @attribute)
61
58
  ]
62
59
 
63
- ; Subject brackets (special highlighting)
64
- (subject) @type
60
+ ; Bracket notation (special highlighting)
61
+ (subject_pattern) @type
65
62
 
66
63
  ; Node with labels
67
- (node (labels (symbol) @type))
64
+ (node_pattern (labels (symbol) @type))
68
65
 
69
66
  ; Relationship arrows (special highlighting for graph syntax)
70
- (relationship) @keyword
67
+ (relationship_pattern) @keyword
71
68
 
72
69
  ; Arrow operators in relationships
73
70
  (right_arrow) @operator