@@ -0,0 +1,2123 @@
+package natlab.utils;%0A%0Aimport java.util.Arrays;%0A%0Aimport ast.AssignStmt;%0Aimport ast.Expr;%0Aimport ast.ExprStmt;%0Aimport ast.FunctionHandleExpr;%0Aimport ast.IntLiteralExpr;%0Aimport ast.Name;%0Aimport ast.NameExpr;%0Aimport ast.ParameterizedExpr;%0Aimport ast.StringLiteralExpr;%0Aimport natlab.DecIntNumericLiteralValue;%0A%0A/**%0A * This class provides some helpers that you can import statically to make%0A * manual AST construction less verbose. For instance, creating an%0A * assignment statement like:%0A *%0A * x = f(4, 'x');%0A *%0A * looks like:%0A *%0A * assign(var(%22x%22), call(%22f%22, args(integer(4), string(%22x%22))))%0A *%0A * instead of:%0A *%0A * new AssignStmt(%0A *   new NameExpr(new Name(%22x%22)),%0A *   new ParameterizedExpr(%0A *     new NameExpr(new Name(%22f%22)),%0A *     new ast.List%3C%3E()%0A *       .add(new IntLiteralExpr(new DecIntNumericLiteralValue(%224%22)))%0A *       .add(new StringLiteralExpr(%22x%22)))%0A *   )%0A * )%0A */%0Apublic class Asts %7B%0A  public static AssignStmt assign(Expr lhs, Expr rhs) %7B%0A    return new AssignStmt(lhs, rhs);%0A  %7D%0A%0A  public static ExprStmt stmt(Expr expr) %7B%0A    return new ExprStmt(expr);%0A  %7D%0A%0A  public static NameExpr var(String name) %7B%0A    return new NameExpr(new Name(name));%0A  %7D%0A%0A  public static ast.List%3CExpr%3E args(Expr... args) %7B%0A    return new ast.List%3CExpr%3E().addAll(Arrays.asList(args));%0A  %7D%0A%0A  public static ParameterizedExpr call(Expr target, ast.List%3CExpr%3E args) %7B%0A    return new ParameterizedExpr(target, args);%0A  %7D%0A%0A  public static ParameterizedExpr call(String target, ast.List%3CExpr%3E args) %7B%0A    return call(var(target), args);%0A  %7D%0A%0A  public static ParameterizedExpr index(Expr target, ast.List%3CExpr%3E args) %7B%0A    return call(target, args);%0A  %7D%0A%0A  public static ParameterizedExpr index(String target, ast.List%3CExpr%3E args) %7B%0A    return index(var(target), args);%0A  %7D%0A%0A  public static IntLiteralExpr integer(int value) %7B%0A    return new IntLiteralExpr(new DecIntNumericLiteralValue(String.valueOf(value)));%0A  %7D%0A%0A  public static StringLiteralExpr string(String value) %7B%0A    return new StringLiteralExpr(value);%0A  %7D%0A%0A  public static FunctionHandleExpr handleTo(String name) %7B%0A    return new FunctionHandleExpr(new Name(name));%0A  %7D%0A%7D%0A

Add AST construction helpers.