[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lpeg Cg question
- From: Pierre-Yves Gérardy <pygy79@...>
- Date: Wed, 14 May 2014 02:16:22 +0200
On Tue, May 13, 2014 at 10:16 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> ...because the manual[1] says:
>
> An anonymous group serves to join values from several captures
> into a single capture.
>
>
>
> What am I missing?
It concerns LPeg's own representation of captures. Groups are
flattened when returned.
For example, in a folding capture, groups are treated as a single
capture, and the callbacks receives all sub-captures as arguments.
There are also some inconsistencies in how other captures handle groups:
(Cg(C(1) * C(1)) * Cg(C(1) * C(1)) / 2):match"abcd" --> b
(Cg(C(1) * C(1)) * Cg(C(1) * C(1)) / "%2"):match"abcd" --> c
`/2` takes the second production of the capture stream, whereas
`/"%2"` takes the value of the second group, truncated to one value.
—Pierre-Yves