tree-sitter-ktav 0.5.0 → 0.6.1

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 CHANGED
@@ -6,8 +6,12 @@
6
6
 
7
7
  **Languages:** **English** · [Русский](README.ru.md) · [简体中文](README.zh.md)
8
8
 
9
- [![CI](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml/badge.svg)](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml)
10
- [![crates.io](https://img.shields.io/crates/v/tree-sitter-ktav.svg)](https://crates.io/crates/tree-sitter-ktav)
9
+ **Playground:** convert JSON / YAML / TOML / INI ⇄ Ktav in your browser at **[ktav-lang.github.io](https://ktav-lang.github.io/)**.
10
+
11
+ [![Crates.io](https://img.shields.io/crates/v/tree-sitter-ktav?style=flat-square&logo=rust&label=crates.io)](https://crates.io/crates/tree-sitter-ktav)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/ktav-lang/tree-sitter-ktav/ci.yml?style=flat-square&logo=github&label=CI)](https://github.com/ktav-lang/tree-sitter-ktav/actions)
13
+ ![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue?style=flat-square)
14
+ [![Playground](https://img.shields.io/badge/playground-try%20online-7c3aed?style=flat-square&logo=rocket&logoColor=white)](https://ktav-lang.github.io/)
11
15
  [![npm](https://img.shields.io/npm/v/tree-sitter-ktav.svg)](https://www.npmjs.com/package/tree-sitter-ktav)
12
16
 
13
17
  ---
@@ -37,7 +41,7 @@ this crate / npm package is the one for Ktav.
37
41
  ```toml
38
42
  [dependencies]
39
43
  tree-sitter = "0.25"
40
- tree-sitter-ktav = "0.1"
44
+ tree-sitter-ktav = "0.6.0"
41
45
  ```
42
46
 
43
47
  ```rust
@@ -45,7 +49,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
45
49
  let mut parser = tree_sitter::Parser::new();
46
50
  parser.set_language(&tree_sitter_ktav::LANGUAGE.into())?;
47
51
 
48
- let source = "name: Russia\nport:i 8080\n";
52
+ let source = "name: Russia\nport: 8080\n";
49
53
  let tree = parser.parse(source, None).unwrap();
50
54
  println!("{}", tree.root_node().to_sexp());
51
55
  Ok(())
@@ -65,7 +69,7 @@ const Ktav = require("tree-sitter-ktav");
65
69
  const parser = new Parser();
66
70
  parser.setLanguage(Ktav);
67
71
 
68
- const tree = parser.parse("name: Russia\nport:i 8080\n");
72
+ const tree = parser.parse("name: Russia\nport: 8080\n");
69
73
  console.log(tree.rootNode.toString());
70
74
  ```
71
75
 
@@ -161,8 +165,8 @@ so consumers do not need the CLI to build.
161
165
 
162
166
  ## Status
163
167
 
164
- `0.1.0` — implements [Ktav 0.1.0](https://github.com/ktav-lang/spec/blob/main/versions/0.1/spec.md).
165
- The grammar accepts every valid Ktav 0.1.0 document (verified against
168
+ `0.6.0` — implements [Ktav 0.6.0](https://github.com/ktav-lang/spec/blob/main/versions/0.6/spec.md).
169
+ The grammar accepts every valid Ktav 0.6.0 document (verified against
166
170
  all `tests/valid/*.ktav` fixtures from the spec repo). It is a
167
171
  syntactic accepter, not a strict spec validator — see
168
172
  [`CHANGELOG.md`](CHANGELOG.md) "Known limitations" for the small
package/README.ru.md CHANGED
@@ -6,8 +6,12 @@
6
6
 
7
7
  **Языки:** [English](README.md) · **Русский** · [简体中文](README.zh.md)
8
8
 
9
- [![CI](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml/badge.svg)](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml)
10
- [![crates.io](https://img.shields.io/crates/v/tree-sitter-ktav.svg)](https://crates.io/crates/tree-sitter-ktav)
9
+ **Песочница:** конвертация JSON / YAML / TOML / INI ⇄ Ktav прямо в браузере — **[ktav-lang.github.io](https://ktav-lang.github.io/)**.
10
+
11
+ [![Crates.io](https://img.shields.io/crates/v/tree-sitter-ktav?style=flat-square&logo=rust&label=crates.io)](https://crates.io/crates/tree-sitter-ktav)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/ktav-lang/tree-sitter-ktav/ci.yml?style=flat-square&logo=github&label=CI)](https://github.com/ktav-lang/tree-sitter-ktav/actions)
13
+ ![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue?style=flat-square)
14
+ [![Playground](https://img.shields.io/badge/playground-try%20online-7c3aed?style=flat-square&logo=rocket&logoColor=white)](https://ktav-lang.github.io/)
11
15
  [![npm](https://img.shields.io/npm/v/tree-sitter-ktav.svg)](https://www.npmjs.com/package/tree-sitter-ktav)
12
16
 
13
17
  ---
@@ -37,7 +41,7 @@ VS Code, Zed, …) используют его для подсветки син
37
41
  ```toml
38
42
  [dependencies]
39
43
  tree-sitter = "0.25"
40
- tree-sitter-ktav = "0.1"
44
+ tree-sitter-ktav = "0.6.0"
41
45
  ```
42
46
 
43
47
  ```rust
@@ -45,7 +49,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
45
49
  let mut parser = tree_sitter::Parser::new();
46
50
  parser.set_language(&tree_sitter_ktav::LANGUAGE.into())?;
47
51
 
48
- let source = "name: Russia\nport:i 8080\n";
52
+ let source = "name: Russia\nport: 8080\n";
49
53
  let tree = parser.parse(source, None).unwrap();
50
54
  println!("{}", tree.root_node().to_sexp());
51
55
  Ok(())
@@ -65,7 +69,7 @@ const Ktav = require("tree-sitter-ktav");
65
69
  const parser = new Parser();
66
70
  parser.setLanguage(Ktav);
67
71
 
68
- const tree = parser.parse("name: Russia\nport:i 8080\n");
72
+ const tree = parser.parse("name: Russia\nport: 8080\n");
69
73
  console.log(tree.rootNode.toString());
70
74
  ```
71
75
 
@@ -161,8 +165,8 @@ npx tree-sitter test # запускает корпус
161
165
 
162
166
  ## Статус
163
167
 
164
- `0.1.0` — реализует [Ktav 0.1.0](https://github.com/ktav-lang/spec/blob/main/versions/0.1/spec.md).
165
- Грамматика принимает любой валидный документ Ktav 0.1.0 (проверено на
168
+ `0.6.0` — реализует [Ktav 0.6.0](https://github.com/ktav-lang/spec/blob/main/versions/0.6/spec.md).
169
+ Грамматика принимает любой валидный документ Ktav 0.6.0 (проверено на
166
170
  всех фикстурах `tests/valid/*.ktav` из spec-репозитория). Это
167
171
  синтаксический акцептор, а не строгий валидатор — небольшое число
168
172
  патологических случаев, которые грамматика принимает, а спецификация
@@ -171,7 +175,7 @@ npx tree-sitter test # запускает корпус
171
175
 
172
176
  ## Лицензия
173
177
 
174
- MIT — см. [LICENSE](LICENSE).
178
+ MIT OR Apache-2.0. См. [LICENSE-MIT](LICENSE-MIT) и [LICENSE-APACHE](LICENSE-APACHE).
175
179
 
176
180
  ## Другие репозитории Ktav
177
181
 
package/README.zh.md CHANGED
@@ -5,8 +5,12 @@
5
5
 
6
6
  **语言:** [English](README.md) · [Русский](README.ru.md) · **简体中文**
7
7
 
8
- [![CI](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml/badge.svg)](https://github.com/ktav-lang/tree-sitter-ktav/actions/workflows/ci.yml)
9
- [![crates.io](https://img.shields.io/crates/v/tree-sitter-ktav.svg)](https://crates.io/crates/tree-sitter-ktav)
8
+ **演练场:** 在浏览器中互转 JSON / YAML / TOML / INI ⇄ Ktav — **[ktav-lang.github.io](https://ktav-lang.github.io/)**。
9
+
10
+ [![Crates.io](https://img.shields.io/crates/v/tree-sitter-ktav?style=flat-square&logo=rust&label=crates.io)](https://crates.io/crates/tree-sitter-ktav)
11
+ [![CI](https://img.shields.io/github/actions/workflow/status/ktav-lang/tree-sitter-ktav/ci.yml?style=flat-square&logo=github&label=CI)](https://github.com/ktav-lang/tree-sitter-ktav/actions)
12
+ ![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue?style=flat-square)
13
+ [![Playground](https://img.shields.io/badge/playground-try%20online-7c3aed?style=flat-square&logo=rocket&logoColor=white)](https://ktav-lang.github.io/)
10
14
  [![npm](https://img.shields.io/npm/v/tree-sitter-ktav.svg)](https://www.npmjs.com/package/tree-sitter-ktav)
11
15
 
12
16
  ---
@@ -33,7 +37,7 @@ JSON 相同(标量、数组、对象、`null`、布尔值),但字符串无
33
37
  ```toml
34
38
  [dependencies]
35
39
  tree-sitter = "0.25"
36
- tree-sitter-ktav = "0.1"
40
+ tree-sitter-ktav = "0.6.0"
37
41
  ```
38
42
 
39
43
  ```rust
@@ -41,7 +45,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
41
45
  let mut parser = tree_sitter::Parser::new();
42
46
  parser.set_language(&tree_sitter_ktav::LANGUAGE.into())?;
43
47
 
44
- let source = "name: Russia\nport:i 8080\n";
48
+ let source = "name: Russia\nport: 8080\n";
45
49
  let tree = parser.parse(source, None).unwrap();
46
50
  println!("{}", tree.root_node().to_sexp());
47
51
  Ok(())
@@ -61,7 +65,7 @@ const Ktav = require("tree-sitter-ktav");
61
65
  const parser = new Parser();
62
66
  parser.setLanguage(Ktav);
63
67
 
64
- const tree = parser.parse("name: Russia\nport:i 8080\n");
68
+ const tree = parser.parse("name: Russia\nport: 8080\n");
65
69
  console.log(tree.rootNode.toString());
66
70
  ```
67
71
 
@@ -157,15 +161,15 @@ CLI 即可构建。
157
161
 
158
162
  ## 状态
159
163
 
160
- `0.1.0` — 实现 [Ktav 0.1.0](https://github.com/ktav-lang/spec/blob/main/versions/0.1/spec.md)。
161
- 语法接受所有合法的 Ktav 0.1.0 文档(对 spec 仓库下
164
+ `0.6.0` — 实现 [Ktav 0.6.0](https://github.com/ktav-lang/spec/blob/main/versions/0.6/spec.md)。
165
+ 语法接受所有合法的 Ktav 0.6.0 文档(对 spec 仓库下
162
166
  `tests/valid/*.ktav` 全部用例验证通过)。它是一个语法接受器,而非
163
167
  严格的规范校验器——少数语法接受但规范拒绝的边界情况(主要是 § 6.10
164
168
  "标记后必须有空格")见 [`CHANGELOG.md`](CHANGELOG.md)。
165
169
 
166
170
  ## 许可证
167
171
 
168
- MIT — 见 [LICENSE](LICENSE)。
172
+ MIT OR Apache-2.0。详见 [LICENSE-MIT](LICENSE-MIT) 和 [LICENSE-APACHE](LICENSE-APACHE)。
169
173
 
170
174
  ## 其他 Ktav 仓库
171
175
 
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.5/spec.md
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: any chars except whitespace, "[", "]", "{", "}", "(", ")",
147
- // ":", ",", ".". Note: "#" is now allowed in keys (spec 0.5.0 § 4).
148
- _key_segment: $ => /[^\s\[\]\{\}\(\):#,.\r\n]+/,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-ktav",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Tree-sitter grammar for Ktav (כְּתָב) — the Written Configuration Format",
5
5
  "keywords": [
6
6
  "parser",
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
  }