lua-users home
lua-l archive

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

Hello, I have been thinking about writing a Lua to JavaScript translator. The main use case would simply be to provide an alternative language for the web. You would just have to run the translator before you use the script.

This would be different than the lua2js which already exists on LuaForge since I would want to make it work in all cases with the only restrictions being on what modules can be used. I think lua2js only does a superficial translation. For example, I don't think it handles using functions as an index into a table.

I do not have a goal of making the output readable. In fact I might purposely obfuscate the output to hinder reverse-engineering efforts of the translated code.

The approach that seems the easiest to me is to run the Lua source through luac.exe and use the output of luac as the input of the translator. This way I don't have to worry about lexing or parsing. I also could have a smaller range of inputs to worry about; there would only be the 38 types of instructions to translate. The down-side to this approach is that the format of the luac output could change significantly between versions.

Now for my questions:
Is this already being work on?
Can you think of any major problems that would prevent the approach described in the previous paragraph from working?
Can you think of a better approach?


P.S. I couldn't find a search feature for the mailing list archive; so sorry if this has already been discussed.