Search in sources :

Example 1 with CurlyBlock

use of ast.Expression.CurlyBlock in project L42 by ElvisResearchGroup.

the class DesugarVars method visit.

public Expression visit(CurlyBlock s) {
    Expression inner;
    if (s.getContents().size() == 1 && s.getContents().get(0).get_catch().isEmpty() && s.getContents().get(0).getDecs().size() == 1 && s.getContents().get(0).getDecs().get(0) instanceof VarDecE) {
        inner = ((VarDecE) s.getContents().get(0).getDecs().get(0)).getInner();
    } else {
        inner = new RoundBlock(s.getP(), s.getDoc(), Expression._void.instance, s.getContents());
    }
    inner = inner.accept(this);
    List<VarDec> vd = Collections.singletonList((VarDec) new VarDecE(inner));
    BlockContent o = new BlockContent(vd, Collections.emptyList());
    return new CurlyBlock(s.getP(), Doc.empty(), Collections.singletonList(o));
}
Also used : Expression(ast.Expression) CurlyBlock(ast.Expression.CurlyBlock) VarDec(ast.Ast.VarDec) BlockContent(ast.Expression.BlockContent) RoundBlock(ast.Expression.RoundBlock) VarDecE(ast.Ast.VarDecE)

Aggregations

VarDec (ast.Ast.VarDec)1 VarDecE (ast.Ast.VarDecE)1 Expression (ast.Expression)1 BlockContent (ast.Expression.BlockContent)1 CurlyBlock (ast.Expression.CurlyBlock)1 RoundBlock (ast.Expression.RoundBlock)1