Closed rmehri01 closed 1 year ago
Hmm, interesting one. I would say that pratt parsing probably isn't cut out for this sort of thing due to the way binding power allows the parser to 'slide' between operator levels and hence requires atoms to have a homogeneous type (so you can't, say, build up one specific operator as a list instead of a tree).
If you chose to not use pratt parsing, the following should work:
enum Expr {
...
Eq(Vec<Expr>),
...
}
atom
.separated_by(eq_op)
.at_least(1)
.collect::<Vec<_>>()
.map(|terms| Expr::Eq(terms))
Ah okay, that makes sense, thanks!
Hey there, thanks for this crate, it's really nice to work with :)
I was wondering if it's possible to parse non-associative operators with the pratt parsing feature, for example to turn
x == y == z
intox == y && y == z
or have a parse error instead?