Skip to content

Conversation

@WindSoilder
Copy link
Contributor

@WindSoilder WindSoilder commented Apr 9, 2025

Closes: #37

This pr introduces a new AstNode::Pipeline variant. When parsing block, it may run into pipeline_or_expression_or_assignment which may return Pipeline/Expression/Assignment. And it enables let and mut using pipelines, so the following is possible:

let x = 3 | 4
mut y = 5 | 6
$y = 7 | 8 | 9

Changes in detail

  • In math_expression, change rhs from expression to pipeline_or_expression, so $y = 7 | 8 | 9 is available, it also returns MathExpressionNode, so it can be used easier in pipeline_or_expression_or_assignment.
  • In let_statement, mut_statement, change initializer to pipeline_or_expression, so let x = 7 | 8, mut y = 5 | 6 is available
  • The core logic lays inside pipeline_or_expression, in detail, if it get the first expression, and it failed to read a pipe, then it returns an Expression node, or else it will consume pipes and return an Pipeline node.

@WindSoilder WindSoilder requested a review from kubouch April 10, 2025 00:55
@kubouch
Copy link
Contributor

kubouch commented Apr 15, 2025

I think it's a good start, just a few small things but we can merge it otherwise.

I actually started working on this but never finished it, it's on my pipeline branch of my fork: https://github.com/kubouch/new-nu-parser/tree/pipeline. There I went a bit further and started implementing also the redirections. Also I added there a Sentence enum that contains either a pipeline, or a statement, not sure if that's the best way. If you happen to work on it, you can take my code, but let me know, otherwise I might attempt to finish it at some point :-).

@WindSoilder
Copy link
Contributor Author

Thanks! I'll look what you have done before :-)
Also I update the github ci to use ubuntu-22.04, because ubuntu-20.04 is going to be removed.

@kubouch
Copy link
Contributor

kubouch commented Apr 17, 2025

OK, looks good. Can you put the CI change to a separate PR? Could be even 24.04.

@kubouch kubouch merged commit c736b7e into nushell:main May 1, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pipelines and pipeline elements

2 participants