lua-users home
lua-l archive

Re: Transform (cond ? then : else) to ifthenelse(cond, then, else) with lpeg

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /