forked from esrrhs/fake
-
Notifications
You must be signed in to change notification settings - Fork 0
script like lua
License
zhangf911/fakescript
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# fakescript # fakescript是一款轻量级的嵌入式脚本语言,使用c++语言编写,语法吸取自lua、golang、erlang,基于flex、bison生成语法树,编译成字节码解释执行。与lua相比,运行速度不相上下,更易使用,源代码可读性更强 脚本特性: @.语法类似lua @.全部为函数 @.支持array,map,可以无限嵌套 @.支持fake testfunc(param1)产生routine,实现假多线程效果 @.支持C函数和类成员函数的绑定 @.自带解释器,JIT部分支持 @.支持多返回值 @.自带profile,可获取脚本各个函数运行时间 @.支持热更新 @.支持Int64 @.支持const定义 @.支持包 @.支持struct 示例: -- 当前包名 package mypackage.test -- 引入的文件 include "common.fk" -- 结构体定义 struct teststruct sample_a sample_b sample_c end -- 常量值 const hellostring = "hello" const helloint = 1234 -- func1 comment func myfunc1(arg1, arg2) -- C函数和类成员函数的调用 arg3 := cfunc1(helloint) + arg2:memfunc1(arg1) -- 分支 if arg1 < arg2 then -- 创建一个协程 fake myfunc2(arg1, arg2) elseif arg1 == arg2 then print("elseif") else print("else") end -- for循环 for var i = 0, i < arg2, i++ then print("i = ", i) end -- 数组 var a = array() a[1] = 3 -- 集合 var b = map() b[a] = 1 b[1] = a -- Int64 var uid = 1241515236123614u log("uid = ", uid) -- 子函数调用 var ret1, var ret2 = myfunc2() -- 其他包的函数调用 ret1 = otherpackage.test.myfunc1(arg1, arg2) -- 结构体 var tt = teststruct() tt->sample_a = 1 tt->sample_b = teststruct() tt->sample_b->sample_a = 10 -- 分支 switch arg1 case 1 then print("1") case "a" then print("a") default print("default") end -- 多返回值 return arg1, arg3 end
About
script like lua
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C++ 52.4%
- C 44.3%
- Yacc 2.3%
- CMake 0.4%
- Lex 0.3%
- Assembly 0.1%
- Other 0.2%