-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: Auto-detect whether to use complete/streaming parser #28
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 3688759797
💛 - Coveralls |
epage
changed the title
feat: Auto-detect whether to use complete/streaming parser
WIP: feat: Auto-detect whether to use complete/streaming parser
Nov 30, 2022
epage
force-pushed
the
port
branch
6 times, most recently
from
December 6, 2022 21:19
eda142c
to
26bd98f
Compare
epage
force-pushed
the
port
branch
2 times, most recently
from
December 9, 2022 18:46
d240a9f
to
bb6b08c
Compare
This will allow wrapping the `Input` with types to carry more metadata while still getting the needed output type.
BREAKING CHANGE: Some parsers added a new trait bound: `Input: IntoOutput`
Features - Conversions between methods - Able to impl for one or the other mode - Able to impl for both modes with specialization
Considering streaming parsers will need to deconstruct the error anyways, we shouldn't be offering them an easy path that can make them miss a case except when their testing is sufficient.
These were more entangled, so I didn't bother to do them by type.
epage
force-pushed
the
port
branch
2 times, most recently
from
December 13, 2022 18:58
f790be8
to
39741a7
Compare
Before, `length_data` and `length_value` were streaming-only (without advertising it). This now uses `InputIsStreaming` to specialize the implementation. `IntoOutput::from_output` reads weird but its good enough for now. I could see running into issues with this with recoverable errors but the case we are using it atm doesn't care about them.
epage
changed the title
WIP: feat: Auto-detect whether to use complete/streaming parser
feat: Auto-detect whether to use complete/streaming parser
Dec 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously in #6, I was transitioning parsers from returning
FnMut(I) -> IResult<I, O, E>
to structs that implementParser
so we could implement two unique parse traits, one for complete and one for streaming parsing. That ran into a series of problems, including not-as-great type inference.This PR takes a different approach by making the type of parser a property of the
Input
, using const-generics. We can then specialize the implementation based on aconst STREAMING: bool
.Potential downsides
Streaming<T>
typenom::bytes
, I automatically convert to theComplete
type but that might not always be the most accurate.recognize
, can't be specialized without adding a new trait boundInputIsStreaming::Complete
for something unrelated toComplete
vsStreaming
and to use that trait in non-specialized placesSteps
Streaming
documentation is sufficientlength_data
)Constrainnom::combinator::complete
to streaming (move to trait, deprecating old version?)length_value
,complete
can be useful inInputIsStreaming
agnostic code.Fixes rust-bakery/nom#1535