Search in sources :

Example 1 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class InjectionOnSugar method visit.

@Override
public Expression visit(Using s) {
    List<String> xs = s.getS().getNames();
    List<ast.ExpCore> es1 = s.getEs();
    List<ast.Expression> es = new ArrayList<ast.Expression>();
    for (ast.ExpCore e : es1) {
        es.add(lift(e));
    }
    ast.Ast.Parameters ps = new ast.Ast.Parameters(Optional.<ast.Expression>empty(), xs, es);
    return new Expression.Using(s.getPath(), s.getS().nameToS(), s.getDoc(), ps, lift(s.getInner()));
}
Also used : ExpCore(ast.ExpCore) Ast(ast.Ast) Using(ast.ExpCore.Using) ArrayList(java.util.ArrayList) ExpCore(ast.ExpCore) Expression(ast.Expression)

Example 2 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class InjectionOnSugar method visit.

@Override
public Expression visit(ClassB s) {
    Doc doc1 = s.getDoc1();
    Header h = (s.isInterface()) ? new Ast.InterfaceHeader() : new Ast.TraitHeader();
    List<Type> supertypes = s.getSupertypes();
    List<Member> members = new ArrayList<>();
    for (ast.ExpCore.ClassB.Member mi : s.getMs()) {
        members.add(mi.match(nc -> new Expression.ClassB.NestedClass(nc.getDoc(), nc.getName(), lift(nc.getInner()), nc.getP()), mimpl -> new Expression.ClassB.MethodImplemented(mimpl.getDoc(), mimpl.getS(), lift(mimpl.getInner()), mimpl.getP()), mwt -> {
            Doc idoc = mwt.getDoc();
            MethodSelector is = mwt.getMs();
            MethodType mt = mwt.getMt();
            return new Expression.ClassB.MethodWithType(idoc, is, mt, lift(mwt.get_inner()), mwt.getP());
        }));
    }
    return new Expression.ClassB(doc1, h, Collections.emptyList(), supertypes, members, s.getP());
}
Also used : VarDecXE(ast.Ast.VarDecXE) UpdateVar(ast.ExpCore.UpdateVar) Ast(ast.Ast) Header(ast.Ast.Header) MCall(ast.ExpCore.MCall) Type(ast.Ast.Type) Member(ast.Expression.ClassB.Member) WellFormedness(auxiliaryGrammar.WellFormedness) MethodType(ast.Ast.MethodType) Loop(ast.ExpCore.Loop) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) Visitor(coreVisitors.Visitor) ClassB(ast.ExpCore.ClassB) WalkBy(ast.ExpCore.WalkBy) Mdf(ast.Ast.Mdf) X(ast.ExpCore.X) VarDec(ast.Ast.VarDec) Path(ast.Ast.Path) Signal(ast.ExpCore.Signal) Match(tools.Match) Doc(ast.Ast.Doc) ExpCore._void(ast.ExpCore._void) ExpCore(ast.ExpCore) Block(ast.ExpCore.Block) Expression(ast.Expression) List(java.util.List) Position(ast.Ast.Position) Using(ast.ExpCore.Using) Optional(java.util.Optional) Collections(java.util.Collections) MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) Ast(ast.Ast) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Header(ast.Ast.Header) Expression(ast.Expression) Doc(ast.Ast.Doc) Member(ast.Expression.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 3 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class InjectionOnSugar method injectionCatch.

private List<Expression.Catch> injectionCatch(List<ast.ExpCore.Block.On> list) {
    if (list.isEmpty()) {
        return Collections.emptyList();
    }
    List<Expression.Catch> ks = new ArrayList<>();
    for (ast.ExpCore.Block.On on : list) {
        Expression inner = lift(on.getInner());
        ks.add(new Expression.Catch1(on.getP(), on.getKind(), on.getT(), on.getX(), inner));
    }
    return ks;
}
Also used : Expression(ast.Expression) ArrayList(java.util.ArrayList) Block(ast.ExpCore.Block)

Example 4 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class Parser method parse.

public static synchronized Expression parse(String fileName, String s) {
    String old = Parser.fileName;
    Parser.fileName = fileName;
    try {
        checkForTab(s);
        checkForBalancedParenthesis(s);
        s = replaceORoundWithTab(s);
        NudeEContext ctxResult = parseCtx(s);
        Expression result = ctxResult.accept(new ToAst());
        return result;
    } finally {
        Parser.fileName = old;
    }
}
Also used : NudeEContext(antlrGenerated.L42Parser.NudeEContext) ToAst(sugarVisitors.ToAst) Expression(ast.Expression)

Example 5 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class OnLineCodeHelper method load.

private static Expression load(String name) {
    //URL res = OnLineCode.class.getResource(name+".L42");
    //Path res = L42.path.resolve(name+".L42");
    Path res = Paths.get("localhost", name + ".L42");
    assert res != null : name;
    String s = L42.pathToString(res);
    Expression e = Parser.parse(res.toString(), s);
    assert WellFormedness.checkAll(e);
    return e;
}
Also used : Path(java.nio.file.Path) Expression(ast.Expression)

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