{"id":21071578,"url":"https://github.com/esrrhs/fakejava","last_synced_at":"2025-05-16T05:31:37.585Z","repository":{"id":87695588,"uuid":"64592962","full_name":"esrrhs/fakejava","owner":"esrrhs","description":"嵌入式脚本语言 Lightweight embedded scripting language","archived":false,"fork":false,"pushed_at":"2021-07-02T09:25:08.000Z","size":2196,"stargazers_count":52,"open_issues_count":0,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T20:51:14.603Z","etag":null,"topics":["interpreter","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esrrhs.png","metadata":{"files":{"readme":"README_EN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-31T12:34:23.000Z","updated_at":"2024-04-09T07:23:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea39ee9e-6fee-405a-8a56-9f64ac0d26a0","html_url":"https://github.com/esrrhs/fakejava","commit_stats":null,"previous_names":["esrrhs/fakescript-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2Ffakejava","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2Ffakejava/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2Ffakejava/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esrrhs%2Ffakejava/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esrrhs","download_url":"https://codeload.github.com/esrrhs/fakejava/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474236,"owners_count":22077245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interpreter","java"],"created_at":"2024-11-19T18:53:40.058Z","updated_at":"2025-05-16T05:31:37.576Z","avatar_url":"https://github.com/esrrhs.png","language":"Java","readme":"# fakejava\n\n[\u003cimg src=\"https://img.shields.io/github/license/esrrhs/fakejava\"\u003e](https://github.com/esrrhs/fakejava)\n[\u003cimg src=\"https://img.shields.io/github/languages/top/esrrhs/fakejava\"\u003e](https://github.com/esrrhs/fakejava)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/com.github.esrrhs/fakescript-java\"\u003e](https://github.com/esrrhs/fakejava)\n[\u003cimg src=\"https://img.shields.io/github/workflow/status/esrrhs/fakejava/Java%20CI\"\u003e](https://github.com/esrrhs/fakejava/actions)\n\nLightweight embedded scripting language\n\n## Brief introduction\n**fakejava** is a lightweight embedded scripting language , using Java language, grammar lessons from lua, golang, erlang, based on jflex, bison generative grammar tree , compiled into byte code interpreted.\n\n[fake for C/C++](https://github.com/esrrhs/fake)\n\n[fake for Go](https://github.com/esrrhs/fakego)\n\n## Script feature\n* The syntax is similar to lua\n* All function\n* Support array, map, unlimited nested\n* Support generating routine like fake testfunc (param1), to achieve the effect of multithreading\n* Support binding Java Static functions and Java class member functions\n* With interpreter\n* Support multi return value\n* Support profile, can get the script running time of each function\n* Support hot update\n* Support Int64\n* Support const definitions\n* Support Package\n* Support struct\n* Support byte code optimize\n* Support global map\n\n\n\n## Sample\n\n```\n\n\n-- Current package name\npackage mypackage.test\n\n-- include file\ninclude \"common.fk\"\n\n-- struct define\nstruct teststruct\n\tsample_a\n\tsample_b\n\tsample_c\nend\n\n-- const define\nconst hellostring = \"hello\"\nconst helloint = 1234\nconst hellomap = {1 : \"a\" 2 : \"b\" 3 : [1 2 3]}\n\n-- func1 comment\nfunc myfunc1(arg1, arg2)\n\n\t-- Java static function calls and Java class member functions\n\targ3 := cfunc1(helloint) + arg2:memfunc1(arg1)\n\n\t-- Branch\n\tif arg1 \u003c arg2 then\n\t\t-- create routine\n\t\tfake myfunc2(arg1, arg2)\n\telseif arg1 == arg2 then\n\t\tprint(\"elseif\")\n\telse\n\t\tprint(\"else\")\n\tend\n\n\t-- for loop\n\tfor var i = 0, i \u003c arg2, i++ then\n\t\tprint(\"i = \", i)\n\tend\n\n\t-- array use\n\tvar a = array()\n\ta[1] = 3\n\n\t-- map use\n\tvar b = map()\n\tb[a] = 1\n\tb[1] = a\n\n\t-- Int64\n\tvar uid = 1241515236123614u\n\tlog(\"uid = \", uid)\n\n\t-- sub func call\n\tvar ret1, var ret2 = myfunc2()\n\n\t-- other package call\n\tret1 = otherpackage.test.myfunc1(arg1, arg2)\n\n\t-- struct use\n\tvar tt = teststruct()\n\ttt-\u003esample_a = 1\n\ttt-\u003esample_b = teststruct()\n\ttt-\u003esample_b-\u003esample_a = 10\n\n\t-- switch branch\n\tswitch arg1\n\t\tcase 1 then\n\t\t\tprint(\"1\")\n\t\tcase \"a\" then\n\t\t\tprint(\"a\")\n\t\tdefault\n\t\t\tprint(\"default\")\n\tend\n\n\t-- multi return value\n\treturn arg1, arg3\n\nend\n```\n\n## Java Sample\n\n```\n// create instance\nfake f = fk.newfake(null);\n// regist all func marked with @fakescript in package\nfk.reg(f, \"com.test\");\n// parse script file\nfk.parse(f, \"test.fk\");\n// run script func myfunc1, put in two param 1 and 2\ndouble ret = (double)fk.run(f, \"myfunc1\", 1, 2);\n\n```\n\n## How to use\n#### Maven\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.esrrhs\u003c/groupId\u003e\n    \u003cartifactId\u003efakescript-java\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.12\u003c/version\u003e\n\u003c/dependency\u003e\n\n```\n\n## Debugging environment\n* IDE\n\n![image](img/ide.png)\n\n* Command-line\n\n![image](img/debug.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesrrhs%2Ffakejava","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesrrhs%2Ffakejava","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesrrhs%2Ffakejava/lists"}