<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          FakeScript-Java輕量級嵌入式腳本語言

          聯(lián)合創(chuàng)作 · 2023-09-27 23:20

          FakeScript-Java

          輕量級嵌入式腳本語言。

          簡介

          FakeScript-Java是一款輕量級的嵌入式腳本語言,使用Java語言編寫,語法吸取自lua、golang、erlang,基于jflex、cup生成語法樹,編譯成字節(jié)碼解釋執(zhí)行。 C/C++版本fakescript

          腳本特性

          • 語法類似lua

          • 全部為函數(shù)

          • 支持array,map,可以無限嵌套

          • 支持fake testfunc(param1)產(chǎn)生routine,實(shí)現(xiàn)假多線程效果

          • 支持Java靜態(tài)函數(shù)和Java類成員函數(shù)的綁定

          • 自帶解釋器

          • 支持多返回值

          • 自帶profile,可獲取腳本各個函數(shù)運(yùn)行時間

          • 支持熱更新

          • 支持Int64

          • 支持const定義

          • 支持包

          • 支持struct

          示例

          #!lua
          -- 當(dāng)前包名
          package mypackage.test
          -- 引入的文件
          include "common.fk"
          -- 結(jié)構(gòu)體定義
          struct teststruct
              sample_a
              sample_b
              sample_c
          end
          -- 常量值
          const hellostring = "hello"
          const helloint = 1234
          const hellomap = {1 : "a" 2 : "b" 3 : [1 2 3]}
          -- func1 comment
          func myfunc1(arg1, arg2)
              -- Java靜態(tài)函數(shù)和類成員函數(shù)的調(diào)用
              arg3 := cfunc1(helloint) + arg2:memfunc1(arg1)
              -- 分支
              if arg1 < arg2 then 
                  -- 創(chuàng)建一個協(xié)程
                  fake myfunc2(arg1, arg2)
              elseif arg1 == arg2 then    
                  print("elseif")
              else
                  print("else")
              end
              -- for循環(huán)
              for var i = 0, i < arg2, i++ then
                  print("i = ", i)
              end
              -- 數(shù)組
              var a = array()
              a[1] = 3
              -- 集合
              var b = map()
              b[a] = 1
              b[1] = a
              -- Int64
              var uid = 1241515236123614u
              log("uid = ", uid)
              -- 子函數(shù)調(diào)用
              var ret1, var ret2 = myfunc2()
              -- 其他包的函數(shù)調(diào)用
              ret1 = otherpackage.test.myfunc1(arg1, arg2)
              -- 結(jié)構(gòu)體
              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

          Java示例

          #!java
          // 創(chuàng)建一個實(shí)例
          fake f = fk.newfake(null);
          // 注冊包里全部標(biāo)記@fakescript的函數(shù)
          fk.reg(f, "com.test");
          // 解析fake腳本文件
          fk.parse(f, "test.fk");
          // 執(zhí)行myfunc1函數(shù),傳入兩個參數(shù)分別為1和2
          double ret = (double)fk.run(f, "myfunc1", 1, 2);
          瀏覽 19
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  天干天干天夜夜 | 成人午夜爱爱视频 | 美女操逼视频免费看 | 九一国产在线 | 国产综合视频在线观看 |