MCPcopy Index your code
hub / github.com/killme2008/aviatorscript

github.com/killme2008/aviatorscript @aviator-5.4.3 sqlite

repository ↗ · DeepWiki ↗ · release aviator-5.4.3 ↗
3,745 symbols 13,433 edges 407 files 757 documented · 20%
README

AviatorScript

Build Status Maven Central

📖 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.

It's not a game, it's a programming language. Please refrain from sending me any more unsolicited emails.RTFM

Feature Intro

  1. Supports basic types such as numbers, strings, regular expressions, booleans, and more. Full support for all Java operators and precedence, etc. Basic Types.
  2. Functions are first-class, supporting closures and functional programming.
  3. Built-in bigint/decimal types for large integers and high-precision calculations. Supports operator overloading to allow these types to use common arithmetic operators +-*/.
  4. Full script syntax support, including multiline data, conditional statements, loop statements, lexical scoping, and exception handling.
  5. Functional programming combined with Sequence abstraction for convenient collection handling.
  6. Lightweight module system.
  7. Multiple ways to easily call Java methods, with full support for the Java script API (facilitating script calls from Java).
  8. Rich customization options, usable as a secure language sandbox and a fully featured language.
  9. Dynamic compilation and execution, lightweight, and high performance. In ASM mode, it directly compiles scripts into JVM bytecode. Interpretation mode can run on non-standard Java platforms like Android.
  10. Supports serialization of compiled results, facilitating caching and compiling acceleration. Supports execution timeout settings to prevent resource exhaustion by disruptive scripts.

Recommend version 5.2.6 and above.

News

  • 5.4.2,add the getFunctionNames method to retrieve a list of functions and set the evaluation timeout, etc.
  • 5.4.1,Fixed recursive function can't work, fixed function can't be serialized etc.
  • 5.4.0,Fixed elsif parser errors,supports expression serialization(example) etc.

Dependency

<dependency>
  <groupId>com.googlecode.aviator</groupId>
  <artifactId>aviator</artifactId>
  <version>{version}</version>
</dependency>

Check available versions at search.maven.org.

Quick Start

  1. Download aviator shell script to a directory in system PATH environment variable,such as ~/bin/aviator:
$ wget https://raw.githubusercontent.com/killme2008/aviator/master/bin/aviator
$ chmod u+x aviator
  1. 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
  1. 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)}");
  1. 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.

Links

Extension points exported contracts — how you extend this code

Sequence (Interface)
Sequence mark interface. @author dennis(killme2008@gmail.com) @param [9 implementers]
src/main/java/com/googlecode/aviator/runtime/type/Sequence.java
Collector (Interface)
Collector to collect elements. @author dennis(killme2008@gmail.com) @param [7 implementers]
src/main/java/com/googlecode/aviator/runtime/type/Collector.java
AviatorFunction (Interface)
A aviator function,all functions must implement this interface @author dennis [109 implementers]
src/main/java/com/googlecode/aviator/runtime/type/AviatorFunction.java
StringSegment (Interface)
A string segment. @author dennis(killme2008@gmail.com) [6 implementers]
src/main/java/com/googlecode/aviator/runtime/type/string/StringSegment.java
CodeGenerator (Interface)
Code generator interface @author dennis [8 implementers]
src/main/java/com/googlecode/aviator/code/CodeGenerator.java

Core symbols most depended-on inside this repo

execute
called by 978
src/main/java/com/googlecode/aviator/Expression.java
getValue
called by 561
src/main/java/com/googlecode/aviator/lexer/token/Token.java
put
called by 423
src/main/java/com/googlecode/aviator/utils/Env.java
get
called by 237
src/main/java/com/googlecode/aviator/utils/Env.java
add
called by 217
src/main/java/com/googlecode/aviator/runtime/type/Collector.java
valueOf
called by 176
src/main/java/com/googlecode/aviator/runtime/type/AviatorNumber.java
valueOf
called by 167
src/main/java/com/googlecode/aviator/runtime/type/AviatorRuntimeJavaType.java
getCodeGeneratorWithTimes
called by 161
src/main/java/com/googlecode/aviator/parser/ExpressionParser.java

Shape

Method 3,292
Class 416
Enum 20
Interface 17

Languages

Java100%

Modules by API surface

src/main/java/com/googlecode/aviator/asm/commons/InstructionAdapter.java95 symbols
src/main/java/com/googlecode/aviator/AviatorEvaluatorInstance.java95 symbols
src/main/java/com/googlecode/aviator/code/asm/ASMCodeGenerator.java92 symbols
src/main/java/com/googlecode/aviator/parser/ExpressionParser.java81 symbols
src/test/java/com/googlecode/aviator/parser/ExpressionParserUnitTest.java79 symbols
src/test/java/com/googlecode/aviator/test/function/GrammarUnitTest.java77 symbols
src/test/java/com/googlecode/aviator/test/function/FunctionTest.java77 symbols
src/main/java/com/googlecode/aviator/asm/commons/GeneratorAdapter.java68 symbols
src/test/java/com/googlecode/aviator/AviatorEvaluatorInstanceUnitTest.java60 symbols
src/main/java/com/googlecode/aviator/code/interpreter/InterpretCodeGenerator.java60 symbols
src/main/java/com/googlecode/aviator/code/OptimizeCodeGenerator.java56 symbols
src/test/java/com/googlecode/aviator/code/asm/ASMCodeGeneratorUnitTest.java51 symbols

Dependencies from manifests, versioned

com.ibeetl:beetl3.1.7.RELEASE · 1×
junit:junit4.13.1 · 1×
org.mockito:mockito-all1.10.19 · 1×
org.openjdk.jmh:jmh-core1.20 · 1×
org.openjdk.jmh:jmh-generator-annprocess1.20 · 1×
org.springframework:spring-context5.3.36 · 1×

For agents

$ claude mcp add aviatorscript \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact