def visitExpression(self, ctx: BKITParser.ExpressionContext):
        if ctx.getChildCount() == 1:
            return ctx.exp1(0).accept(self)

        left = ctx.exp1(0).accept(self)
        right = ctx.exp1(1).accept(self)
        op = ctx.getChild(1).getText()

        return BinaryOp(op, left, right)
Esempio n. 2
0
 def visitExpression(self, ctx: BKITParser.ExpressionContext):
     if ctx.getChildCount() == 3:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.expression()),
             self.visit(ctx.expression2()))
     return self.visit(ctx.expression2())
 def visitExpression(self, ctx: BKITParser.ExpressionContext):
     return ctx.exp1(0).accept(
         self) if ctx.getChildCount() == 1 else BinaryOp(
             ctx.getChild(1).getText(),
             ctx.exp1(0).accept(self),
             ctx.exp1(1).accept(self))