aviatorscript

A high performance scripting language hosted on the JVM.

Stars
4.5K
Committers
21

Bot releases are hidden (Show)

aviatorscript - [Deprecated] AviatorScript 5.1.0 released

Published by killme2008 about 4 years ago

Thit is a major version release, it introduces some new syntax features,main changes as below:

  • Supports catching multi exceptions in one catch clause, for example:
try {
   ## do something
} catch (IllegalStateException | ArrayIndexOutOfBoundsException | java.io.IOException e) {
   pst(e);  ##print stack trace
}

It's the same as the Java 7 catch multiple exceptions.

  • String interpolation to stick strings together more easier and faster:
let name = "aviator";
let a = 1;
let b = 2;
let s = "hello, #{name}, #{a} + #{b} = #{a + b}";
p(s);

It will output the string hello,avitor,1 + 2 = 3. The expression quoted by #{} will be executed and sticked into the result string.
A new feature Feature.StringInterpolation is added into Feature enum, it's enabled by default.

  • Adds a new method AviatorEvaluatorInstance#validate(script) to validate whether a text string is a legal script.
  • Fixed #257
  • Make some internal standard functions more friend with nil argument:
nil =~/[a-zA-Z]+/;                 ## returns false when matching nil with regular pattern .
count(nil);                        ## returns 0
include(nil, element);             ## returns false
map(nil, lambda);                  ## returns nil
sort(nil);                         ## returns nil
reduce(nil, lambda, init);         ## returns the init value
filter(nil, lambda);               ## returns nil
seq.every(nil, lambda);            ## returns true
seq.not_any(nil, lambda);          ## returns true
seq.some(nil, lambda);             ## returns nil

There are some breaking changes, the user MUST note them.

aviatorscript - [Deprecated] AviatorScript 5.0.1

Published by killme2008 over 4 years ago

Main changes:

  • Tweak variable accessing performance #238
  • Fixed can't overload assignment/define operator #245
  • Fixed function arguments( enabled by Opitons.CAPTURE_FUNCTION_ARGS) are wrong when invoking more than one functions.#236
  • Fixed array accessing operator can't work with Options.ALWAYS_PARSE_INTEGRAL_NUMBER_INTO_DECIMAL #237
  • Adds new function eval(script, [bindings], [cached]) to execute a script text string with binding map in scripts.
  • Adds overload functions reader(input_stream, [charset]) and writer(output_stream, [charset]) to IO module.
aviatorscript - [Deprecated] Aviator 5.0.0 releases

Published by killme2008 over 4 years ago

Deprecated, please use 5.2.6 and above versions.

I am happy to announce that AviatorScript 5.0.0 is released. Main changes since 5.0.0-RC2:

  • Adds main class com.googlecode.aviator.Main to execute aviator scripts.
  • Adds bootstrap shell script aviator to wrap the main class and download/upgrade logics. See doc how to use it.
  • count(nil) returns 0 instead of throwing an exception.
  • AviatorFunction extends java Runnable and Callable interface, now you can pass a aviator function to Thread constructor:
let t = new Thread(lambda() -> p('run'); end);
start(t);
  • Fixed some bugs:
    • try statement can't only be with finally without catch statements.
    • NPE in parser.
aviatorscript - [Deprecated] AviatorScript 5.0.0-RC2

Published by killme2008 over 4 years ago

Main changes:

  • new Class(args) statement to create an instance of special class with arguments, for example:
let s = new String("test");
p(type(s)); ## print string
  • throw exception statement to throw an exception.
  • try/catch/finally statement to handle exceptions, for example:
   try {
       throw "an exception";
   } catch(e) {
       pst(e);
   } finally {
       p("finally");
   }
  • Fixed #228 can't run on IBM jdk.
  • Fixed Opitons.MAX_LOOP_COUNT.
  • Make seq.get to support List.
  • AviatorEvaluatorInstance#aliasFunction(name, alias) to alias a function.
  • New function pst(e) to print stacktrace of an exception.
  • Alias function println to p.
  • Every statement has a value:
let a = if(true) {
   2
};

p(a);  ## print 2
  • Breaking changes:
    • Checking equality of two different types x == y or x !=y doesn't throw an exception any more but returns false.
aviatorscript - [Deprecated] AviatorScript 5.0.0-RC1

Published by killme2008 over 4 years ago

Main changes since 5.0.0-beta2:

  • Release Programming AviatorScript 5.0 doc in chinese.
  • Options. MAX_LOOP_COUNT to control max loop count in for/while/sequence-iterate loop, default zero means no limitation.
  • Fixed __MODULE__.exports can't be assigned.
  • Use absolute file path as module caching key.
  • Fixed number overflow parsing error #219, thanks to @H123R
  • seq.get supports java.util.Set, return the element itself if it is in set, otherwise returns nil.
  • Reset classloader when calling AviatorEvaluatorInstance#clearExpressionCache().
  • Adds new method to set classloader AviatorEvaluatorInstance#setAviatorClassLoader(classloader)
  • Adds LRU cache for expression caching, enable it by AviatorEvaluatorInstance#useLRUExpressionCache(capacity).
  • Make parser token and avaitor objects implements Serializable interface #209
  • Remove global lock in BeanUtilsBean.getInstance by a bean cache. #222
  • Impl java scripting SPI #198 , supports Invocable and refactor script engine, see the programming doc.
  • New option Options.FEATURE_SET to set engine's syntax feature, valid features are listed in Feature enum.Default set is full feature set.
  • New functions:
    • seq.entry(key, value) to create a Map.Entry.
    • into(to_coll, from_coll) to add all elements in from_coll into to_coll by seq.add(to_coll, element).
    • bigint(x) to cast a value into bigint type.
    • decimal(x) to cast a value into decimal type.
  • Breaking changes:
    • Remove Options.ALWAYS_USE_DOUBLE_AS_DECIMAL, already replaced by Options. ALWAYS_USE_DECIMAL_AS_FLOATING_POINT_NUMBER.
    • Remove Options.TRACE, not supported any more.
    • Remove Options.DISABLE_ASSIGNMENT, please use feature API.
    • Default syntax feature set is full-featured, if you want to be compatible with old versions(before 5.0.0), please setOption(Options.FEATURE_SET, Feature.getCompatibleFeatures()), then the engine only supports assignment, lambda and internal variables, if/for/while/let etc. features are disabled.
aviatorscript - AviatorScript 5.0.0-beta2

Published by killme2008 over 4 years ago

Main changes:

  • More examples for AviatorScript.
  • Fixed issue #212 in scopes for variable assignment.
  • A simple IO module, see example file_io.av.
  • A new method AviatorEvaluatorInstance#addModule to register custom modules.
  • Refactor sequence/reducer impl, and now string is a sequence too:
let s = "hello";
for c in s {
  println(c);
}

println(filter(s, seq.eq('l')));
  • New functions: type(x) to return x's type, is_def(x) returns true when variable x is defined, undef(x) to forgot a defined variable.
  • Performance turning: almost 60% speedup in quick-sort benchmark.
  • include(seq, x) is O(1) time complexity for java.util.Set now #214
aviatorscript - AviatorScript 5.0.0-beta1

Published by killme2008 over 4 years ago

Since 5.0.0, aviator becomes a general-purpose scripting language, new features:

• Lexical scope by { }
return statement to return a value in a function or script.
if/elsif/else statement
for loop statement and supports break , continue
while loop statement
let to define lexical variable
fn syntax to define named function
## a comment for single line comment

Please see the documents AviatorScript UserGuide (in progress).

Breaking changes: TODO

You can try the examples by running RunScriptExample. All the examples are under examples folder.

aviatorscript - Aviator 4.2.10 released

Published by killme2008 over 4 years ago

Main changes:

  • Added a new helper method AviatorEvaluator.newEnv(k1, v1, k2, v2, ...) to create an environment map.
  • Supports assigning value to object's property such as bean.x = y.
  • FIxed parsing scientific notation number error with Options.ALWAYS_PARSE_FLOATING_POINT_NUM #191
  • Allows new line(\r or \r\n) breaker in expression. #191
  • Function can be found by object's property syntax #191 , for example
m = seq.map('square', lambda(x)-> x*x end); 
m.square(100.0)
aviatorscript - Aviator 4.2.9 released

Published by killme2008 almost 5 years ago

Main changes:

  • Bug fixes:
    • Stackoverflow when calling AviatorFunction#toString, #184
    • getVariableNames result contains true/false/nil, #186
  • New features:
    • Supports array/list element assignment such as x[i]=y #187
aviatorscript - Aviator 4.2.8 released

Published by killme2008 almost 5 years ago

Main changes:

  • Fixed #181
  • Wraps function returned value to ensure it's not null (replaced by AviatorNil automatically). For example, it will throw a NullPointerException on runtime if the custom function returns java's null right now, you should return AviatorNil.Nil instead. But with this improvement, you can just return the null in custom functions, aviator will replace the null with AviatorNil automatically for you.
aviatorscript - Aviator 4.2.7 released

Published by killme2008 almost 5 years ago

Main changes:

  • Fixed parser bug #177
aviatorscript - Aviator 4.2.6 released

Published by killme2008 almost 5 years ago

Main changes:

  • Fixed NPE when compare date instances #175
aviatorscript - Aviator 4.2.5 released

Published by killme2008 about 5 years ago

Main changes:

  • Deprecated AviatorEvaluator#exec, please use AviatorEvaluator#execute instead.
  • Function missing mechanism #170, #171, you can custom your own behaviours when calling function is not found by implement FunctionMissing interface.
  • A default function missing implementation JavaMethodReflectionFunctionMissing. With this handler, you can call any java class's public instance methods by reflection even when you don't import them. The example is here,but you have to pay performance cost(almost 3x times slower than implements custom functions).
  • New doc 调用 Java 方法和 Function Missing
aviatorscript - Aviator 4.2.4 released

Published by killme2008 about 5 years ago

Main features:

  • Fixed #162 , long type promption error.
  • Fixed #166 , call varidic methods in java class.
  • Adds seq.array(clazz, arg1, arg2, ...) function to create an array of clazz type, seq.array(int, 1, 2, 3) for example that creates an int array new int[] {1, 2, 3}.
  • Adds annotations for importing java class methods:
    • Function for java method to set custom function name.
    • Ignore to ignore java method for importing.
    • Import annotation with new method AviatorEvaluatorInstance#importFunctions to set imported methods scope and namespace.
  • Breaking change: aviator generated bytecode version bump to Java 1.7
  • map and reduce function now support java.util.Map, the element type is Map.Entry, #164
  • Constant pool for constants(number/string etc.) to reduce CPU and memory consumption #167
aviatorscript - Aviator 4.2.3 released

Published by killme2008 about 5 years ago

  • Fixed: AviatorEvaluator.addStaticFunctions shoud be static.
  • New feature: imports java class's instance methods by AviatorEvaluator.addInstanceFunctions(String, Class) or AviatorEvaluatorInstance#addInstanceFunctions(String, Class). For example:
AviatorEvaluator.addInstanceFunctions("s", String.class);

Then you can use all java.lang.String 's all public instance methods by passing the string instance as the first argument:

s.indexOf('hello', 'l')
s.replaceAll('hello', 'l', 'x')
aviatorscript - Aviator 4.2.2 released

Published by killme2008 about 5 years ago

Main features:

  • Added new methods AviatorEvaluator.addStaticFunctions(namespace, clazz) and AviatorEvaluatorInstanc#addStaticFunctions(namespace, clazz) to import class public static methods as custom functions under namespace #155
  • Breaking change: the regular pattern's value is the compiled java Pattern instance, it's a string before.
  • Improve runtime exceptions.
aviatorscript - Aviator 4.2.1 released

Published by killme2008 about 5 years ago

  1. Fixed typo: SringContextFunctionLoader.java -> SpringContextFunctionLoader
  2. Fixed NPE in tracing mode #145

Many code style,compile warnings and document errors fixed, thanks to @oldratlee contribution.

aviatorscript - Aviator 4.2.0 released

Published by killme2008 over 5 years ago

Main features:

  1. Fixed closured over wrong variable in nested lambda #134
  2. Adds a new opiton Options.ALWAYS_PARSE_INTEGRAL_NUMBER_INTO_DECIMAL that will parse all integral numbers into big decimal, thanks to @aliiohs #124
  3. Adds seq.contains_key(map, key) to check if the key object is exists in a map and fixed Env#contains_key #122
  4. Adds a new feature: capture function invocation arguments into env, for example:
List<FunctionArgument> args = (List<FunctionArgument>) AviatorEvaluator
		  .execute("f = lambda(a,bc, d) -> __args__ end; f(1,2,100+2)");

The args list is retrieved from env as __args__ var,and it's a list of FunctionArgument:

[
 FunctionArgument [index=0, expression=1],  
 FunctionArgument [index=1, expression=2],
 FunctionArgument [index=2, expression=100+2]
]

This feature is useful for function invocation caching or parameter vailidation, and it's optional, if you want it, you can enable it by setting Options.CAPTURE_FUNCTION_ARGS to be true, default is false.

The argument list can also be captured in custom functions, you can get it through FunctionUtils.getFunctionArguments(env) or env.get("__args__").

aviatorscript - Aviator 4.1.2 released

Published by killme2008 over 5 years ago

Main features:

  1. Fixed a bug in FunctionUtils#getJavaObject to retrieve java collection type such as (user.roles) #106
  2. Fixed NPE when tracing expression evaluation.
  3. Variables captured by closure should be immutable. #101
  4. Adds a new option Options.DISABLE_ASSIGNMENT to disable variable assignment.
  5. Literal expression performance issue #96
  6. New functions to create java collections
    • seq.set(x,y,z...) to create a HashSet instance from varidic arguments.
    • seq.list(x,y,z...) to create a 'ArrayList` instance from varidic arguments.
    • seq.map(k1,v1, k2, v2,...) to create a HashMap instance from varidic arguments.
    • New functions seq.add,seq.remove and seq.get to add/remove/get elements(values) from collections.
  7. seq.max(coll) and seq.min(coll) to retrieve min/max element in a sequence.
  8. min(x,y,z...) and max(x,y,z...) to retrieve min/max value from varidic arguments.
  9. identity(x) function to return the argument itself.
  10. Adds a new document 4.0 features explain.

Maven

 <dependency>
      <groupId>com.googlecode.aviator</groupId>
      <artifactId>aviator</artifactId>
      <version>4.1.2</version>
  </dependency>
aviatorscript - Aviator 4.1.1 发布

Published by killme2008 almost 6 years ago

主要改动如下:

  1. 性能优化,从简单测试来看,对比 4.1.0 有近 30% 的提升,整体性能接近 3.3.0 版本。
  2. 废弃 AviatorEvaluator.exec(exp, args...) 方法,都推荐使用 execute 方法明确传入 env map 的方式。

此版本推荐升级。

`Maven 依赖:

<dependency>
      <groupId>com.googlecode.aviator</groupId>
      <artifactId>aviator</artifactId>
      <version>4.1.1</version>
  </dependency>