Skip to content

Commit

Permalink
Merge pull request #1670 from DanielXMoore/yield-star-pipe
Browse files Browse the repository at this point in the history
`yield*` in pipeline
  • Loading branch information
edemaine authored Jan 5, 2025
2 parents f5a7224 + c07f970 commit 3514f86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion civet.dev/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ Use `as T` to cast types in your pipeline:
data |> JSON.parse |> as MyRecord |> addRecord
</Playground>
Use `await`, `throw`, `yield`, or `return` in your pipeline:
Use `await`, `throw`, `yield`, `yield*`, or `return` in your pipeline:
<Playground>
fetch url |> await
Expand Down
4 changes: 3 additions & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,9 @@ PipelineHeadItem
OptimizedParenthesizedExpression

PipelineTailItem
( AwaitOp / Yield / Return / Throw ) !AccessStart !MaybeParenNestedExpression -> $1
( AwaitOp / Return / Throw ) !AccessStart !MaybeParenNestedExpression -> $1
$( Yield ( _? Star )? ) !AccessStart !MaybeParenNestedExpression ->
return { $loc, token: $1, type: "Yield" }
"import" !AccessStart ->
return {
type: "Identifier",
Expand Down
14 changes: 14 additions & 0 deletions test/pipe.civet
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ describe "pipe", ->
}
"""

testCase """
yield in pipeline
---
[x, y]
|> .map (+ 1)
|> yield*
---
yield*([x, y].map((a => a+ 1)))
""", wrapper: """
function* f() {
CODE
}
"""

testCase """
throw statement in pipeline
---
Expand Down

0 comments on commit 3514f86

Please sign in to comment.