def test_simple_positive_unary_test(self): self.check_parser('1 in <2', AST.In(AST.Number(1), AST.PositiveUnaryTests([AST.LtEp(AST.Endpoint(AST.Number(2)))]))) self.check_parser('1 in <=2', AST.In(AST.Number(1), AST.PositiveUnaryTests([AST.LteEp(AST.Endpoint(AST.Number(2)))]))) self.check_parser('1 in >2', AST.In(AST.Number(1), AST.PositiveUnaryTests([AST.GtEp(AST.Endpoint(AST.Number(2)))]))) self.check_parser('1 in >=2', AST.In(AST.Number(1), AST.PositiveUnaryTests([AST.GteEp(AST.Endpoint(AST.Number(2)))])))
def p_op_endpoint(self, p): """op_endpoint : '<' endpoint | GTE endpoint | '>' endpoint | LTE endpoint""" p[0] = { '<': AST.LtEp(p[2]), '<=': AST.LteEp(p[2]), '>': AST.GtEp(p[2]), '>=': AST.GteEp(p[2]) }[p[1]]