def visitExp(self, ctx: MPParser.ExpContext): log('visitExp') if ctx.getChildCount() == 1: # exp1 return self.visit(ctx.exp1()) left = self.visit(ctx.exp()) right = self.visit(ctx.exp1()) op = 'andthen' if ctx.op_and_then() else 'orelse' log1(left) log1(right) log1(op) return BinaryOp(op, left, right)
def visitExp(self, ctx: MPParser.ExpContext): if ctx.getChildCount() == 1: return self.visit(ctx.exp1()) else: if (ctx.AND() and ctx.THEN()): op = "andthen" elif (ctx.OR() and ctx.ELSE()): op = "orelse" return BinaryOp(op, self.visit(ctx.exp()), self.visit(ctx.exp1()))
def visitExp(self, ctx: MPParser.ExpContext): if ctx.getChildCount() == 1: return self.visit(ctx.exp1()) elif ctx.AND(): return BinaryOp("andthen", self.visit(ctx.exp()), self.visit(ctx.exp1())) elif ctx.OR(): return BinaryOp("orelse", self.visit(ctx.exp()), self.visit(ctx.exp1()))
def visitExp(self,ctx:MPParser.ExpContext): if ctx.AND() != None: return BinaryOp('andthen',self.visit(ctx.exp()),self.visit(ctx.exp1())) elif ctx.OR() != None: return BinaryOp('orelse',self.visit(ctx.exp()),self.visit(ctx.exp1())) else: return self.visit(ctx.exp1())
def visitExp(self, ctx: MPParser.ExpContext): if ctx.getChildCount() == 1: return self.visitChildren(ctx) if ctx.getChild(1) == ctx.ANDTHEN(): op = "andthen" elif ctx.getChild(1) == ctx.ORELSE(): op = "orelse" return BinaryOp(op, self.visit(ctx.exp()), self.visit(ctx.exp1()))
def visitExp(self, ctx: MPParser.ExpContext): if ctx.andthenop(): return BinaryOp('andthen', self.visit(ctx.exp()), self.visit(ctx.exp1())) elif ctx.orelseop(): return BinaryOp('orelse', self.visit(ctx.exp()), self.visit(ctx.exp1())) else: return self.visit(ctx.exp1())
def visitExp(self, ctx: MPParser.ExpContext): if ctx.exp(): if ctx.andThen(): return BinaryOp("andthen", self.visit(ctx.exp()), self.visit(ctx.exp1())) #[self.visit(ctx.exp()) + self.visit(ctx.andThen()) + self.visit(ctx.exp1())] else: return BinaryOp("orelse", self.visit(ctx.exp()), self.visit(ctx.exp1())) else: return self.visit(ctx.exp1())
def visitExp(self, ctx: MPParser.ExpContext): return IntLiteral(int(ctx.INTLIT().getText()))
def visitExp(self, ctx: MPParser.ExpContext): if (ctx.funcall()): return self.visit(ctx.funcall()) else: return IntLiteral(int(ctx.INTLIT().getText()))
def visitExp(self, ctx: MPParser.ExpContext): lst = list(zip(ctx.term()[:-1], ctx.ASSIGN()))[::-1] return functools.reduce( lambda x, y: Binary(y[1].getText(), self.visit(y[0]), x), lst, self.visit(ctx.term()[-1]))
def visitExp(self, ctx: MPParser.ExpContext): if ctx.ASSIGN(): return Binary(ctx.ASSIGN().getText(), self.visit(ctx.term()), self.visit(ctx.exp())) return self.visit(ctx.term())
def visitExp(self, ctx: MPParser.ExpContext): op = "andthen" if ctx.AND() else "orelse" return BinaryOp(op, self.visit(ctx.exp(0)), self.visit( ctx.exp(1))) if ctx.getChildCount() > 1 else self.visit( ctx.exp_one())