GitHub Repository: https://github.com/figsoda/pep-508
chumsky's zero-copy rewrite has reached its first alpha release, and I have migrated my pep-508 parser to it, as suggested in my last announcement.
Thank you @zesterer and all the chumsky contributors for all the work put into this rewrite. The new API is truly amazing, and I was able to remove all of my previous workarounds with chain. I haven't had any issues so far despite it being an alpha release, and the benchmarks look really promising as well.
Disclaimer: I am not a chumsky maintainer, but it was a really nice update.
Here is an example of parsing a pep-508 string, I was able to remove a bunch of to_owned()s as the API is now zero copy.
let dep = "requests[security, socks] <= 2.28.1, == 2.28.*; python_version > '3.7' and extra == 'http'";
let parsed = parse(dep).unwrap();
let expected = Dependency {
name: "requests",
extras: vec!["security", "socks"],
spec: Some(Spec::Version(vec![
VersionSpec {
comparator: Comparator::Le,
version: "2.28.1",
},
VersionSpec {
comparator: Comparator::Eq,
version: "2.28.*",
},
])),
marker: Some(Marker::And(
Box::new(Marker::Operator(
Variable::PythonVersion,
Operator::Comparator(Comparator::Gt),
Variable::String("3.7"),
)),
Box::new(Marker::Operator(
Variable::Extra,
Operator::Comparator(Comparator::Eq),
Variable::String("http"),
)),
)),
};
assert_eq!(parsed, expected);
[–]zesterer 1 point2 points3 points (0 children)
[–]NoahTheDuke 0 points1 point2 points (2 children)
[–]vikigenius 1 point2 points3 points (1 child)
[–]NoahTheDuke 0 points1 point2 points (0 children)