- Notifications
You must be signed in to change notification settings - Fork870
A high performance scripting language hosted on the JVM.
NotificationsYou must be signed in to change notification settings
killme2008/aviatorscript
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
📖 English Documentation | 📖 中文文档
AviatorScript
是一门高性能、轻量级寄宿于 JVM (包括 Android 平台)之上的脚本语言。
It's not a game, it's a programming language. Please refrain from sending me any more unsolicited emails.RTFM
- 支持数字、字符串、正则表达式、布尔值、正则表达式等基本类型,完整支持所有 Java 运算符及优先级等。
- 函数是一等公民,支持闭包和函数式编程。
- 内置bigint/decimal 类型用于大整数和高精度运算,支持运算符重载得以让这些类型使用普通的算术运算符
+-*/
参与运算。 - 完整的脚本语法支持,包括多行数据、条件语句、循环语句、词法作用域和异常处理等。
- 函数式编程结合Sequence 抽象,便捷处理任何集合。
- 轻量化的模块系统。
- 多种方式,方便地调用 Java 方法,完整支持 Java脚本 API(方便从 Java 调用脚本)。
- 丰富的定制选项,可作为安全的语言沙箱和全功能语言使用。
- 动态编译和执行、轻量化、高性能,ASM 模式下通过直接将脚本编译成 JVM 字节码,解释模式可运行于 Android 等非标 Java 平台。
- 支持编译结果序列化,方便缓存加速等。支持执行超时设置,避免破坏性脚本耗尽资源。
使用场景包括:
- 规则判断及规则引擎
- 公式计算
- 动态脚本控制
- 集合数据 ELT 等……
推荐使用版本 5.2.6 及以上
- 5.4.3,增加安全沙箱一键启用方法以及修复 bug 等。
- 5.4.2,增加
getFunctionNames
方法用于获取函数列表以及设置求值超时时间等。 - 5.4.1,修复递归函数无法工作的 bug,修复函数无法序列化的 bug 等。
<dependency> <groupId>com.googlecode.aviator</groupId> <artifactId>aviator</artifactId> <version>{version}</version></dependency>
可以在search.maven.org 查看可用的版本。
- 下载aviator shell 到某个目录(最好是在系统的
PATH
环境变量内),比如~/bin/aviator
:
$ wget https://raw.githubusercontent.com/killme2008/aviator/master/bin/aviator$ chmod u+x aviator
- 执行
aviator
命令,将自动下载最新文档版本 aviator jar 到~/.aviatorscript
下的安装目录并运行:
$ aviatorDownloading AviatorScript now... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 153 100 153 0 0 111 0 0:00:01 0:00:01 --:--:-- 111100 1373k 100 1373k 0 0 689k 0 0:00:01 0:00:01 --:--:-- 689kUsage: java com.googlecode.aviator.Main [file] [args]: java com.googlecode.aviator.Main -e [script]: java com.googlecode.aviator.Main -v
- 将下面这个脚本保存为文件
hello.av
:
p("Hello, AviatorScript!");leta=tuple(1,2,3,4,5);p("sum of a is: "+reduce(a,+,0));letdate=newjava.util.Date();p("The year is: "+getYear(date));p("The month is: #{getMonth(date)}");
一个更复杂的计算器例子(求值算术表达式字符串)参见calculator.av。
- 执行脚本:
$ aviator hello.avHello, AviatorScript!sum of a is: 15The year is: 120The month is: 3
更详细的请阅读用户指南。
- Releases:https://github.com/killme2008/aviator/releases
- Documents:https://www.yuque.com/boyan-avfmj/aviatorscript
- Changelog:https://www.yuque.com/boyan-avfmj/aviatorscript/bggwx2
- Javadoc:http://fnil.net/aviator/apidocs/
- Spring boot rule:https://github.com/mengxiangrui007/spring-boot-rule-jsr94
- Idea plugin:https://github.com/yanchangyou/aviatorscript-ideaplugin
About
A high performance scripting language hosted on the JVM.
Topics
Resources
Security policy
Stars
Watchers
Forks
Packages0
No packages published