tree-sitter-ktav 0.5.0 → 0.6.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.ru.md +1 -1
- package/README.zh.md +1 -1
- package/grammar.js +25 -4
- package/package.json +1 -1
- package/src/grammar.json +9 -1
- package/src/parser.c +977 -924
package/README.ru.md
CHANGED
package/README.zh.md
CHANGED
package/grammar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tree-sitter grammar for Ktav (כְּתָב) — the Written Configuration Format.
|
|
3
3
|
*
|
|
4
|
-
* Spec: https://github.com/ktav-lang/spec/blob/main/versions/0.
|
|
4
|
+
* Spec: https://github.com/ktav-lang/spec/blob/main/versions/0.6/spec.md
|
|
5
5
|
*
|
|
6
6
|
* Ktav is line-oriented. Every line is one of:
|
|
7
7
|
* - blank
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* - an array item (inside an open `[` array, or at the top level)
|
|
13
13
|
* - raw content of a multi-line string
|
|
14
14
|
*
|
|
15
|
+
* Changes from 0.5.0 to 0.6.0:
|
|
16
|
+
* - Keys now process escape sequences (§ 3.7). The escape table grows
|
|
17
|
+
* to 10 entries by adding `\.` (literal dot — does NOT split the
|
|
18
|
+
* dotted path) and `\:` (literal colon — does NOT act as the
|
|
19
|
+
* key/value separator). `\` becomes the escape lead in keys.
|
|
20
|
+
* Breaking: a raw `\` in a key now requires `\\`.
|
|
21
|
+
*
|
|
15
22
|
* Changes from 0.3.0 (spec 0.1.1) to 0.5.0:
|
|
16
23
|
* - Comment marker changed from `#` to `##`. Single `#` is now a
|
|
17
24
|
* content byte (allowed in keys and scalar values).
|
|
@@ -143,9 +150,17 @@ module.exports = grammar({
|
|
|
143
150
|
repeat1(seq('.', $._key_segment)),
|
|
144
151
|
)),
|
|
145
152
|
|
|
146
|
-
// Key segment
|
|
147
|
-
//
|
|
148
|
-
|
|
153
|
+
// Key segment (spec 0.6.0 § 4): a non-empty run of plain key bytes
|
|
154
|
+
// and/or escape sequences. Plain key bytes exclude whitespace, the
|
|
155
|
+
// bracket/paren/brace bytes, `:`, `,`, the dotted-path separator `.`,
|
|
156
|
+
// `#` (reserved for comment marker `##`), and the escape lead `\`.
|
|
157
|
+
// Those structural bytes — including `\.` and `\:` — can now appear
|
|
158
|
+
// inside a key when escaped (§ 3.7, expanded in 0.6.0 to include
|
|
159
|
+
// `\.` and `\:`).
|
|
160
|
+
//
|
|
161
|
+
// The dotted-path separator is an UNescaped `.`; an unescaped `\`
|
|
162
|
+
// is always the start of an escape sequence (10 forms in 0.6.0).
|
|
163
|
+
_key_segment: $ => /([^\s\[\]\{\}\(\):#,.\r\n\\]|\\[\\,\}\]\{\[nr.:])+/,
|
|
149
164
|
|
|
150
165
|
// ---- Value line ----
|
|
151
166
|
_value_line: $ => choice(
|
|
@@ -279,6 +294,10 @@ module.exports = grammar({
|
|
|
279
294
|
),
|
|
280
295
|
|
|
281
296
|
// Escape sequences recognised inside inline scalars (§ 3.7).
|
|
297
|
+
// In 0.6.0 the table grows to 10 forms by adding `\.` and `\:` —
|
|
298
|
+
// they yield literal `.` and `:` respectively. Inside a value these
|
|
299
|
+
// are redundant (a value's `.`/`:` is already a literal byte) but
|
|
300
|
+
// remain accepted for symmetry with key parsing.
|
|
282
301
|
escape_sequence: $ => token(choice(
|
|
283
302
|
'\\\\',
|
|
284
303
|
'\\,',
|
|
@@ -288,6 +307,8 @@ module.exports = grammar({
|
|
|
288
307
|
'\\[',
|
|
289
308
|
'\\n',
|
|
290
309
|
'\\r',
|
|
310
|
+
'\\.',
|
|
311
|
+
'\\:',
|
|
291
312
|
)),
|
|
292
313
|
|
|
293
314
|
// Leading chunk of a scalar: first byte excludes whitespace and the
|
package/package.json
CHANGED
package/src/grammar.json
CHANGED
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
},
|
|
221
221
|
"_key_segment": {
|
|
222
222
|
"type": "PATTERN",
|
|
223
|
-
"value": "[^\\s\\[\\]\\{\\}\\(\\):#,.\\r\\n]+"
|
|
223
|
+
"value": "([^\\s\\[\\]\\{\\}\\(\\):#,.\\r\\n\\\\]|\\\\[\\\\,\\}\\]\\{\\[nr.:])+"
|
|
224
224
|
},
|
|
225
225
|
"_value_line": {
|
|
226
226
|
"type": "CHOICE",
|
|
@@ -840,6 +840,14 @@
|
|
|
840
840
|
{
|
|
841
841
|
"type": "STRING",
|
|
842
842
|
"value": "\\r"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"type": "STRING",
|
|
846
|
+
"value": "\\."
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
"type": "STRING",
|
|
850
|
+
"value": "\\:"
|
|
843
851
|
}
|
|
844
852
|
]
|
|
845
853
|
}
|