@konomanoasa/tree-sitter-query 0.2.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 +1 -1
- package/README.md +1 -1
- package/grammar.js +33 -22
- package/package.json +6 -5
- package/src/grammar.json +179 -112
- package/src/node-types.json +1 -1
- package/src/parser.c +1859 -1727
- package/test/bindings.test.rs +34 -0
- package/tree-sitter.json +1 -1
package/test/bindings.test.rs
CHANGED
|
@@ -268,6 +268,19 @@ fn string_leaves_preserve_literal_bytes_and_escape_spelling() {
|
|
|
268
268
|
("\"", 9..10),
|
|
269
269
|
],
|
|
270
270
|
),
|
|
271
|
+
(
|
|
272
|
+
"\";x\0\"",
|
|
273
|
+
vec![("\"", 0..1), ("string_content", 1..4), ("\"", 4..5)],
|
|
274
|
+
),
|
|
275
|
+
(
|
|
276
|
+
"\"\\\n;x\0\"",
|
|
277
|
+
vec![
|
|
278
|
+
("\"", 0..1),
|
|
279
|
+
("escape_sequence", 1..3),
|
|
280
|
+
("string_content", 3..6),
|
|
281
|
+
("\"", 6..7),
|
|
282
|
+
],
|
|
283
|
+
),
|
|
271
284
|
(
|
|
272
285
|
"\"a\0b\0\0c\"",
|
|
273
286
|
vec![("\"", 0..1), ("string_content", 1..7), ("\"", 7..8)],
|
|
@@ -318,6 +331,27 @@ fn string_leaves_preserve_literal_bytes_and_escape_spelling() {
|
|
|
318
331
|
}
|
|
319
332
|
}
|
|
320
333
|
|
|
334
|
+
#[test]
|
|
335
|
+
fn string_newlines_cannot_skip_comments_before_nul() {
|
|
336
|
+
let language = grammar::LANGUAGE.into();
|
|
337
|
+
let mut parser = parser();
|
|
338
|
+
for (source, api_error) in [
|
|
339
|
+
("\"\n;x\0\"", QueryErrorKind::Syntax),
|
|
340
|
+
("(#custom? \"\n;x\0\")", QueryErrorKind::Syntax),
|
|
341
|
+
("(#custom! \"\n;x\0\")", QueryErrorKind::Syntax),
|
|
342
|
+
("(identifier/\"\n;x\0\")", QueryErrorKind::Structure),
|
|
343
|
+
] {
|
|
344
|
+
assert_eq!(
|
|
345
|
+
Query::new(&language, source).unwrap_err().kind,
|
|
346
|
+
api_error,
|
|
347
|
+
"{source:?}"
|
|
348
|
+
);
|
|
349
|
+
let tree = parser.parse(source, None).unwrap();
|
|
350
|
+
assert!(tree.root_node().has_error(), "{source:?}");
|
|
351
|
+
assert_eq!(tree.root_node().byte_range(), 0..source.len());
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
321
355
|
#[test]
|
|
322
356
|
fn carriage_returns_inside_comments_preserve_the_following_pattern() {
|
|
323
357
|
let language = grammar::LANGUAGE.into();
|