Ejemplo n.º 1
0
def p_simple_num_predicate(p):
    '''simple_num_predicate : attribute_key num_comparison_op num_val
                              | num_val num_comparison_op attribute_key
                              | ANY attribute_key num_comparison_op num_val
                              | num_val num_comparison_op ANY attribute_key'''
    if (len(p) == 4):
        if (isinstance(p[1], float)):
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ExactKeyMatcher(p[3]),
                predicate.NumericValueMatcher(
                    predicate.reverse_comparison(p[2]), p[1]))
        else:
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ExactKeyMatcher(p[1]),
                predicate.NumericValueMatcher(p[2], p[3]))
    else:
        if (isinstance(p[1], float)):
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ArrayKeyMatcher(p[4]),
                predicate.NumericValueMatcher(
                    predicate.reverse_comparison(p[2]), p[1]))
        else:
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ArrayKeyMatcher(p[2]),
                predicate.NumericValueMatcher(p[3], p[4]))
Ejemplo n.º 2
0
def p_simple_bool_predicate(p):
    '''simple_bool_predicate : attribute_key bool_comparison_op bool_val
                             | bool_val bool_comparison_op attribute_key
                             | ANY attribute_key bool_comparison_op bool_val
                             | bool_val bool_comparison_op ANY attribute_key'''
    if (len(p) == 4):
        if (isinstance(p[1], bool)):
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ExactKeyMatcher(p[3]),
                predicate.BooleanValueMatcher(
                    predicate.reverse_comparison(p[2]), p[1]))
        else:
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ExactKeyMatcher(p[1]),
                predicate.BooleanValueMatcher(p[2], p[3]))
    else:
        if (isinstance(p[1], bool)):
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ArrayKeyMatcher(p[4]),
                predicate.BooleanValueMatcher(
                    predicate.reverse_comparison(p[2]), p[1]))
        else:
            p[0] = predicate.SimplePredicate(
                "placeholder", predicate.ArrayKeyMatcher(p[2]),
                predicate.BooleanValueMatcher(p[3], p[4]))
Ejemplo n.º 3
0
def p_simple_str_predicate_left(p):
    '''simple_str_predicate_left : attribute_key str_comparison_op str_val
                                 | ANY attribute_key str_comparison_op str_val'''
    if (len(p) == 4):
        p[0] = predicate.SimplePredicate(
            "placeholder", predicate.ExactKeyMatcher(p[1]),
            predicate.StringValueMatcher(p[2], p[3]))
    else:
        p[0] = predicate.SimplePredicate(
            "placeholder", predicate.ArrayKeyMatcher(p[2]),
            predicate.StringValueMatcher(p[3], p[4]))
Ejemplo n.º 4
0
def p_simple_str_predicate_right(p):
    '''simple_str_predicate_right : str_val str_comparison_op attribute_key
                                  | str_val str_comparison_op ANY attribute_key'''
    if (len(p) == 4):
        p[0] = predicate.SimplePredicate(
            "placeholder", predicate.ExactKeyMatcher(p[3]),
            predicate.StringValueMatcher(predicate.reverse_comparison(p[2]),
                                         p[1]))
    else:
        p[0] = predicate.SimplePredicate(
            "placeholder", predicate.ArrayKeyMatcher(p[4]),
            predicate.StringValueMatcher(predicate.reverse_comparison(p[2]),
                                         p[1]))