示例#1
0
 def visitExp4(self, ctx: MCParser.Exp4Context):
     # exp4: exp5 (LESS|LESSEQ|GREA|GREAEQ) exp5 | exp5;
     if (ctx.LESS()):
         return BinaryOp(ctx.LESS().getText(), self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif (ctx.LESSEQ()):
         return BinaryOp(ctx.LESSEQ().getText(), self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif (ctx.GREA()):
         return BinaryOp(ctx.GREA().getText(), self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif (ctx.GREAEQ()):
         return BinaryOp(ctx.GREAEQ().getText(), self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     else:
         return self.visit(ctx.exp5(0))
 def visitExp4(self, ctx: MCParser.Exp4Context):
     #exp4: exp5 (LESS|LESSEQUAL|GREATER|GREATEREQUAL) exp5 | exp5;
     if ctx.getChildCount() == 3:
         if ctx.LESS():
             return BinaryOp(ctx.LESS().getText(), self.visit(ctx.exp5(0)),
                             self.visit(ctx.exp5(1)))
         if ctx.LESSEQUAL():
             return BinaryOp(ctx.LESSEQUAL().getText(),
                             self.visit(ctx.exp5(0)),
                             self.visit(ctx.exp5(1)))
         if ctx.GREATER():
             return BinaryOp(ctx.GREATER().getText(),
                             self.visit(ctx.exp5(0)),
                             self.visit(ctx.exp5(1)))
         if ctx.GREATEREQUAL():
             return BinaryOp(ctx.GREATEREQUAL().getText(),
                             self.visit(ctx.exp5(0)),
                             self.visit(ctx.exp5(1)))
     else:
         return self.visit(ctx.exp5(0))
示例#3
0
 def visitExp4(self, ctx: MCParser.Exp4Context):
     if ctx.LESS():
         return BinaryOp("<", self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif ctx.GREATER():
         return BinaryOp(">", self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif ctx.LESS_EQUAL():
         return BinaryOp("<=", self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     elif ctx.GREATER_EQUAL():
         return BinaryOp(">=", self.visit(ctx.exp5(0)),
                         self.visit(ctx.exp5(1)))
     else:
         return self.visit(ctx.exp5(0))