peggyjs / peggy

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

Documentation misleadings #450

Closed Bot12313 closed 6 months ago

Bot12313 commented 8 months ago

Problem

Some examples in the documentation seems either outdated, incorrect, or impossible to reproduce in online version on Peggy.

& { predicate }

The example appears to be working fine but is impossible to reproduce the results in the online version.

Even after adding the "match" label, it still produces error.

@ ( label : )? expression

Unable to use the "matches" examples noted below.

Bot12313 commented 8 months ago

& { predicate }

It appears that everything is now being returned as a list, so it needs to be converted back into a string to work with it.

hildjj commented 8 months ago

The posPredicate one should read:

posPredicate = @match:$[0-9]+ &{return parseInt(match, 10) < 100}

note the $. This returns "23" but fails on "233". The @ is so that the predicate doesn't return a confusing null.

The second one needs a better default input of "aaa bbbb" or something.

Valid issue, willfix.