Search in sources :

Example 6 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class TestHelper method getExpCore.

public static ExpCore getExpCore(String source, String _e1) {
    Expression code1 = Parser.parse("GeneratedByTestHelper_", _e1);
    Expression code2 = Desugar.of(code1);
    ExpCore e1 = code2.accept(new InjectionOnCore());
    return e1;
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 7 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class TestHelper method getProgram.

public static Program getProgram(/*List<Path> paths,*/
String[] code) {
    Program p0 = Program.emptyLibraryProgram();
    Integer outerCount = code.length;
    for (String s : code) {
        Expression e = Parser.parse("This" + outerCount, s);
        --outerCount;
        ClassB ec = (ClassB) Desugar.of(e).accept(new InjectionOnCore());
        p0 = p0.evilPush(ec);
    }
    return p0;
}
Also used : Program(programReduction.Program) Expression(ast.Expression) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 8 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class TestHelper method getClassB.

public static ClassB getClassB(String source, String e1) {
    Expression code1 = Parser.parse("GeneratedByTestHelper_" + source, e1);
    auxiliaryGrammar.WellFormedness.checkAll(code1);
    Expression code2 = Desugar.of(code1);
    assert auxiliaryGrammar.WellFormedness.checkAll(code2);
    ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
    assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
    return code3;
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) ClassB(ast.ExpCore.ClassB) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 9 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class Desugar method visit1Step.

public MCall visit1Step(SquareCall s) {
    //we can assumethe receivers are normalized after DesugarContext
    //assert s.getReceiver() instanceof Ast.Atom:      s.getReceiver();
    //but nor really, since vars accesses are replaced by meth calls. In that case is fine to not have an atom.
    //(b=r.builder() b.a() b.b() b.c() .... b)
    List<VarDec> vd = new ArrayList<>();
    Expression k = getMCall(s.getP(), s.getReceiver(), "#seqBuilder", getPs());
    String x = Functions.freshName("b", usedVars);
    X b = new X(s.getP(), x);
    vd.add(new VarDecXE(false, Optional.empty(), x, k));
    for (Parameters ps : s.getPss()) {
        vd.add(new VarDecE(getMCall(s.getP(), b, "#add", ps)));
    }
    Expression inner = getBlock(s.getP(), vd, b);
    Parameters ps = new Parameters(Optional.empty(), Collections.singletonList("seqBuilder"), Collections.singletonList(inner));
    return getMCall(s.getP(), s.getReceiver(), "#from", ps);
}
Also used : Parameters(ast.Ast.Parameters) Expression(ast.Expression) VarDec(ast.Ast.VarDec) ArrayList(java.util.ArrayList) X(ast.Expression.X) MethodSelectorX(ast.Ast.MethodSelectorX) VarDecE(ast.Ast.VarDecE) VarDecXE(ast.Ast.VarDecXE)

Example 10 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class Desugar method liftPs.

protected Parameters liftPs(Parameters ps) {
    if (!ps.getE().isPresent()) {
        return liftPsPropagate(ps);
    }
    List<String> xs = new ArrayList<String>(ps.getXs());
    List<Expression> es = new ArrayList<Expression>(ps.getEs());
    xs.add(0, "that");
    es.add(0, ps.getE().get());
    return liftPsPropagate(new Parameters(Optional.empty(), xs, es));
}
Also used : Parameters(ast.Ast.Parameters) Expression(ast.Expression) ArrayList(java.util.ArrayList)

Aggregations

Expression (ast.Expression)66 ArrayList (java.util.ArrayList)24 VarDec (ast.Ast.VarDec)14 X (ast.Expression.X)13 Type (ast.Ast.Type)11 VarDecXE (ast.Ast.VarDecXE)11 ExpCore (ast.ExpCore)11 Catch (ast.Expression.Catch)11 RoundBlock (ast.Expression.RoundBlock)11 VarDecE (ast.Ast.VarDecE)10 Doc (ast.Ast.Doc)8 Position (ast.Ast.Position)8 MethodSelectorX (ast.Ast.MethodSelectorX)7 Parameters (ast.Ast.Parameters)7 MethodWithType (ast.Expression.ClassB.MethodWithType)7 MethodType (ast.Ast.MethodType)6 ClassB (ast.ExpCore.ClassB)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Path (ast.Ast.Path)4