Skip to content
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

[docs] Parens create a pluck context #398

Closed
hildjj opened this issue Mar 28, 2023 · 7 comments
Closed

[docs] Parens create a pluck context #398

hildjj opened this issue Mar 28, 2023 · 7 comments

Comments

@hildjj
Copy link
Contributor

hildjj commented Mar 28, 2023

It's not clear from the docs that this is legal:

foo = "a" b:(@"c" "d") { return 2 }

because the parens create a new context for returns. Same with the old way:

foo = "a" b:(first:"c" "d" { return first })
@hildjj
Copy link
Contributor Author

hildjj commented Mar 30, 2023

Parens also create a location() context.

hildjj added a commit to hildjj/peggy that referenced this issue Apr 6, 2023
@hildjj
Copy link
Contributor Author

hildjj commented Apr 6, 2023

I figured I'd fix 398 while I was in there.

@reverofevil
Copy link

Oh, BTW, do you remember when it was introduced? I remember at least old versions of PEG.js didn't have this kind of scoping.

@hildjj
Copy link
Contributor Author

hildjj commented Apr 7, 2023

Probably in 2.0. It's been in for a while, but definitely after we forked.

@hildjj
Copy link
Contributor Author

hildjj commented Apr 7, 2023

It was 1.1:

- Back-ported value plucking with `@` from pegjs head. If your rule has a simple action that returns one or more of the values matched by the rule, you can instead mark those expressions with `@` and not need an action. This works inside of parens as well. [@hildjj](https://github.com/peggyjs/peggy/pull/89)

@reverofevil
Copy link

Thanks!

It was one of the larger improvements to DX, but I didn't know it happened after the fork.

@hildjj hildjj closed this as completed in 76b4e87 Apr 7, 2023
@hildjj
Copy link
Contributor Author

hildjj commented Apr 8, 2023

It was technically after the fork, because we forked from the last-known-good spot, then the plucks were back-ported from head -- because that was the feature I wanted to be released enough to want the fork. :)

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

No branches or pull requests

2 participants