lua-users home
lua-l archive

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

2009/12/17 Luiz Henrique de Figueiredo <>:
>> After thinking more about what you want, I realize it would be easy to
>> implement using token filters. All you need is a filter that converts:
>>     for k,v in <expressions> do end
>> into:
>>     for k,v in __iter_handler( <expressions> ) do end
>> Of course the token filter is not trivial because it would have to
>> recognize the expression end, but that is a feature many token filters
>> need, so you may be able to find it already implemented.
> Other application do need to recognize expressions but in this case you
> you only need to issue "__iter_handler(" after "in" and ")" before "do".

But you have to distinguish which "do" belong to a generic for. And
you cannot assume it's the first one since the expression list may
contain function definition, with arbitrary code in there.