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()));
}
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());
}
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;
}
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;
}
}
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;
}
Aggregations