# Javascript to Lua translator
So... this is an experiment with making a full-blown Javascript to Lua translator, preserving semantics and so on.
It's a single-pass transpiler that directly generates Lua code from the Esprima AST, without any kind of IR.
Quick-and-dirty, cutting corners, etc etc - don't expect much of this code
Runs on vanilla LuaJIT, without any C modules or hacking the VM (e.g. Tessel runs on Lua, too, but on heavily modified runtime, which I didnt like)
Oh, and it probably can't bootstrap itself right now. Anyone willing to make it self-hosting? That would be cool
Results on ES5 test suite in 10 days:
Passed: 3659 Failed: 7753 Cannot Translate: 138 Skipped: 175 Total: 11725 Time: 1479.842
UPDATE: For more complete variants, see https://github.com/PaulBernier/castl. Also, https://github.com/Etiene/js2lua
Uses LuaJIT, esprima, lua-date, lpeglj, ta-regex, ast-hoist, esutils, escodegen
Tested under LuaJIT 2.1+ and node 0.10+.
Assumes LuaJIT binary at \bin\luajit\luajit
To run something: node run.js something.js
. After translation, you can also use luajit something.lua
to run translated code directly.
To run tests: node test\test.js test\sometestname.js
. It compares STDOUT of JS and Lua versions to decide if the test passed.
To run entire ES5 test suite: node test\test.js test\es5\**\*.js
(WARNING: Full suite takes over 20 minutes on fast, SSD-equipped machine!)
Some tests are blacklisted (grep for LUA_SKIP) because they cause infinite loop or do something similarly bad, they're marked as "skipped".
License: MIT
(c) 2015 Oleksandr Nikitin oleksandr@tvori.info
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。