예제 #1
0
 def visitExp(self, ctx: BKITParser.ExpContext):
     if ctx.getChildCount() > 1:
         left = self.visit(ctx.exp1()[0])
         right = self.visit(ctx.exp1()[1])
         if ctx.EQ():
             op = str(ctx.EQ().getText())
         if ctx.LTE():
             op = str(ctx.LTE().getText())
         if ctx.GTE():
             op = str(ctx.GTE().getText())
         if ctx.NEQ():
             op = str(ctx.NEQ().getText())
         if ctx.LT():
             op = str(ctx.LT().getText())
         if ctx.GT():
             op = str(ctx.GT().getText())
         if ctx.LTEF():
             op = str(ctx.LTEF().getText())
         if ctx.GTEF():
             op = str(ctx.GTEF().getText())
         if ctx.NEQF():
             op = str(ctx.NEQF().getText())
         if ctx.LTF():
             op = str(ctx.LTF().getText())
         if ctx.GTF():
             op = str(ctx.GTF().getText())
         return BinaryOp(op, left, right)
     else:
         return self.visit(ctx.exp1()[0])
예제 #2
0
 def visitExp(self,ctx:BKITParser.ExpContext):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp1(0))
     else:
         if ctx.ASSIGN():
             return BinaryOp(ctx.ASSIGN().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.NOTEQ():
             return BinaryOp(ctx.NOT_EQUAL().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.LESS_THAN():
             return BinaryOp(ctx.LT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.GREATER_THAN():
             return BinaryOp(ctx.GT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.LTOE():
             return BinaryOp(ctx.ASSIGN().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.GTOE():
             return BinaryOp(ctx.GET().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.ASSIGNFLOAT():
             return BinaryOp(ctx.ASSIGNFLOAT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.LTOEFLOAT():
             return BinaryOp(ctx.LETFLOAT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.GTOEFLOAT():
             return BinaryOp(ctx.GETFLOAT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.LESS_THAN_FLOAT():
             return BinaryOp(ctx.LTFLOAT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))
         elif ctx.GREATER_THAN_FLOAT():
             return BinaryOp(ctx.GTFLOAT().getText(),self.visit(ctx.exp1(0)),self.visit(ctx.exp1(1)))