def visitExp4(self, ctx: BKITParser.Exp4Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp5())
     else:
         op = ctx.NOT().getText()
         body = self.visit(ctx.exp4())
         return UnaryOp(op, body)
    def visitExp4(self, ctx: BKITParser.Exp4Context):
        if ctx.getChildCount() == 1:
            return ctx.exp5().accept(self)

        op = ctx.getChild(0).getText()
        body = ctx.exp4().accept(self)
        return UnaryOp(op, body)
Ejemplo n.º 3
0
 def visitExp4(self,ctx:BKITParser.Exp4Context):
     if ctx.NOT():
         return UnaryOp(
             ctx.NOT().getText(),
             self.visitExp4(ctx.exp4())
         )
     else:
         return self.visitExp5(ctx.exp5())
Ejemplo n.º 4
0
 def visitExp4(self, ctx: BKITParser.Exp4Context):
     if ctx.getChildCount() > 1:
         body = self.visit(ctx.exp4())
         if ctx.NOT():
             op = str(ctx.NOT().getText())
         if ctx.SUB():
             op = str(ctx.SUB().getText())
         return UnaryOp(op, body)
     else:
         return self.visit(ctx.exp5())
 def visitExp4(self, ctx: BKITParser.Exp4Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp5())
     return UnaryOp(ctx.NEGATION().getText(), self.visit(ctx.exp4()))
Ejemplo n.º 6
0
 def visitExp4(self, ctx: BKITParser.Exp4Context):
     if ctx.getChildCount() == 2:
         return UnaryOp(
             ctx.getChild(0).getText(), self.visit(ctx.getChild(1)))
     else:
         return self.visit(ctx.exp5())
 def visitExp4(self, ctx: BKITParser.Exp4Context):
     return ctx.exp5().accept(
         self) if ctx.getChildCount() == 1 else UnaryOp(
             ctx.getChild(0).getText(),
             ctx.exp4().accept(self))
Ejemplo n.º 8
0
 def visitExp4(self, ctx: BKITParser.Exp4Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp5())
     if ctx.MulFloat():
         op = ctx.MulFloat().getText()
     elif ctx.MulInt():
         op = ctx.MulInt().getText()
     elif ctx.Modulus():
         op = ctx.Modulus().getText()
     elif ctx.DivFloat():
         op = ctx.DivFloat().getText()
     elif ctx.DivInt():
         op = ctx.DivInt().getText()
     return BinaryOp(op, self.visit(ctx.exp4()), self.visit(ctx.exp5()))