@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 +2 -2
- package/editors/zed/README.md +1 -1
- package/editors/zed/extension.toml +2 -2
- package/editors/zed/languages/gram/highlights.scm +10 -13
- package/grammar.js +35 -34
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/darwin-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/linux-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/linux-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/win32-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/win32-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/queries/highlights.scm +10 -13
- package/src/grammar.json +60 -76
- package/src/node-types.json +264 -274
- package/src/parser.c +1639 -1756
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**: `[
|
|
61
|
-
- **Nodes**: `(
|
|
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)`
|
package/editors/zed/README.md
CHANGED
|
@@ -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
|
-
- **
|
|
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.
|
|
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 = "
|
|
11
|
+
rev = "d6c1b944723c508fde78bc77a39718d6e93e5b8d"
|
|
@@ -39,19 +39,16 @@
|
|
|
39
39
|
] @punctuation.delimiter
|
|
40
40
|
|
|
41
41
|
; Field names in records and maps
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
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
|
-
;
|
|
64
|
-
(
|
|
60
|
+
; Bracket notation (special highlighting)
|
|
61
|
+
(subject_pattern) @type
|
|
65
62
|
|
|
66
63
|
; Node with labels
|
|
67
|
-
(
|
|
64
|
+
(node_pattern (labels (symbol) @type))
|
|
68
65
|
|
|
69
66
|
; Relationship arrows (special highlighting for graph syntax)
|
|
70
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
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($.
|
|
17
|
+
field("elements", commaSep1($._annotated_pattern_element)),
|
|
16
18
|
),
|
|
17
|
-
|
|
19
|
+
_annotated_pattern_element: ($) => choice($.subject_pattern, $._path_pattern),
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
subject_pattern: ($) =>
|
|
20
22
|
seq(
|
|
21
23
|
"[",
|
|
22
|
-
field("
|
|
23
|
-
field("
|
|
24
|
+
field("subject", optional($._subject)),
|
|
25
|
+
field("elements", optional(seq("|", $.subject_pattern_elements))),
|
|
24
26
|
"]",
|
|
25
27
|
),
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
subject_pattern_elements: ($) => commaSep1($._subject_pattern_element),
|
|
28
30
|
|
|
29
|
-
|
|
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
|
-
|
|
38
|
+
_path_pattern: ($) => choice($.relationship_pattern, $.node_pattern),
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
node_pattern: ($) =>
|
|
39
41
|
seq(
|
|
40
42
|
"(",
|
|
41
|
-
field("
|
|
42
|
-
field("attributes", optional($._attributes)),
|
|
43
|
+
field("subject", optional($._subject)),
|
|
43
44
|
")",
|
|
44
45
|
),
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
relationship_pattern: ($) =>
|
|
47
48
|
seq(
|
|
48
|
-
field("left", $.
|
|
49
|
+
field("left", $.node_pattern),
|
|
49
50
|
field("kind", $._relationship_kind),
|
|
50
|
-
field("right", $.
|
|
51
|
+
field("right", $._path_pattern),
|
|
51
52
|
),
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
pattern_reference: ($) => field("identifier", $._identifier),
|
|
54
55
|
|
|
55
56
|
_identifier: ($) => choice($.symbol, $.string_literal, $.integer),
|
|
56
57
|
|
|
57
|
-
|
|
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($.
|
|
103
|
+
record: ($) => seq("{", commaSep($.record_property), "}"),
|
|
103
104
|
|
|
104
|
-
|
|
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($.
|
|
112
|
+
map: ($) => seq("{", commaSep($.map_entry), "}"),
|
|
112
113
|
|
|
113
|
-
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
378
|
+
field("subject", optional($._subject)),
|
|
378
379
|
"]",
|
|
379
380
|
),
|
|
380
381
|
),
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/queries/highlights.scm
CHANGED
|
@@ -39,19 +39,16 @@
|
|
|
39
39
|
] @punctuation.delimiter
|
|
40
40
|
|
|
41
41
|
; Field names in records and maps
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
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
|
-
;
|
|
64
|
-
(
|
|
60
|
+
; Bracket notation (special highlighting)
|
|
61
|
+
(subject_pattern) @type
|
|
65
62
|
|
|
66
63
|
; Node with labels
|
|
67
|
-
(
|
|
64
|
+
(node_pattern (labels (symbol) @type))
|
|
68
65
|
|
|
69
66
|
; Relationship arrows (special highlighting for graph syntax)
|
|
70
|
-
(
|
|
67
|
+
(relationship_pattern) @keyword
|
|
71
68
|
|
|
72
69
|
; Arrow operators in relationships
|
|
73
70
|
(right_arrow) @operator
|