Пример #1
0
 def visitExp2(self, ctx: BKITParser.Exp2Context):
     if ctx.getChildCount() == 3:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.getChild(0)),
             self.visit(ctx.getChild(2)))
     else:
         return self.visit(ctx.exp3())
 def visitExp2(self, ctx: BKITParser.Exp2Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp3())
     else:
         left = self.visit(ctx.exp2())
         right = self.visit(ctx.exp3())
         return BinaryOp(ctx.getChild(1).getText(), left, right)
    def visitExp2(self, ctx: BKITParser.Exp2Context):
        if ctx.getChildCount() == 1:
            return ctx.exp3().accept(self)

        left = ctx.exp2().accept(self)
        right = ctx.exp3().accept(self)
        op = ctx.getChild(1).getText()

        return BinaryOp(op, left, right)
Пример #4
0
 def visitExp2(self, ctx: BKITParser.Exp2Context):
     if ctx.getChildCount() == 1:
         return self.visitChildren(ctx)
     return BinaryOp(
         ctx.getChild(1).getText(), self.visit(ctx.exp2()),
         self.visit(ctx.exp3()))
 def visitExp2(self, ctx: BKITParser.Exp2Context):
     return ctx.exp3().accept(
         self) if ctx.getChildCount() == 1 else BinaryOp(
             ctx.getChild(1).getText(),
             ctx.exp2().accept(self),
             ctx.exp3().accept(self))