@konomanoasa/tree-sitter-toml 0.3.0 → 0.4.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/Cargo.toml +16 -3
- package/README.md +2 -7
- package/package.json +1 -1
- package/src/parser.c +1 -1
- package/src/scanner.c +5 -6
- package/test/bindings.test.rs +5 -3
- package/tree-sitter.json +1 -1
package/Cargo.toml
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
[package]
|
|
2
|
-
name = "tree-sitter-toml"
|
|
3
|
-
version = "0.
|
|
2
|
+
name = "konomanoasa-tree-sitter-toml"
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
edition = "2024"
|
|
5
|
+
description = "Tree-sitter grammar for TOML."
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
repository = "https://github.com/konomanoasa/tree-sitter-toml"
|
|
8
|
+
license = "MIT"
|
|
5
9
|
build = "bindings/rust/build.rs"
|
|
6
10
|
links = "tree-sitter-toml"
|
|
7
|
-
|
|
11
|
+
include = [
|
|
12
|
+
"/LICENSE",
|
|
13
|
+
"/README.md",
|
|
14
|
+
"/bindings/rust/*.rs",
|
|
15
|
+
"/queries/*.scm",
|
|
16
|
+
"/src/*.c",
|
|
17
|
+
"/src/node-types.json",
|
|
18
|
+
"/src/tree_sitter/*.h",
|
|
19
|
+
"/test/bindings.test.rs",
|
|
20
|
+
]
|
|
8
21
|
|
|
9
22
|
[lib]
|
|
10
23
|
path = "bindings/rust/lib.rs"
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# tree-sitter-toml
|
|
2
2
|
|
|
3
3
|
[](https://github.com/konomanoasa/tree-sitter-toml/actions/workflows/ci.yaml)
|
|
4
|
+
[](https://crates.io/crates/konomanoasa-tree-sitter-toml)
|
|
4
5
|
[](https://www.npmjs.com/package/@konomanoasa/tree-sitter-toml)
|
|
5
6
|
|
|
6
7
|
[Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
|
|
@@ -12,15 +13,9 @@ Tom's Obvious Minimal Language 1.1.0.
|
|
|
12
13
|
npm install @konomanoasa/tree-sitter-toml
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
## Grammar
|
|
16
|
-
|
|
17
|
-
| Grammar | Description | Rust constant |
|
|
18
|
-
| --- | --- | --- |
|
|
19
|
-
| `toml` | TOML 1.1.0 | `LANGUAGE` |
|
|
20
|
-
|
|
21
16
|
## Development
|
|
22
17
|
|
|
23
|
-
Development
|
|
18
|
+
Development uses Node.js 24 or later.
|
|
24
19
|
|
|
25
20
|
```sh
|
|
26
21
|
npm install
|
package/package.json
CHANGED
package/src/parser.c
CHANGED
package/src/scanner.c
CHANGED
|
@@ -33,14 +33,13 @@ bool tree_sitter_toml_external_scanner_scan(
|
|
|
33
33
|
const bool *valid_symbols
|
|
34
34
|
) {
|
|
35
35
|
(void)payload;
|
|
36
|
-
|
|
37
|
-
if (
|
|
36
|
+
const int32_t quote = lexer->lookahead;
|
|
37
|
+
if (quote != '"' && quote != '\'') {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (lexer->lookahead != quote) {
|
|
40
|
+
// Error recovery marks both quote tokens valid; the delimiter selects one.
|
|
41
|
+
const enum TokenType symbol = quote == '"' ? MLB_QUOTE : MLL_QUOTE;
|
|
42
|
+
if (!valid_symbols[symbol]) {
|
|
44
43
|
return false;
|
|
45
44
|
}
|
|
46
45
|
lexer->advance(lexer, false);
|
package/test/bindings.test.rs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
use konomanoasa_tree_sitter_toml as grammar;
|
|
1
2
|
use tree_sitter::{Parser, Query};
|
|
2
|
-
use tree_sitter_toml as grammar;
|
|
3
3
|
|
|
4
4
|
#[test]
|
|
5
5
|
fn parses_valid_source() {
|
|
6
6
|
let source = "answer = 42\n";
|
|
7
|
+
let language = grammar::LANGUAGE.into();
|
|
7
8
|
let mut parser = Parser::new();
|
|
8
|
-
parser.set_language(&
|
|
9
|
+
parser.set_language(&language).unwrap();
|
|
9
10
|
let tree = parser.parse(source, None).unwrap();
|
|
10
11
|
let root = tree.root_node();
|
|
11
12
|
assert_eq!(root.kind(), "toml");
|
|
12
13
|
assert_eq!(root.byte_range(), 0..source.len());
|
|
13
14
|
assert!(!root.has_error());
|
|
15
|
+
assert!(grammar::NODE_TYPES.contains("\"toml\""));
|
|
16
|
+
Query::new(&language, grammar::HIGHLIGHTS_QUERY).unwrap();
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
#[test]
|
|
@@ -25,5 +28,4 @@ fn linked_scanner_preserves_quotes_in_multiline_strings() {
|
|
|
25
28
|
assert_eq!(root.byte_range(), 0..source.len());
|
|
26
29
|
assert!(!root.has_error(), "{source}");
|
|
27
30
|
}
|
|
28
|
-
Query::new(&language, grammar::HIGHLIGHTS_QUERY).unwrap();
|
|
29
31
|
}
|