[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Transform (cond ? then : else) to ifthenelse(cond, then, else) with lpeg
- From: Christophe Jorssen <jorssen.leraincy@...>
- Date: Tue, 21 Feb 2012 11:56:45 +0100
2012/2/21 Christophe Jorssen <jorssen.leraincy@free.fr>:
>> local grammar = lpeg.P{ "E",
>> E = ((var + G) * (lpeg.P"?" * E * lpeg.P":" * E)^-1) / tr,
>> G = lpeg.P"(" * E * lpeg.P")",
>> }
>
> So this is done without captures (I mean without lpeg.C*). I
> misunderstood the manual thinking the patt in 'patt / function' was
> necessarily a capture (since a capture is a pattern and it is
> documented in the capture section).
>
> One thing I do not understand is how function tr is fed by the parser
> without captures? For example, why "?" or ":" do not end up as
> arguments given to tr?
>
Sorry... I think I understood this part. I missed the capture in
local var = lpeg.C(lpeg.alpha * (lpeg.alnum^0))
Thanks
--
Christophe