lua-users home
lua-l archive

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


> 1.  Is there a better way to do a query language over a set of tables

Use setfenv to set the environment of the function returned by loadstring
to the table you want to query. Do that for each table.

> 2.  If not is there a easy way in lua to transform the query string
> (timeZone == "EST") or ( timeZone == "PST")
> 
> to
> { ts.entry.timeZone == "EST") or ( ts.entry.timeZone == "PST")

You could do it easily with token filters, but I think the soltion above is
simpler and more powerful.

If your queries involve actual Lua globals, such as say math.sqrt, then you 
need to set __index methods for your tables to _G.
--lhf