lua-users home
lua-l archive

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


On 17 November 2017 at 08:46, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> A safe table navigator symbol would be a fun thing to implement too.
>
> What do you mean?

tbl?.subtbl?.field
--> meaning (tbl or {}).(subtbl or {}).field

Not (easily*) doable with ltokenp because tbl can be an arbitrarily
long expression:

foo[bar?.baz](arg).x?.bla
--> meaning (foo[(bar or {}).baz](arg).x or {}).bla

To deal with expressions, you need an AST, which is what Metalua provides.

(* technically it is doable with ltokenp because one would have to
essentially consume an arbitrary number of the tokens and build an
AST, but then you are just reimplementing a subset of Metalua)

-- Hisham