translating Lua 5.2 to 5.1 using Metalua

69 views
Skip to first unread message

David Manura

unread,
Nov 19, 2011, 3:50:55 PM11/19/11
to met...@googlegroups.com
With the upcoming Lua 5.2 release, I think a productive (and not too
difficult) application or demonstration of Metalua would be for it to
attempt as far as reasonably possible to translate Lua 5.2 source to
Lua 5.1 source.

goto's [2] may require the most thought but normally can be rewritten
in terms of breaks and control variables, especially with the
restrictions 5.2 places on it. Moreover, goto's are reported to be on
the TODO list for 5.1-based LuaJIT [3].

It might involve variants of mlp_lexer.lua to handle vanilla 5.1 and
5.2 syntax and likewise for the parser.

There will also need to be a runtime component as well, i.e. a version
of the 5.2 `_G` table that runs in 5.1.

Ultimately, a package searcher could be written to load a 5.2 module,
parse/compile it with Metalua, set it's environment to the 5.2 style
_G and run it (and hope it works).

[1] goto, hex and \* escapes, _ENV, hex floats, break in middle of
block, empty statement, etc.
[2] http://lua-users.org/wiki/GotoStatement
[3] http://lua-users.org/lists/lua-l/2011-10/msg00578.html

sylvanaar

unread,
Nov 20, 2011, 2:56:18 PM11/20/11
to metalua
Hello guys.

This is a really good suggestion. Just on its merits it might be a
well timed "killer-app". An obvious candidate user would be LuaRocks.

-Jon

Reply all
Reply to author
Forward
0 new messages