[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lpeg.C() drops named captures. Is there a workaround for that?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 30 Aug 2023 10:08:49 -0300
> [...]
> So: I understand what is happening, and why it happens... but is there
> a workaround? Is it possible to replace the :C():Cg"c" in
>
> pabc = (P"(%" * pa * pb * P")"):C():Cg"c":Ct()
>
> by something else, that would put the substring matched by the
>
> P"(%" * pa * pb * P")"
>
> into the key "c" without dropping the named captures generated by pa
> and pb?
I myself tend to use named captures nested in table captures only for
very simple tasks. For anything more complex I prefer to use unamed
captures nested in function captures: The function then creates the
table with the proper fields.
-- Roberto