lua-users home
lua-l archive

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


On Sat, Nov 5, 2011 at 16:26, Maximilian Herkender
<static@brokenfunction.com> wrote:
> Hi, I wanted to share a Lua-related experiment I've written.
> https://github.com/mherkender/lua2js-experiment
> Basically, it converts a single Lua script into a Javascript equivalent.
> It works by parsing normal Lua code and wrapping pretty much every Lua
> operation around a function to maintain compatibility, and using Javascript
> constructs wherever possible, the result being a pretty fast Javascript
> version of a Lua script. It seems like there's only a handful of Lua
> features that seem to be completely incompatible with this style of
> translation.
>
> Still, this is better used as a proof-of-concept rather than a legitimate
> tool. I didn't plan much in advance so it's only clear to me now that it
> should've been written in Javascript instead of Python, which makes this
> something of a dead end. Since it works for what I've been using it for, and
> I'm having trouble finding an equivalent to ply for Javascript, I decided to
> put it up online for now in case anyone would like to check it out.
> -Max

I've been curious about the possibility of this for a while. It sounds
like yours even goes as far as to provide JS equivalents of Lua's
standard functions? I had envisioned a tool that would mainly just
translate Lua to Javascript at the syntax level, so you could write
things like:
local form = document.getElementById('myform')
if foo then form:submit() else doSomethingWith(form) end
and just pretend the browser understood that by translating it to
Javascript syntax.

-- 
Sent from my toaster.