-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
add pipe operator #152
add pipe operator #152
Conversation
It's a good start, but this misses support for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I just know that Nix got new experimental operators. It may worth referencing the source PR NixOS/nix#11131
CI failure is unrelated and is already fixed on main
. A rebase should fix it.
@@ -160,7 +160,7 @@ pub(crate) fn highlight( | |||
HlTag::Operator(HlOperator::Comparison) | |||
} | |||
T![+] | T![-] | T![*] | T![/] => HlTag::Operator(HlOperator::Arithmetic), | |||
T![++] | T!["//"] => HlTag::Operator(HlOperator::Aggregation), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a collection operator. It may need another HlOperator
variant like Pipe
.
@@ -250,7 +250,7 @@ impl<'db> InferCtx<'db> { | |||
self.unify_var(lhs_ty, rhs_ty); | |||
lhs_ty | |||
} | |||
BinaryOpKind::Concat => { | |||
BinaryOpKind::Concat | BinaryOpKind::Pipe => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't unity arguments of pipe operators to be List.
They should follow the handling of Expr::Apply
with two arguments flipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't quite follow this, need an example... speaking of the other threads, i can make the changes and push them right away
that's quite dumb, but i have basically zero experience in parsers 💀
this PR (plus patches in tree-sitter-nix
, rnix-parser
and alejandra
) emerged from my need of using pipe operator w/o errors from the language server and with working formatter. then i showed all of this to friends and they kinda expected me to make PRs to the base repos 💀 💀 💀
btw i also opened a PR in tree-sitter-nix
, but considering the status quo of rnix-parser
and it being a dependency of alejandra
, i am totally unsure how to work this out 😭
sorry for this silly venting in this thread
@@ -113,6 +113,7 @@ def! { | |||
LT_EQ = [<=], | |||
MINUS_GT = [->], | |||
NOT_EQ = [!=], | |||
PIPE = [|>], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PIPE = [|>], | |
OR_GT = [|>], |
Here we name symbols syntactically, not semantically.
@@ -884,6 +884,7 @@ impl SyntaxKind { | |||
T![*] | | |||
T![/] => (17, 18), | |||
T![++] => (20, 19), | |||
T![|>] => (21, 22), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This precedence is incorrect. According to Nix, it should have a lower precedence than logic-imply ->
. So it should goes above to be (-1, 0)
, which underflows u8
... Unfortunately, we need to shift all other BP values up by +10
(for simplicity and more future proof), so |>
becomes (9, 10)
, ->
becomes (12, 11)
, and etc.
I hate to be that one that writes "any progress on this?", but I need to be that one |
before
after