4 ms·
> If you want "<" to be right associative, that's exactly one of the things that's easy to do with a Pratt parser, change the binding power on one side for the
by orthoxerox 3y ago
> If you want "<" to be right associative, that's exactly one of the things that's easy to do with a Pratt parser, change the binding power on one side for the "<".
It's not about associativity at all. "a < b < c" is a ternary operator that compares three operands.
- ReleaseCandidat 3y agoThat's what I would think too (as it doesn't make much sense to compare a boolean to c), but what OP wrote doesn't make much sense else: or if `a < b < c` is to be treated differently than `(a < b) < c`
- int_19h 3y agoOP is saying that you can write (a < b < c) in C and the likes, but it behaves as if ((a < b) < c), which is pretty much never what you want - hence why ternary and N-ary comparison operators like the Python one are desirable in the first place.