lua-users home
lua-l archive

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


I've actually thought before that it would be useful to implement a JavaScript-to-Lua compiler and a supporting runtime library -- and this leads me to reconsider what I said this morning about how different the two languages are. The best starting point would probably be the compiler in JavaScript Strands (http://www.xucia.com/strands-doc/index.html), which is a project to retrofit coroutines onto JS. One could take large portions of the compiler from that project, write a code generator (also in JS) that emits Lua, then write a runtime library in Lua to implement some of the semantics of JS's built-in objects. Then use a command-line JS host program to run and debug the compiler until it successfully compiles itself into Lua. This JS-to-Lua compiler would itself be written in JS, which makes for a good (though partial) self-test.

Matt

David Given wrote:
I've actually thought that it would be very interesting to build a
Javascript interpreter *on Lua* --- use pure Lua code to translate the
Javascript into Lua, compile, and run. The two languages are similar
enough semantically that the mapping is probably quite easy.