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)
コード例 #2
0
 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))