-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for zero-copy parsing #82
Conversation
I want to experience this function but the following error is reported, how should I solve it? error[E0309]: the parameter type `S` may not live long enough
--> src\input.rs:233:64
|
233 | ... E: Error<I::Token>, S, P: Parser<'a, I, E, S> + ?Sized>(parser: &P, inp: &mut InputRef<'a, '_, I, S>) -> PResult<Self, P::Output, E> {
| - ^^^^^^^^^^^^^^^^^^^ ...so that the type `S` will meet its required lifetime bounds...
| |
| help: consider adding an explicit lifetime bound...: `S: 'a`
|
note: ...that is required by this bound
--> src\input.rs:238:69
|
238 | pub trait Parser<'a, I: Input + ?Sized, E: Error<I::Token> = (), S: 'a = ()> {
| ^^
error: missing required bound on `Iter`
--> src\input.rs:402:5
|
402 | type Iter<'a>: Iterator<Item = T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| help: add the required where clause: `where Self: 'a`
|
= note: this bound is currently required to ensure that impls have maximum flexibility
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information |
@oovm Hey, I've just pushed up some fixes. It seems like I was working against an older nightly when developing this. You can use Obviously, please be aware that this is very early work, is missing a lot of combinators, and is likely going to be changing a lot before being merged. It's definitely not much more than an experiment right now, and I've only implemented the features required for the |
[zero-copy] `Repeated::at_most`, `separated_by`, `padded_by`
[zero-copy] Re-add `no_std` support, add `separated_by_exactly`, and a few primitives
[zero-copy] Add `rewind` and `then_with` combinators
Use IterParser for foldl/foldr
Remove lazy-by-default
Add Stream input
Reimplemented alt error prioritisation, added more recovery strategies
Select ref
Added support for spanned inputs
Removed old chumsky code
Currently, only some initial experiments outside of the main codebase.
The new design departs quite a lot from
master
, to the point that it's likely to end up being a near-complete rewrite of the crate. However, benchmarks so far are promising!These benchmarks have a few caveats:
serde_json
is not quite comparable because it's not performing zero-copy parsing: the finalJsonValue
containsString
.pest
is not quite comparable because it does not support parsing byte strings: it's parsing a version of the input that's been run throughstd::str::from_utf8
Regardless, the benchmark demonstrates well the substantial performance improvement over
master
(oldchumsky
has been included at the bottom as a point of comparison).Along with support for zero-copy parsing, this new design also permits the following:
Unfortunately, the code requires GATs, a feature that is currently unstable (but might not be for much longer!).
then_with
.parse(..)
to.then_ignore(end())
, addskip_all()
combinator so the old behaviour can be opted into with.then_ignore(skip_all())
Closes #9