@gram-data/tree-sitter-gram 0.3.7 → 0.3.10
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/binding.gyp +6 -0
- package/editors/zed/extension.toml +3 -3
- 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/src/parser.c +1 -1
- package/src/tree_sitter/array.h +20 -37
- package/tree-sitter-gram.wasm +0 -0
- package/tree-sitter.json +1 -1
- package/editors/zed/languages/gram/highlights.scm +0 -111
- package/editors/zed/languages/gram/indents.scm +0 -14
- package/editors/zed/languages/gram/injections.scm +0 -29
- package/editors/zed/languages/gram/locals.scm +0 -37
package/binding.gyp
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
id = "gram"
|
|
2
2
|
name = "Gram Language Support"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.10"
|
|
4
4
|
schema_version = 1
|
|
5
5
|
authors = ["Gram Data Contributors"]
|
|
6
6
|
description = "Support for Gram notation - composable data patterns"
|
|
@@ -12,5 +12,5 @@ capabilities = [
|
|
|
12
12
|
|
|
13
13
|
# path = "grammars/tree-sitter-gram"
|
|
14
14
|
[grammars.gram]
|
|
15
|
-
repository = "
|
|
16
|
-
rev = "
|
|
15
|
+
repository = "file:///Users/akollegger/Developer/gram-data/tree-sitter-gram"
|
|
16
|
+
rev = "v0.3.10"
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/parser.c
CHANGED
package/src/tree_sitter/array.h
CHANGED
|
@@ -60,7 +60,13 @@ extern "C" {
|
|
|
60
60
|
|
|
61
61
|
/// Free any memory allocated for this array. Note that this does not free any
|
|
62
62
|
/// memory allocated for the array's contents.
|
|
63
|
-
#define array_delete(self)
|
|
63
|
+
#define array_delete(self) \
|
|
64
|
+
do { \
|
|
65
|
+
if ((self)->contents) ts_free((self)->contents); \
|
|
66
|
+
(self)->contents = NULL; \
|
|
67
|
+
(self)->size = 0; \
|
|
68
|
+
(self)->capacity = 0; \
|
|
69
|
+
} while (0)
|
|
64
70
|
|
|
65
71
|
/// Push a new `element` onto the end of the array.
|
|
66
72
|
#define array_push(self, element) \
|
|
@@ -130,12 +136,11 @@ extern "C" {
|
|
|
130
136
|
/// Swap one array with another
|
|
131
137
|
#define array_swap(self, other) \
|
|
132
138
|
do { \
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
(other)->contents = swapped_contents.other_contents; \
|
|
139
|
+
void *_array_swap_tmp = (void *)(self)->contents; \
|
|
140
|
+
(self)->contents = (other)->contents; \
|
|
141
|
+
(other)->contents = _array_swap_tmp; \
|
|
142
|
+
_array__swap(&(self)->size, &(self)->capacity, \
|
|
143
|
+
&(other)->size, &(other)->capacity); \
|
|
139
144
|
} while (0)
|
|
140
145
|
|
|
141
146
|
/// Get the size of the array contents
|
|
@@ -188,12 +193,6 @@ extern "C" {
|
|
|
188
193
|
// The `Array` type itself was not altered as a solution in order to avoid breakage
|
|
189
194
|
// with existing consumers (in particular, parsers with external scanners).
|
|
190
195
|
|
|
191
|
-
/// This is not what you're looking for, see `array_delete`.
|
|
192
|
-
static inline void _array__delete(void *self, void *contents, size_t self_size) {
|
|
193
|
-
if (contents) ts_free(contents);
|
|
194
|
-
if (self) memset(self, 0, self_size);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
196
|
/// This is not what you're looking for, see `array_erase`.
|
|
198
197
|
static inline void _array__erase(void* self_contents, uint32_t *size,
|
|
199
198
|
size_t element_size, uint32_t index) {
|
|
@@ -228,31 +227,15 @@ static inline void *_array__assign(void* self_contents, uint32_t *self_size, uin
|
|
|
228
227
|
return new_contents;
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
struct Swap {
|
|
232
|
-
void *self_contents;
|
|
233
|
-
void *other_contents;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
230
|
/// This is not what you're looking for, see `array_swap`.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
*other_size = *self_size;
|
|
246
|
-
*other_capacity = *self_capacity;
|
|
247
|
-
|
|
248
|
-
*self_size = new_self_size;
|
|
249
|
-
*self_capacity = new_self_capacity;
|
|
250
|
-
|
|
251
|
-
struct Swap out = {
|
|
252
|
-
.self_contents = new_self_contents,
|
|
253
|
-
.other_contents = new_other_contents,
|
|
254
|
-
};
|
|
255
|
-
return out;
|
|
231
|
+
static inline void _array__swap(uint32_t *self_size, uint32_t *self_capacity,
|
|
232
|
+
uint32_t *other_size, uint32_t *other_capacity) {
|
|
233
|
+
uint32_t tmp_size = *self_size;
|
|
234
|
+
uint32_t tmp_capacity = *self_capacity;
|
|
235
|
+
*self_size = *other_size;
|
|
236
|
+
*self_capacity = *other_capacity;
|
|
237
|
+
*other_size = tmp_size;
|
|
238
|
+
*other_capacity = tmp_capacity;
|
|
256
239
|
}
|
|
257
240
|
|
|
258
241
|
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
package/tree-sitter-gram.wasm
CHANGED
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
; Strings
|
|
2
|
-
(string_literal) @string
|
|
3
|
-
(string_content) @string
|
|
4
|
-
|
|
5
|
-
; Numbers
|
|
6
|
-
(integer) @number
|
|
7
|
-
(decimal) @number
|
|
8
|
-
(hexadecimal) @number
|
|
9
|
-
(octal) @number
|
|
10
|
-
(measurement) @number
|
|
11
|
-
|
|
12
|
-
; Boolean literals
|
|
13
|
-
(boolean_literal) @boolean
|
|
14
|
-
|
|
15
|
-
; Comment (FR-003)
|
|
16
|
-
(comment) @comment
|
|
17
|
-
|
|
18
|
-
; Tagged-string tag distinct from content (FR-002)
|
|
19
|
-
(tagged_string tag: (symbol) @attribute)
|
|
20
|
-
|
|
21
|
-
; Reference identifier: pattern_reference (FR-001)
|
|
22
|
-
(pattern_reference identifier: (_) @variable)
|
|
23
|
-
|
|
24
|
-
; Symbols and identifiers (generic; definition/reference/tag captured above)
|
|
25
|
-
(symbol) @variable
|
|
26
|
-
|
|
27
|
-
; Definition-like identifiers and labels (FR-001): @type
|
|
28
|
-
; These must come AFTER generic symbol rule to take priority
|
|
29
|
-
|
|
30
|
-
; Labels (symbols and quoted names in labels nodes)
|
|
31
|
-
(labels (symbol) @type)
|
|
32
|
-
(labels (quoted_name) @type)
|
|
33
|
-
|
|
34
|
-
; Annotation identifiers and labels
|
|
35
|
-
(identified_annotation identifier: (_) @type)
|
|
36
|
-
(identified_annotation labels: (labels (symbol) @type))
|
|
37
|
-
(identified_annotation labels: (labels (quoted_name) @type))
|
|
38
|
-
|
|
39
|
-
; Subject, node, and relationship pattern definitions (FR-001): @type
|
|
40
|
-
; subject/node subject is _subject (use wildcard _ as it may be hidden in some runtimes)
|
|
41
|
-
(subject_pattern subject: (_ identifier: (_) @type))
|
|
42
|
-
(subject_pattern subject: (_ labels: (labels (symbol) @type)))
|
|
43
|
-
(subject_pattern subject: (_ labels: (labels (quoted_name) @type)))
|
|
44
|
-
(node_pattern subject: (_ identifier: (_) @type))
|
|
45
|
-
(node_pattern subject: (_ labels: (labels (symbol) @type)))
|
|
46
|
-
(node_pattern subject: (_ labels: (labels (quoted_name) @type)))
|
|
47
|
-
(relationship_pattern left: (node_pattern subject: (_ identifier: (_) @type)))
|
|
48
|
-
(relationship_pattern left: (node_pattern subject: (_ labels: (labels (symbol) @type))))
|
|
49
|
-
(relationship_pattern left: (node_pattern subject: (_ labels: (labels (quoted_name) @type))))
|
|
50
|
-
(relationship_pattern right: (node_pattern subject: (_ identifier: (_) @type)))
|
|
51
|
-
(relationship_pattern right: (node_pattern subject: (_ labels: (labels (symbol) @type))))
|
|
52
|
-
(relationship_pattern right: (node_pattern subject: (_ labels: (labels (quoted_name) @type))))
|
|
53
|
-
; Arrow kind: subject is inside optional brackets on the arrow
|
|
54
|
-
(relationship_pattern kind: (right_arrow subject: (_ identifier: (_) @type)))
|
|
55
|
-
(relationship_pattern kind: (right_arrow subject: (_ labels: (labels (symbol) @type))))
|
|
56
|
-
(relationship_pattern kind: (right_arrow subject: (_ labels: (labels (quoted_name) @type))))
|
|
57
|
-
(relationship_pattern kind: (left_arrow subject: (_ identifier: (_) @type)))
|
|
58
|
-
(relationship_pattern kind: (left_arrow subject: (_ labels: (labels (symbol) @type))))
|
|
59
|
-
(relationship_pattern kind: (left_arrow subject: (_ labels: (labels (quoted_name) @type))))
|
|
60
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ identifier: (_) @type)))
|
|
61
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ labels: (labels (symbol) @type))))
|
|
62
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ labels: (labels (quoted_name) @type))))
|
|
63
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ identifier: (_) @type)))
|
|
64
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ labels: (labels (symbol) @type))))
|
|
65
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ labels: (labels (quoted_name) @type))))
|
|
66
|
-
|
|
67
|
-
; Keywords and operators
|
|
68
|
-
[
|
|
69
|
-
"@"
|
|
70
|
-
"|"
|
|
71
|
-
":"
|
|
72
|
-
"::"
|
|
73
|
-
] @operator
|
|
74
|
-
|
|
75
|
-
; Subject Patterns and delimiters
|
|
76
|
-
[
|
|
77
|
-
"["
|
|
78
|
-
"]"
|
|
79
|
-
"("
|
|
80
|
-
")"
|
|
81
|
-
"{"
|
|
82
|
-
"}"
|
|
83
|
-
] @punctuation.bracket
|
|
84
|
-
|
|
85
|
-
; Comma separator
|
|
86
|
-
[
|
|
87
|
-
","
|
|
88
|
-
] @punctuation.delimiter
|
|
89
|
-
|
|
90
|
-
; Field names in records and maps
|
|
91
|
-
(record_property key: (symbol) @property)
|
|
92
|
-
(record_property key: (quoted_name) @property)
|
|
93
|
-
(record_property key: (double_quoted_name) @property)
|
|
94
|
-
(map_entry key: (symbol) @property)
|
|
95
|
-
(map_entry key: (quoted_name) @property)
|
|
96
|
-
(map_entry key: (double_quoted_name) @property)
|
|
97
|
-
|
|
98
|
-
; Annotation keys (property-style) and headers (identified/label-style)
|
|
99
|
-
(property_annotation key: (symbol) @attribute)
|
|
100
|
-
|
|
101
|
-
; Relationship arrows (special highlighting for graph syntax)
|
|
102
|
-
(relationship_pattern) @keyword
|
|
103
|
-
|
|
104
|
-
; Arrow operators in relationships
|
|
105
|
-
(right_arrow) @operator
|
|
106
|
-
(left_arrow) @operator
|
|
107
|
-
(undirected_arrow) @operator
|
|
108
|
-
(bidirectional_arrow) @operator
|
|
109
|
-
|
|
110
|
-
; Error highlighting
|
|
111
|
-
(ERROR) @error
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
; Indentation: 2 spaces per level for brackets and multi-line structures
|
|
2
|
-
; FR-007 — specs/004-editor-improvements/contracts/indents.md
|
|
3
|
-
|
|
4
|
-
; Record {}
|
|
5
|
-
"{" @indent
|
|
6
|
-
"}" @indent.end
|
|
7
|
-
|
|
8
|
-
; Subject pattern []
|
|
9
|
-
"[" @indent
|
|
10
|
-
"]" @indent.end
|
|
11
|
-
|
|
12
|
-
; Node pattern ()
|
|
13
|
-
"(" @indent
|
|
14
|
-
")" @indent.end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
; Language injection for tagged strings: tag`content` and ```tag\ncontent\n```
|
|
2
|
-
;
|
|
3
|
-
; The tag symbol is used as the injection language so that downstream and editors
|
|
4
|
-
; can support arbitrary tags without changing the grammar. Well-known tags (md, ts,
|
|
5
|
-
; date, datetime, time, sql, json, html, etc.) are documented in docs/tagged-strings-and-injections.md.
|
|
6
|
-
;
|
|
7
|
-
; Overrides below map tags that do not match common parser names. The final
|
|
8
|
-
; rule uses the tag's text as the language name for all other tags (e.g. "sql",
|
|
9
|
-
; "json", "html" often match parser names).
|
|
10
|
-
|
|
11
|
-
; md -> markdown
|
|
12
|
-
(tagged_string
|
|
13
|
-
tag: (symbol) @_tag
|
|
14
|
-
content: (string_content) @injection.content)
|
|
15
|
-
(#eq? @_tag "md")
|
|
16
|
-
(#set! injection.language "markdown")
|
|
17
|
-
|
|
18
|
-
; ts -> typescript
|
|
19
|
-
(tagged_string
|
|
20
|
-
tag: (symbol) @_tag
|
|
21
|
-
content: (string_content) @injection.content)
|
|
22
|
-
(#eq? @_tag "ts")
|
|
23
|
-
(#set! injection.language "typescript")
|
|
24
|
-
|
|
25
|
-
; Dynamic: use tag text as language name for all other tags (sql, json, html, etc.)
|
|
26
|
-
; Editors may map additional tags (e.g. date, datetime, time) to parsers or leave as plain.
|
|
27
|
-
(tagged_string
|
|
28
|
-
tag: (symbol) @injection.language
|
|
29
|
-
content: (string_content) @injection.content)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
; Locals: go to definition and highlight references (file scope)
|
|
2
|
-
; FR-005, FR-006 — specs/004-editor-improvements/contracts/locals.md
|
|
3
|
-
|
|
4
|
-
; File scope: all definitions and references in one scope
|
|
5
|
-
(gram_pattern) @local.scope
|
|
6
|
-
|
|
7
|
-
; Definitions: identifiers that define a pattern or annotation
|
|
8
|
-
(subject_pattern subject: (_ identifier: (_) @local.definition))
|
|
9
|
-
(subject_pattern subject: (_ labels: (labels (symbol) @local.definition)))
|
|
10
|
-
(subject_pattern subject: (_ labels: (labels (quoted_name) @local.definition)))
|
|
11
|
-
(node_pattern subject: (_ identifier: (_) @local.definition))
|
|
12
|
-
(node_pattern subject: (_ labels: (labels (symbol) @local.definition)))
|
|
13
|
-
(node_pattern subject: (_ labels: (labels (quoted_name) @local.definition)))
|
|
14
|
-
(relationship_pattern left: (node_pattern subject: (_ identifier: (_) @local.definition)))
|
|
15
|
-
(relationship_pattern left: (node_pattern subject: (_ labels: (labels (symbol) @local.definition))))
|
|
16
|
-
(relationship_pattern left: (node_pattern subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
17
|
-
(relationship_pattern right: (node_pattern subject: (_ identifier: (_) @local.definition)))
|
|
18
|
-
(relationship_pattern right: (node_pattern subject: (_ labels: (labels (symbol) @local.definition))))
|
|
19
|
-
(relationship_pattern right: (node_pattern subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
20
|
-
(relationship_pattern kind: (right_arrow subject: (_ identifier: (_) @local.definition)))
|
|
21
|
-
(relationship_pattern kind: (right_arrow subject: (_ labels: (labels (symbol) @local.definition))))
|
|
22
|
-
(relationship_pattern kind: (right_arrow subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
23
|
-
(relationship_pattern kind: (left_arrow subject: (_ identifier: (_) @local.definition)))
|
|
24
|
-
(relationship_pattern kind: (left_arrow subject: (_ labels: (labels (symbol) @local.definition))))
|
|
25
|
-
(relationship_pattern kind: (left_arrow subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
26
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ identifier: (_) @local.definition)))
|
|
27
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ labels: (labels (symbol) @local.definition))))
|
|
28
|
-
(relationship_pattern kind: (undirected_arrow subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
29
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ identifier: (_) @local.definition)))
|
|
30
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ labels: (labels (symbol) @local.definition))))
|
|
31
|
-
(relationship_pattern kind: (bidirectional_arrow subject: (_ labels: (labels (quoted_name) @local.definition))))
|
|
32
|
-
(identified_annotation identifier: (_) @local.definition)
|
|
33
|
-
(identified_annotation labels: (labels (symbol) @local.definition))
|
|
34
|
-
(identified_annotation labels: (labels (quoted_name) @local.definition))
|
|
35
|
-
|
|
36
|
-
; References: pattern_reference identifier
|
|
37
|
-
(pattern_reference identifier: (_) @local.reference)
|