def visitExpr2(self, ctx: MCParser.Expr2Context): if ctx.AND(): op = ctx.AND().getText() left = self.visitExpr2(ctx.expr2()) right = self.visitExpr3(ctx.expr3()) return BinaryOp(op, left, right) else: return self.visitExpr3(ctx.expr3())
def visitExpr2(self, ctx: MCParser.Expr2Context): if (ctx.getChildCount() == 3): op = ctx.getChild(1).getText() left = self.visit(ctx.expr2()) right = self.visit(ctx.expr3()) return BinaryOp(op, left, right) else: return self.visit(ctx.expr3())
def visitExpr2(self, ctx: MCParser.Expr2Context): if ctx.LOGICAND(): return BinaryOp("&&", self.visit(ctx.expr3()), self.visit(ctx.expr2())) else: return self.visit(ctx.expr3())
def visitExpr2(self, ctx: MCParser.Expr2Context): return self.visit(ctx.expr3()) if ctx.getChildCount() == 1 else BinaryOp(ctx.AND().getText(), self.visit(ctx.expr2()), self.visit(ctx.expr3()))
def visitExpr2(self, ctx:MCParser.Expr2Context): # expr2 : expr2 AND expr3 | expr3; return BinaryOp(ctx.AND().getText(),self.visit(ctx.expr2()),self.visit(ctx.expr3())) if ctx.getChildCount() == 3 else self.visit(ctx.expr3())