peggyjs / peggy

Peggy: Parser generator for JavaScript
https://peggyjs.org/
MIT License
914 stars 65 forks source link

[docs] Parens create a pluck context #398

Closed hildjj closed 1 year ago

hildjj commented 1 year ago

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 commented 1 year ago

Parens also create a location() context.

hildjj commented 1 year ago

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

reverofevil commented 1 year ago

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 commented 1 year ago

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

hildjj commented 1 year ago

It was 1.1: https://github.com/peggyjs/peggy/blob/dfca04cf000d9be3d8f4a99314ccbedef744db33/CHANGELOG.md?plain=1#L371

reverofevil commented 1 year ago

Thanks!

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

hildjj commented 1 year ago

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. :)