Conversation
There was a problem hiding this comment.
clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Pull Request Test Coverage Report for Build 16239183961Details
💛 - Coveralls |
|
Could you clean up the commit history, per our CONTRIBUTING.md? |
There was a problem hiding this comment.
I'd probably name that c_expr, rather than pratt. Trying to decide how it should show up in our docs, maybe a sub-page if Languages but have Arithmetic cross-link to it?
There was a problem hiding this comment.
We should include the example from #622
I'm on vacation and haven't had much time to look at this code, but I started porting the example to the new API. If it helps: https://github.com/ssmendon/winnow/blob/devel-pratt/examples/pratt/parser.rs#L72-L163
All commits: https://github.com/ssmendon/winnow/commits/devel-pratt
Some notes:
- Needed to make
Prefix's fields public to use the API in ssmendon@1d5454e
|
CC @39555 |
d0629db to
bb9a5d4
Compare
|
|
||
| /// Set the precedence level for the current expression | ||
| #[inline(always)] | ||
| pub fn current_precedence_level( |
There was a problem hiding this comment.
Probably we could drop current_.
Closes winnow-rs#131 Implementation history in winnow-rs#614
| #[doc(alias = "shunting_yard")] | ||
| #[doc(alias = "precedence_climbing")] | ||
| #[inline(always)] | ||
| pub fn expression<I, ParseOperand, O, E>( |
There was a problem hiding this comment.
shall we pub use the main function in the parent module as the rest of the functions?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #798 +/- ##
==========================================
+ Coverage 46.72% 47.42% +0.70%
==========================================
Files 26 27 +1
Lines 3416 3519 +103
==========================================
+ Hits 1596 1669 +73
- Misses 1820 1850 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| impl<I: Stream, O, E: ParserError<I>> Parser<I, Postfix<I, O, E>, E> | ||
| for (i64, fn(&mut I, O) -> Result<O, E>) | ||
| { | ||
| #[inline(always)] | ||
| fn parse_next(&mut self, input: &mut I) -> Result<Postfix<I, O, E>, E> { | ||
| empty.value(Postfix(self.0, self.1)).parse_next(input) | ||
| } | ||
| } |
There was a problem hiding this comment.
Question for @39555.
I think you meant to implement this for Postfix instead of for the tuple? Like this:
impl<I: Stream, O, E: ParserError<I>> Parser<I, Postfix<I, O, E>, E> for Postfix<I, O, E> {
#[inline(always)]
fn parse_next(&mut self, input: &mut I) -> Result<Postfix<I, O, E>, E> {
empty.value(self.clone()).parse_next(input)
}
}I noticed this while porting the example in #622 to my own fork: https://github.com/ssmendon/winnow/blob/pratt-parsing/examples/c_expression/parser.rs
Specifically, I noticed this syntax doesn't work due to unsatisfied trait bounds:
dispatch! {take(2usize);
"++" => Postfix(20, |_: &mut _, a| Ok(Expr::PostIncr(Box::new(a)))),
"--" => Postfix(20, |_: &mut _, a| Ok(Expr::PostDecr(Box::new(a)))),
_ => fail,
},Notes:
- You can't implement the original trait outside of
winnowdue to trait orphan rules. - The example inside of
crate::combinator::expressiondoesn't use any Postfix rules, but it is in the example (e.g.cargo test -F unstable-doc,std --all).
|
I added my own PR in #804, which tries to address some of the review comments attached to this. I did not really look at the code in this PR, so I don't know in what ways our implementation is different (if at all). |
|
Let me close this in favor of #804 then. |
Rebase of #614
Closes #131
I guess porting what we have in #620 could happen later or within this PR.