fake
fake是一款轻量级的嵌入式脚本语言, 使用c++语言编写, 语法吸取自lua、golang、erlang, 基于flex、bison生成语法树, 编译成字节码解释执行。
脚本特性
- 运行环境linux amd64、MacOS amd64
- 支持VM, JIT(实验性质)
- 支持fake testfunc(param1)产生routine, 在单线程上实现多线程效果(此特性不支持JIT)
- 支持调试, 自带gdb风格的命令行调试器, 以及VS风格的可视化编辑调试ide, 也可在C里直接通过接口调用, 开始命令行调试
- 支持热更新
- 支持C风格函数和C++类成员函数的绑定
- 支持profile, 可获取脚本各个函数运行时间
- 支持array, map, 可以无限嵌套
- 支持多返回值
- 支持Int64
- 支持const定义
- 支持包
- 支持struct
- 支持打包bin文件或可执行文件
示例
-- 当前包名package mypackage.test-- 引入的文件include "common.fk"-- 结构体定义struct teststructsample_asample_bsample_cend-- 常量值const hellostring = "hello"const helloint = 1234const hellomap = {1 : "a" 2 : "b" 3 : [1 2 3]}-- func1 commentfunc myfunc1(arg1, arg2)-- C函数和类成员函数的调用arg3 := cfunc1(helloint) + arg2:memfunc1(arg1)-- 分支if arg1 < arg2 then-- 创建一个协程fake myfunc2(arg1, arg2)elseif arg1 == arg2 thenprint("elseif")elseprint("else")end-- for循环for var i = 0, i < arg2, i++ thenprint("i =