7 Star 18 Fork 2

agent.zy / apolloxlua

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

项目介绍 star

apolloxlua 目前支持javascript到lua的翻译。可以在openresty和luajit里使用。这个工具分为两种模式, 一种是web模式,可以通过网页使用。另> 这里输入引用文本外一种是tool模式, 通常作为大规模翻译文件的工具使用。 agent.zy 于 18.07.21 晚

特色

  1. 支持switch case 语句
  2. 支持trycatch 语句
  3. 可以自定义语法和后端实现
  4. 无缝对接lua标准库和三方库
  5. 支持array 和 数学库
  6. 支持面向对象开发 OOP
  7. 支持macro宏预处理
  8. 支持面向切面开发 AOP

代码示例:

//[NameSpace("core")] 
class Person{
    hellow(){
         console.log("base Person")
		 console.log(this.age)
    }
	
	setAge(v) {
		this.age = v;
	}
	
	static staticSmethod (...args) {
		 console.log(args[1], args[2]);
		 console.log("i am static method");
	}
}
 
class Person2 extends Person{
	Person2 (name) {
		this.name = name;
		console.log("constructor..");
	}
	
    hellow(){
        console.log("override ");
		console.log("name=" + this.name + ",age=" + this.age);
    }
}

var p1 = Person  >>> New();
var p2 = Person2 >>> New("agent.zy");

p1 >>> setAge(10);
p2 >>> setAge(20);

p1 >>> hellow();
p2 >>> hellow();

如何扩展语法?

1可以使用luajit的ffi或swig扩展你的服务器。在语法分析里添加相应的标准库。 2可以集成现有的lua库,包括但不限于resty*和nginx-lua-*。 3可以通过本工具的js语法,实现库的自举。

示例

控制台示例

项目预览

安装

下载后解压到你的目录, 通过控制台找到项目目录

生成web模式的js文件 make web

生成工具模式的js文件 make tool

生成两种模式文件 make all

##使用方式:

web模式 : 在apolloxlua.js载入浏览器后使用一个全局的包装叫apolloxLua的变量包含一个parse的方法, 接受一个js代码串,返回lua代码串。 tool模式: 使用的方式 node apolloxlua 输入文件 输出文件

The MIT License (MIT) Copyright (c) 2018 钟元大老爷 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

这是一个把javascript翻译成lua的工具。这个工具是基于宿主的解决方案,最终目标是lua脚本和平台无关,只要宿主程序支持lua,你就可以在你的代码里使用 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/dingluo_wangdh/apolloxlua.git
git@gitee.com:dingluo_wangdh/apolloxlua.git
dingluo_wangdh
apolloxlua
apolloxlua
master

搜索帮助