3 Star 0 Fork 0

agent.zy / def

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

def 条件编译处理工具

项目介绍

这是一个编程语言无关的条件编译插件。 首先你要确认的是你的代码需要使用条件编译,或者有多种模态发布到不同平台的限制。这个工具本质是和任何语言无关,你可以在你的代码里 免费使用。

安装教程

下载以后解压到系统的/bin目录下,或者在PATH里指定路径。

使用说明

1 宏注释

{% if  SCRIPT  == "lua" then %}
     return exports.GetValueByType (eax.value);
{% end %}

{% if  SCRIPT  == "neko" then %}
     return exports.GetValueByType (eax.value);
{% end %}


{% if  SCRIPT  == "c" then %}
     return exports.GetValueByType (eax.value);
{% end %}

使用方式

lua def.lua 输入文件 输出文件 SCRIPT=lua DEBUG=1

2 inline macro

{-inline_listense-}

Copyright (c) 2018 agent.zy@aliyun.com

{-inline_listense-}

在代码中内联该语法会将不同的inline macro 输出到指定位置

3 函数定义

 {%   
    local lua_member_call    ="{{item}}:{{item1}}({{item2}})"
    local lua_string_add_val ="\"{{item}}\" .. {{item2}}"
    local lua_string_add_string ="\"{{item}}\" + \"{{item2}}\""
 %}

4 内联函数

{-inline_max-}
function  max (a, b) {
return a>b;
}
{-inline_max-}

如何使用我们定义的内联函数

{blocks.inline_max}

5 替换模式

{% 
local string_macro ="\"{{item}}\""
%}
{* MACRO(string_macro)(context) *}
{* MACRO(string_macro){ item = "string-macro-context" } *}

例子 :

{-inline_esprima_parse-}
    var options = {
        attachComment: false,
        range: false,
        loc: false,
        sourceType: "script",
        tolerant: true
    };
            
    options.tokens = false;
    var result = exports.esprima.parse(buff, options);
    
{-inline_esprima_parse-}

/////
/////  生成code 
/////
{-inline_generate_code-}
 exports.lexerGenerateCode(result);
{-inline_generate_code-}


////
////   生成字节码
////

{-inline_generate_mid-}
 exports.lexerGenerateMidCode(result);
{-inline_generate_mid-}



{% if  SCRIPT  == "lua" then %}
exports.Main = function (buff) {
    {% if  DEBUG  then %}
        console.log("lua mode.")
    {% end %}
    ///生成ast解析
    {*blocks.inline_esprima_parse*} 
    ///生成code
    {*blocks.inline_generate_code*}       
}
{% end %}


{% if  SCRIPT  == "c" then %}
exports.Main = function (str) {
    {% if  DEBUG  then %}
        console.log("c mode.")
    {% end %}
    {*blocks.inline_esprima_parse*}
    {*blocks.inline_generate_code*} 
}
{% end %}
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.

简介

这是一个编程语言无关的条件编译插件。 首先你要确认的是你的代码需要使用条件编译,或者有多种模态发布到不同平台的限制 展开 收起
Lua
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助