Skip to content

Commit

Permalink
some more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Oct 5, 2024
1 parent 489a74a commit d6945ba
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [1.56.0, stable]
rust: [1.70.0, stable]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
Expand Down
36 changes: 4 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,6 @@ assert_eq!(&doc.to_string(), node_str);
[`KdlDocument`], [`KdlNode`], [`KdlEntry`], and [`KdlIdentifier`] can all
be parsed and managed this way.

#### Query Engine

`kdl` includes a query engine for
[KQL](https://github.com/kdl-org/kdl/blob/main/QUERY-SPEC.md), which lets you
pick out nodes from a document using a CSS Selectors-style syntax.

Queries can be done from either a [`KdlDocument`] or a [`KdlNode`], with
mostly the same semantics.

```rust
use kdl::KdlDocument;

let doc = r#"
a {
b 1
c 2
d 3 {
e prop="hello"
}
}
"#.parse::<KdlDocument>().expect("failed to parse KDL");

let results = doc.query("a > b").expect("failed to parse query");
assert_eq!(results, Some(&doc.nodes()[0].children().unwrap().nodes()[0]));

let results = doc.query_get("e", "prop").expect("failed to parse query");
assert_eq!(results, Some(&"hello".into()));

let results = doc.query_get_all("a > []", 0).expect("failed to parse query").collect::<Vec<_>>();
assert_eq!(results, vec![&1.into(), &2.into(), &3.into()]);
```

### Error Reporting

[`KdlError`] implements [`miette::Diagnostic`] and can be used to display
Expand Down Expand Up @@ -154,6 +122,10 @@ means a few things:
you [`KdlDocument::fmt`] in which case the original representation will be
thrown away and the actual value will be used when serializing.

### Minimum Supported Rust Version

You must be at least `1.70.0` tall to get on this ride.

### License

The code in this repository is covered by [the Apache-2.0
Expand Down
70 changes: 37 additions & 33 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,39 +64,6 @@
//! [`KdlDocument`], [`KdlNode`], [`KdlEntry`], and [`KdlIdentifier`] can all
//! be parsed and managed this way.
//!

// ### Query Engine

// `kdl` includes a query engine for
// [KQL](https://github.com/kdl-org/kdl/blob/main/QUERY-SPEC.md), which lets you
// pick out nodes from a document using a CSS Selectors-style syntax.

// Queries can be done from either a [`KdlDocument`] or a [`KdlNode`], with
// mostly the same semantics.

// ```rust
// use kdl::KdlDocument;

// let doc = r#"
// a {
// b 1
// c 2
// d 3 {
// e prop="hello"
// }
// }
// "#.parse::<KdlDocument>().expect("failed to parse KDL");

// let results = doc.query("a > b").expect("failed to parse query");
// assert_eq!(results, Some(&doc.nodes()[0].children().unwrap().nodes()[0]));

// let results = doc.query_get("e", "prop").expect("failed to parse query");
// assert_eq!(results, Some(&"hello".into()));

// let results = doc.query_get_all("a > []", 0).expect("failed to parse query").collect::<Vec<_>>();
// assert_eq!(results, vec![&1.into(), &2.into(), &3.into()]);
// ```

//! ## Error Reporting
//!
//! [`KdlError`] implements [`miette::Diagnostic`] and can be used to display
Expand Down Expand Up @@ -153,11 +120,48 @@
//! you [`KdlDocument::fmt`] in which case the original representation will be
//! thrown away and the actual value will be used when serializing.
//!
//! ## Minimum Supported Rust Version
//!
//! You must be at least `1.70.0` tall to get on this ride.
//!
//! ## License
//!
//! The code in this repository is covered by [the Apache-2.0
//! License](LICENSE.md).

// TODO(@zkat): bring this back later.
// ### Query Engine

// `kdl` includes a query engine for
// [KQL](https://github.com/kdl-org/kdl/blob/main/QUERY-SPEC.md), which lets you
// pick out nodes from a document using a CSS Selectors-style syntax.

// Queries can be done from either a [`KdlDocument`] or a [`KdlNode`], with
// mostly the same semantics.

// ```rust
// use kdl::KdlDocument;

// let doc = r#"
// a {
// b 1
// c 2
// d 3 {
// e prop="hello"
// }
// }
// "#.parse::<KdlDocument>().expect("failed to parse KDL");

// let results = doc.query("a > b").expect("failed to parse query");
// assert_eq!(results, Some(&doc.nodes()[0].children().unwrap().nodes()[0]));

// let results = doc.query_get("e", "prop").expect("failed to parse query");
// assert_eq!(results, Some(&"hello".into()));

// let results = doc.query_get_all("a > []", 0).expect("failed to parse query").collect::<Vec<_>>();
// assert_eq!(results, vec![&1.into(), &2.into(), &3.into()]);
// ```

#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, rust_2018_idioms, unreachable_pub)]
// #![cfg_attr(test, deny(warnings))]
Expand Down
6 changes: 2 additions & 4 deletions src/v2_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ pub(crate) fn is_disallowed_ident_char(c: char) -> bool {
|| NEWLINES.iter().copied().collect::<String>().contains(c)
|| UNICODE_SPACES.iter().any(|us| us == &c)
|| is_disallowed_unicode(c)
|| EQUALS_SIGNS.iter().any(|eq| eq == &c)
|| c == '='
}

/// `identifier-char := unicode - unicode-space - newline - [\\/(){};\[\]"#] - disallowed-literal-code-points - equals-sign`
Expand All @@ -679,11 +679,9 @@ fn identifier_char(input: &mut Input<'_>) -> PResult<char> {
.parse_next(input)
}

static EQUALS_SIGNS: [char; 4] = ['=', '﹦', '=', '🟰'];

/// `equals-sign := See Table ([Equals Sign](#equals-sign))`
fn equals_sign(input: &mut Input<'_>) -> PResult<()> {
one_of(EQUALS_SIGNS).void().parse_next(input)
"=".void().parse_next(input)
}

/// ```text
Expand Down
1 change: 0 additions & 1 deletion tests/test_cases/expected_kdl/unicode_equals_signs.kdl

This file was deleted.

4 changes: 0 additions & 4 deletions tests/test_cases/input/unicode_equals_signs.kdl

This file was deleted.

0 comments on commit d6945ba

Please sign in to comment.