All Projects → esrrhs → fakejava

esrrhs / fakejava

Licence: MIT License
嵌入式脚本语言 Lightweight embedded scripting language

Programming Languages

java
68154 projects - #9 most used programming language
Yacc
648 projects
Lex
420 projects

Projects that are alternatives of or similar to fakejava

CSLisp
C# Scheme / Lisp implementation for embedding in .NET projects
Stars: ✭ 27 (-34.15%)
Mutual labels:  interpreter
scheme.js
Scheme语言解释器的JavaScript语言实现
Stars: ✭ 57 (+39.02%)
Mutual labels:  interpreter
hematita
A memory safe Lua interpreter
Stars: ✭ 118 (+187.8%)
Mutual labels:  interpreter
BabyBrowser
A Small Web Browser Built in Python
Stars: ✭ 21 (-48.78%)
Mutual labels:  interpreter
MonkeyLang.jl
"Writing an Interpreter in GO" and "Writing a Compiler in GO" in Julia.
Stars: ✭ 30 (-26.83%)
Mutual labels:  interpreter
jaws
Jaws is an invisible programming language! Inject invisible code into other languages and files! Created for security research -- see blog post
Stars: ✭ 204 (+397.56%)
Mutual labels:  interpreter
fast-formula-parser
Parse and evaluate MS Excel formula in javascript.
Stars: ✭ 341 (+731.71%)
Mutual labels:  interpreter
snap
An embeddable scripting language inspired by Lua and JavaScript.
Stars: ✭ 32 (-21.95%)
Mutual labels:  interpreter
lambda-dti
Interpreter of the ITGL with dynamic type inference
Stars: ✭ 18 (-56.1%)
Mutual labels:  interpreter
termission
Cross-platform Serial (COM Port) / TCP Terminal with Scriptable Auto-Response
Stars: ✭ 39 (-4.88%)
Mutual labels:  interpreter
BQN
No description or website provided.
Stars: ✭ 16 (-60.98%)
Mutual labels:  interpreter
jispy
A JavaScript interpreter in Python, built for embedding JavaScript.
Stars: ✭ 43 (+4.88%)
Mutual labels:  interpreter
X11Basic
X11-Basic BASIC programming language.
Stars: ✭ 42 (+2.44%)
Mutual labels:  interpreter
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (+173.17%)
Mutual labels:  interpreter
clyde
Dialogue language and tools for games.
Stars: ✭ 21 (-48.78%)
Mutual labels:  interpreter
rlox
Lox Interpreter/REPL written in Rust
Stars: ✭ 31 (-24.39%)
Mutual labels:  interpreter
vein
🔮⚡️Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support.
Stars: ✭ 31 (-24.39%)
Mutual labels:  interpreter
computation-py
Python implementation for Understanding Computation book.
Stars: ✭ 22 (-46.34%)
Mutual labels:  interpreter
aria
Expressive, noiseless, interpreted, toy programming language
Stars: ✭ 40 (-2.44%)
Mutual labels:  interpreter
dew-common
Java common tools collection, support for GraalVM
Stars: ✭ 52 (+26.83%)
Mutual labels:  interpreter

fakejava

Codacy Badge

轻量级嵌入式脚本语言

README_EN

简介

fakejava是一款轻量级的嵌入式脚本语言,使用Java语言编写,语法吸取自lua、golang、erlang,基于jflex、bison生成语法树,编译成字节码解释执行。

C/C++版本fake

Go版本fake

脚本特性

  • 语法类似lua
  • 全部为函数
  • 支持array,map,可以无限嵌套
  • 支持fake testfunc(param1)产生routine,实现假多线程效果
  • 支持Java静态函数和Java类成员函数的绑定
  • 自带解释器
  • 支持多返回值
  • 自带profile,可获取脚本各个函数运行时间
  • 支持热更新
  • 支持Int64
  • 支持const定义
  • 支持包
  • 支持struct
  • 支持字节码优化
  • 支持全局map

示例


-- 当前包名
package mypackage.test

-- 引入的文件
include "common.fk"

-- 结构体定义
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静态函数和类成员函数的调用
	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

Java示例

// 创建一个实例
fake f = fk.newfake(null);
// 注册包里全部标记@fakescript的函数
fk.reg(f, "com.test");
// 解析fake脚本文件
fk.parse(f, "test.fk");
// 执行myfunc1函数,传入两个参数分别为1和2
double ret = (double)fk.run(f, "myfunc1", 1, 2);

使用

Maven

<dependency>
    <groupId>com.github.esrrhs</groupId>
    <artifactId>fakescript-java</artifactId>
    <version>1.0.12</version>
</dependency>

调试环境

  • IDE

image

  • 命令行

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].