Closed oppiliappan closed 2 years ago
~Tests fail at the moment because expect.sh
was not run after #67 (I think?), I'll open a separate PR for that.~ Oops, I should be using UPDATE_TESTS=1
for this.
@nerdypepper SGTM, thanks :+1: . Just got a single question, after that it should be good to go :)
Thanks for the review, this should be fixed now, do let me know if I should squash these or if they will will be squashed directly during merge.
once
should not be removed. It is used to handle non-associative operators I think
It should be used to parse operators such as ==
, >=
, etc. which are not parsed correctly currently
@oberblastmeister according to https://nixos.org/manual/nix/stable/expressions/language-operators.html ==
/>=
are neither left nor right-associative. The proper solution would be to create for e.g. Or am I missing something? :) a == b == c
a node with a
/b
/c
being children of it, but I think that this is good-enough for now.
Yes, they are non-associative. The proper solution is to just not parse them, and have a parse error.
OK, I should've checked more closely how what Nix actually expects. First of all, this doesn't affect that PR IMHO, so we can merge this.
In fact, cargo run --example from-stdin <<< "a == b == c"
already gives a parse error as expected, namely error: unexpected token at 7..11
.
Yeah my bad, currently it parses it correctly. Also adding once
for left and right would be redundant, so removing it makes sense.
Port of @oberblastmeister's changes from #35, should hopefully fix #74. I haven't fully wrapped my head around the parser code, but I think the changes I have ported are correct as far as I have tested.
Summary & Motivation
An attempt to split changes from that #35 into more reviewable chunks.
Backwards-incompatible changes
Changes syntax trees generated for binary expressions using right-associative operators.
Further context
Previously, all operators were parsed as left associative, certain operators such as concat (
++
), merge (//
), and implication (->
) are now parsed as right associative: