• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

wizzard0/js2lua: Javascript to Lua translator

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

wizzard0/js2lua

开源软件地址(OpenSource Url):

https://github.com/wizzard0/js2lua

开源编程语言(OpenSource Language):

JavaScript 96.1%

开源软件介绍(OpenSource Introduction):

Javascript to Lua translator

Hey, I heard Javascript was made in 10 days!

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 :) For example, each ternary expression (?:) generates 4 function calls and a closure - too lazy to implement anything more clever :)

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

Requirements and usage

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 [email protected]




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap