Пример #1
0
	def visitExpression1(self, ctx:MPParser.Expression1Context):
		if(ctx.getChildCount() == 3):
			if ctx.EQ():
				return BinaryOp("=",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
			elif ctx.NOTEQ():
				return BinaryOp("<>",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
			elif ctx.LESS():
				return BinaryOp("<",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
			elif ctx.GREATER():
				return BinaryOp(">",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
			elif ctx.LEQ():
				return BinaryOp("<=",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
			else:
				return BinaryOp(">=",self.visit(ctx.simpleExpression1(0)),self.visit(ctx.simpleExpression1(1)))
		else:
			return self.visit(ctx.simpleExpression1(0))
Пример #2
0
 def visitExpression1(self, ctx: MPParser.Expression1Context):
     #expression1:expression2 EQ expression2| expression2 NOTEQ expression2| expression2 LESS expression2
     #| expression2 GREATER expression2| expression2 LEQ expression2| expression2 GEQ expression2 | expression2
     if ctx.EQ():
         return BinaryOp("=", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     elif ctx.NOTEQ():
         return BinaryOp("<>", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     elif ctx.LESS():
         return BinaryOp("<", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     elif ctx.GREATER():
         return BinaryOp(">", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     elif ctx.LEQ():
         return BinaryOp("<=", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     elif ctx.GEQ():
         return BinaryOp(">=", self.visit(ctx.expression2(0)),
                         self.visit(ctx.expression2(1)))
     else:
         return self.visit(ctx.expression2(0))  #ctx.expression2() thì error