test - 测试脚本语言

This commit is contained in:
wangli 2024-11-28 15:15:33 +08:00
parent 5f2cd081d7
commit 406d0d5954
5 changed files with 59 additions and 0 deletions

View File

@ -142,6 +142,11 @@
<groupId>cn.axzo</groupId>
<artifactId>riven-api</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>5.4.3</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,25 @@
package cn.axzo.workflow.server;
import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.AviatorEvaluatorInstance;
import com.googlecode.aviator.EvalMode;
import com.googlecode.aviator.Expression;
import com.googlecode.aviator.Options;
import java.util.List;
/**
* TODO
*
* @author wangli
* @since 2024-11-28 10:06
*/
public class Main {
public static void main(String[] args) throws Exception {
AviatorEvaluatorInstance engine = AviatorEvaluator.newInstance(EvalMode.ASM);
engine.setOption(Options.TRACE_EVAL, false);
Expression exp = engine.compile(" for i in range(0,10) { p(i);}");
exp.execute();
}
}

View File

@ -0,0 +1,10 @@
let a = 99;
let b = 0xFF;
let c = -99;
println(a + b);
println(a / b);
println(a - b + c);
println(a + b * c);
println(a - (b - c));
println(a / b * b + a % b);

View File

@ -0,0 +1 @@
println("hello,AviatorScript!");

View File

@ -0,0 +1,18 @@
## examples/use.av
use java.util.*;
let list = new ArrayList(10);
seq.add(list, 1);
seq.add(list, 2);
p("list[0]=#{list[0]}");
p("list[1]=#{list[1]}");
let set = new HashSet();
seq.add(set, "a");
seq.add(set, "a");
p("set type is: " + type(set));
p("set is: #{set}");