@konomanoasa/tree-sitter-toml 0.1.0 → 0.3.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 +23 -0
- package/README.md +11 -2
- package/bindings/rust/build.rs +23 -0
- package/bindings/rust/lib.rs +12 -0
- package/grammar.js +29 -7
- package/package.json +6 -2
- package/src/grammar.json +351 -64
- package/src/node-types.json +5 -4
- package/src/parser.c +5532 -4141
- package/src/scanner.c +1 -1
- package/test/bindings.test.rs +29 -0
- package/tree-sitter.json +2 -2
package/src/scanner.c
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
use tree_sitter::{Parser, Query};
|
|
2
|
+
use tree_sitter_toml as grammar;
|
|
3
|
+
|
|
4
|
+
#[test]
|
|
5
|
+
fn parses_valid_source() {
|
|
6
|
+
let source = "answer = 42\n";
|
|
7
|
+
let mut parser = Parser::new();
|
|
8
|
+
parser.set_language(&grammar::LANGUAGE.into()).unwrap();
|
|
9
|
+
let tree = parser.parse(source, None).unwrap();
|
|
10
|
+
let root = tree.root_node();
|
|
11
|
+
assert_eq!(root.kind(), "toml");
|
|
12
|
+
assert_eq!(root.byte_range(), 0..source.len());
|
|
13
|
+
assert!(!root.has_error());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[test]
|
|
17
|
+
fn linked_scanner_preserves_quotes_in_multiline_strings() {
|
|
18
|
+
let language = grammar::LANGUAGE.into();
|
|
19
|
+
let mut parser = Parser::new();
|
|
20
|
+
parser.set_language(&language).unwrap();
|
|
21
|
+
for source in ["a = \"\"\"one\"two\"\"\"\n", "a = '''one'two'''\n"] {
|
|
22
|
+
let tree = parser.parse(source, None).unwrap();
|
|
23
|
+
let root = tree.root_node();
|
|
24
|
+
assert_eq!(root.kind(), "toml");
|
|
25
|
+
assert_eq!(root.byte_range(), 0..source.len());
|
|
26
|
+
assert!(!root.has_error(), "{source}");
|
|
27
|
+
}
|
|
28
|
+
Query::new(&language, grammar::HIGHLIGHTS_QUERY).unwrap();
|
|
29
|
+
}
|
package/tree-sitter.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"metadata": {
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.3.0",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"description": "Tree-sitter grammar for TOML.",
|
|
18
18
|
"links": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"go": false,
|
|
25
25
|
"node": false,
|
|
26
26
|
"python": false,
|
|
27
|
-
"rust":
|
|
27
|
+
"rust": true,
|
|
28
28
|
"swift": false
|
|
29
29
|
}
|
|
30
30
|
}
|