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