use of ast.Expression in project L42 by ElvisResearchGroup.
the class InjectionOnCore method visit.
public ExpCore visit(Expression.MCall s) {
assert !s.getPs().getE().isPresent() : s;
ExpCore receiver = s.getReceiver().accept(this);
String name = s.getName();
Doc doc = s.getDoc();
List<String> xs = s.getPs().getXs();
List<ExpCore> es = new ArrayList<>();
for (Expression e : s.getPs().getEs()) {
es.add(e.accept(this));
}
return new MCall(receiver, MethodSelector.of(name, xs), doc, es, s.getP());
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class ReplaceDots method visit.
@Override
public Expression visit(DotDotDot s) {
assert this.currentNested != null;
Path pathF = pathToFile();
Path pathD = pathToDirectory();
if (pathF != null && pathD != null) {
fail("Both file and directory present");
}
if (pathF == null && pathD == null) {
fail("File not found");
}
if (pathF != null) {
//put in subfunction
String code = L42.pathToString(pathF);
Expression e = Parser.parse(pathF.toString(), code);
auxiliaryGrammar.WellFormedness.checkAll(e);
return ReplaceDots.of(this.currentFolder, e);
}
assert pathD != null;
Path pdf = pathD.resolve("This.L42");
String code = L42.pathToString(pdf);
Expression e = Parser.parse(pdf.toString(), code);
return ReplaceDots.of(pathD, e);
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class CheckVarUsedAreInScope method of.
public static void of(Expression e, List<String> names) {
Expression old = ctx;
ctx = e;
try {
CheckVarUsedAreInScope cdv = new CheckVarUsedAreInScope();
cdv.xs.addAll(names);
e.accept(cdv);
} finally {
ctx = old;
}
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class CheckVarUsedAreInScope method visit.
public Expression visit(RoundBlock s) {
Set<String> aux = this.xs;
this.xs = new HashSet<String>(aux);
List<BlockContent> content = Map.of(this::liftBC, s.getContents());
//here should have all the accumulated vardecs
Expression inner = lift(s.getInner());
this.xs = aux;
Expression result = new RoundBlock(s.getP(), s.getDoc(), inner, content);
return result;
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class CloneVisitor method visit.
@Override
public Expression visit(RoundBlock s) {
List<BlockContent> content = Map.of(this::liftBC, s.getContents());
Expression inner = lift(s.getInner());
Expression result = new RoundBlock(s.getP(), liftDoc(s.getDoc()), inner, content);
//assert L42.checkWellFormedness(result);
return result;
}
Aggregations