Search in sources :

Example 21 with Expression

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());
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) ArrayList(java.util.ArrayList) Doc(ast.Ast.Doc)

Example 22 with Expression

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);
}
Also used : Path(java.nio.file.Path) Expression(ast.Expression)

Example 23 with Expression

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;
    }
}
Also used : Expression(ast.Expression)

Example 24 with Expression

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;
}
Also used : Expression(ast.Expression)

Example 25 with Expression

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;
}
Also used : 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