@cavelang/tree-sitter-cave 0.31.0 → 0.32.0
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/README.md +6 -4
- package/grammar.js +25 -1
- package/package.json +1 -1
- package/src/grammar.json +76 -1
- package/src/node-types.json +71 -0
- package/src/parser.c +1420 -1110
- package/tree-sitter-cave.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Tree-sitter grammar for [CAVE](https://github.com/mirek/cave) — the
|
|
4
4
|
canonical grammar artifact behind editor and terminal highlighting.
|
|
5
5
|
|
|
6
|
-
The grammar is line-oriented (one claim
|
|
7
|
-
needs no external scanner: indentation is skipped
|
|
8
|
-
lines are recognized by their leading verb
|
|
9
|
-
|
|
6
|
+
The grammar is line-oriented (one claim or §8.5 shorthand fragment per
|
|
7
|
+
physical line), so it needs no external scanner: indentation is skipped,
|
|
8
|
+
qualifier/continuation lines are recognized by their leading verb, and a
|
|
9
|
+
low-precedence shorthand fallback keeps incomplete fragments highlightable.
|
|
10
|
+
Prefix expansion and parent attachment (spec §8) are semantic and left to
|
|
11
|
+
consumers such as `@cavelang/parser`.
|
|
10
12
|
|
|
11
13
|
Entity and attribute names accept Unicode letters, combining marks and
|
|
12
14
|
numbers, with `/`, `-`, `_`, and `.` as structural characters. Numeric
|
package/grammar.js
CHANGED
|
@@ -22,6 +22,12 @@ module.exports = grammar({
|
|
|
22
22
|
|
|
23
23
|
extras: () => [/[ \t]/],
|
|
24
24
|
|
|
25
|
+
conflicts: $ => [
|
|
26
|
+
[$.claim_line, $.shorthand_line, $._body],
|
|
27
|
+
[$.shorthand_line, $._body],
|
|
28
|
+
[$.claim_line, $.shorthand_line]
|
|
29
|
+
],
|
|
30
|
+
|
|
25
31
|
rules: {
|
|
26
32
|
document: $ => seq(optional($._line), repeat(seq(NL, optional($._line)))),
|
|
27
33
|
|
|
@@ -29,7 +35,8 @@ module.exports = grammar({
|
|
|
29
35
|
$.comment_line,
|
|
30
36
|
$.qualifier_line,
|
|
31
37
|
$.claim_line,
|
|
32
|
-
$.continuation_line
|
|
38
|
+
$.continuation_line,
|
|
39
|
+
$.shorthand_line
|
|
33
40
|
),
|
|
34
41
|
|
|
35
42
|
comment_line: $ => $.comment,
|
|
@@ -42,6 +49,23 @@ module.exports = grammar({
|
|
|
42
49
|
// Bare relational verb; the subject is inherited from the parent (§8.3).
|
|
43
50
|
continuation_line: $ => prec.dynamic(-1, $._body),
|
|
44
51
|
|
|
52
|
+
// A physical fragment participating in §8.5's recursive shorthand.
|
|
53
|
+
// Indentation and prefix expansion remain consumer responsibilities;
|
|
54
|
+
// this permissive fallback keeps every fragment highlightable while the
|
|
55
|
+
// complete line rules above retain precedence.
|
|
56
|
+
shorthand_line: $ => prec.dynamic(-2, seq(
|
|
57
|
+
repeat1(choice(
|
|
58
|
+
$.verb,
|
|
59
|
+
$.attribute,
|
|
60
|
+
$._term,
|
|
61
|
+
$.number,
|
|
62
|
+
$.negation,
|
|
63
|
+
$._meta,
|
|
64
|
+
'->'
|
|
65
|
+
)),
|
|
66
|
+
optional($.comment)
|
|
67
|
+
)),
|
|
68
|
+
|
|
45
69
|
_body: $ => choice(
|
|
46
70
|
prec.right(seq(
|
|
47
71
|
field('verb', $.verb),
|
package/package.json
CHANGED
package/src/grammar.json
CHANGED
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
{
|
|
62
62
|
"type": "SYMBOL",
|
|
63
63
|
"name": "continuation_line"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"type": "SYMBOL",
|
|
67
|
+
"name": "shorthand_line"
|
|
64
68
|
}
|
|
65
69
|
]
|
|
66
70
|
},
|
|
@@ -107,6 +111,63 @@
|
|
|
107
111
|
"name": "_body"
|
|
108
112
|
}
|
|
109
113
|
},
|
|
114
|
+
"shorthand_line": {
|
|
115
|
+
"type": "PREC_DYNAMIC",
|
|
116
|
+
"value": -2,
|
|
117
|
+
"content": {
|
|
118
|
+
"type": "SEQ",
|
|
119
|
+
"members": [
|
|
120
|
+
{
|
|
121
|
+
"type": "REPEAT1",
|
|
122
|
+
"content": {
|
|
123
|
+
"type": "CHOICE",
|
|
124
|
+
"members": [
|
|
125
|
+
{
|
|
126
|
+
"type": "SYMBOL",
|
|
127
|
+
"name": "verb"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"type": "SYMBOL",
|
|
131
|
+
"name": "attribute"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"type": "SYMBOL",
|
|
135
|
+
"name": "_term"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "SYMBOL",
|
|
139
|
+
"name": "number"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"type": "SYMBOL",
|
|
143
|
+
"name": "negation"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "SYMBOL",
|
|
147
|
+
"name": "_meta"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"type": "STRING",
|
|
151
|
+
"value": "->"
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "CHOICE",
|
|
158
|
+
"members": [
|
|
159
|
+
{
|
|
160
|
+
"type": "SYMBOL",
|
|
161
|
+
"name": "comment"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"type": "BLANK"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
},
|
|
110
171
|
"_body": {
|
|
111
172
|
"type": "CHOICE",
|
|
112
173
|
"members": [
|
|
@@ -782,7 +843,21 @@
|
|
|
782
843
|
"value": "[ \\t]"
|
|
783
844
|
}
|
|
784
845
|
],
|
|
785
|
-
"conflicts": [
|
|
846
|
+
"conflicts": [
|
|
847
|
+
[
|
|
848
|
+
"claim_line",
|
|
849
|
+
"shorthand_line",
|
|
850
|
+
"_body"
|
|
851
|
+
],
|
|
852
|
+
[
|
|
853
|
+
"shorthand_line",
|
|
854
|
+
"_body"
|
|
855
|
+
],
|
|
856
|
+
[
|
|
857
|
+
"claim_line",
|
|
858
|
+
"shorthand_line"
|
|
859
|
+
]
|
|
860
|
+
],
|
|
786
861
|
"precedences": [],
|
|
787
862
|
"externals": [],
|
|
788
863
|
"inline": [],
|
package/src/node-types.json
CHANGED
|
@@ -299,6 +299,10 @@
|
|
|
299
299
|
{
|
|
300
300
|
"type": "qualifier_line",
|
|
301
301
|
"named": true
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"type": "shorthand_line",
|
|
305
|
+
"named": true
|
|
302
306
|
}
|
|
303
307
|
]
|
|
304
308
|
}
|
|
@@ -477,6 +481,73 @@
|
|
|
477
481
|
"named": true,
|
|
478
482
|
"fields": {}
|
|
479
483
|
},
|
|
484
|
+
{
|
|
485
|
+
"type": "shorthand_line",
|
|
486
|
+
"named": true,
|
|
487
|
+
"fields": {},
|
|
488
|
+
"children": {
|
|
489
|
+
"multiple": true,
|
|
490
|
+
"required": false,
|
|
491
|
+
"types": [
|
|
492
|
+
{
|
|
493
|
+
"type": "attribute",
|
|
494
|
+
"named": true
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
"type": "code",
|
|
498
|
+
"named": true
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
"type": "comment",
|
|
502
|
+
"named": true
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
"type": "confidence",
|
|
506
|
+
"named": true
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"type": "context",
|
|
510
|
+
"named": true
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"type": "entity",
|
|
514
|
+
"named": true
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"type": "importance",
|
|
518
|
+
"named": true
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"type": "negation",
|
|
522
|
+
"named": true
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"type": "number",
|
|
526
|
+
"named": true
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"type": "sigma",
|
|
530
|
+
"named": true
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"type": "string",
|
|
534
|
+
"named": true
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
"type": "tag",
|
|
538
|
+
"named": true
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
"type": "uncertainty",
|
|
542
|
+
"named": true
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"type": "verb",
|
|
546
|
+
"named": true
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
}
|
|
550
|
+
},
|
|
480
551
|
{
|
|
481
552
|
"type": "tag",
|
|
482
553
|
"named": true,
|