import parsii.eval.Expression;
import parsii.eval.Parser;
import parsii.eval.Scope;
import parsii.eval.Variable;
public class ExpDemo {
public static void main(String[]args) throws Exception{
String exp = "x**n ";//指数
Scope scope = new Scope();
Expression parsiiExpr = Parser.parse(exp,scope);
Variable var1 = scope.getVariable("x");
var1.setValue(3.0);
Variable var2 = scope.getVariable("n");
var2.setValue(3);
double result = parsiiExpr.evaluate();
System.out.println(result);
}
}
使用parsii包,计算表达式的值