Search in sources :

Example 61 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class ToAst method visitMxRound.

@Override
public Expression visitMxRound(MxRoundContext ctx) {
    String mx = ctx.MX().getText();
    assert mx.endsWith("(");
    mx = mx.substring(0, mx.length() - 1);
    RoundContext r = ctx.round();
    Doc doc = parseDoc(r.docsOpt());
    assert !mx.startsWith("#");
    assert !mx.startsWith("\\");
    Expression rcv = new Expression.X(position(ctx), mx);
    //Expression rcv= (mx.startsWith("#"))?new Expression.ContextId(mx):new Expression.X(mx);
    return new Expression.FCall(position(r), rcv, doc, parseMParameters(r.ps()));
}
Also used : Expression(ast.Expression) MethodSelectorX(ast.Ast.MethodSelectorX) Doc(ast.Ast.Doc)

Example 62 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class ToAst method visitRoundBlockAux.

private Expression visitRoundBlockAux(ParserRuleContext ctx, DocsOptContext docsOpt, List<BbContext> bB, ETopContext eTop) {
    Doc doc = parseDoc(docsOpt);
    List<BlockContent> contents = new ArrayList<BlockContent>();
    for (BbContext b : bB) {
        List<VarDec> decs = new ArrayList<VarDec>();
        for (DContext d : b.d()) {
            decs.add(parseVDec(d));
        }
        assert b.ks() != null;
        List<Catch> _catch = parseKs(b.ks());
        contents.add(new BlockContent(decs, _catch));
    }
    Expression inner = eTop.accept(this);
    return new Expression.RoundBlock(position(ctx), doc, inner, contents);
}
Also used : Expression(ast.Expression) Catch(ast.Expression.Catch) VarDec(ast.Ast.VarDec) BlockContent(ast.Expression.BlockContent) Doc(ast.Ast.Doc)

Example 63 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class ToAst method visitBinOp.

private Expression visitBinOp(ParserRuleContext ctx) {
    LinkedList<ParseTree> stack = this.getStack(ctx);
    Expression current = stack.pop().accept(this);
    while (!stack.isEmpty()) {
        current = new Expression.BinOp(position(ctx), current, Op.fromString(stack.pop().getText()), ToAst.parseDoc(stack.pop()), stack.pop().accept(this));
    }
    if (current instanceof Expression.BinOp) {
        current = onNeedMakeRightAssociative((Expression.BinOp) current);
    }
    return current;
}
Also used : Expression(ast.Expression)

Example 64 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class ToAst method visitEUnOp.

@Override
public Expression visitEUnOp(EUnOpContext ctx) {
    Expression e = ctx.ePost().accept(this);
    Token t = null;
    try {
        t = (Token) ((TerminalNode) ctx.children.get(0)).getPayload();
    } catch (ClassCastException ignored) {
    }
    if (t != null && t.getType() == L42Lexer.UnOp) {
        e = new Expression.UnOp(position(ctx), Op.fromString(t.getText()), e);
    }
    return e;
}
Also used : Expression(ast.Expression)

Example 65 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class ToAst method parseRealVDec.

private VarDecXE parseRealVDec(VarDecContext vd) {
    TContext tt = vd.t();
    Optional<Type> t = (tt == null) ? Optional.<Type>empty() : Optional.of(parseType(tt));
    Expression inner = vd.eTop().accept(this);
    return new Ast.VarDecXE(vd.Var() != null, t, nameL(vd.x()), inner);
}
Also used : Type(ast.Ast.Type) Expression(ast.Expression) VarDecXE(ast.Ast.VarDecXE)

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