Ejemplo n.º 1
0
def make_range_list(*values):
    ranges = []
    for v in values:
        if isinstance(v, int):
            val_node = plural.value_node(v)
            ranges.append((val_node, val_node))
        else:
            assert isinstance(v, tuple)
            ranges.append((plural.value_node(v[0]), plural.value_node(v[1])))
    return plural.range_list_node(ranges)
Ejemplo n.º 2
0
def make_range_list(*values):
    ranges = []
    for v in values:
        if isinstance(v, int):
            val_node = plural.value_node(v)
            ranges.append((val_node, val_node))
        else:
            assert isinstance(v, tuple)
            ranges.append((plural.value_node(v[0]),
                           plural.value_node(v[1])))
    return plural.range_list_node(ranges)
Ejemplo n.º 3
0
 def test_or_and(self):
     assert plural._Parser('n = 0 or n != 1 and n % 100 = 1..19').ast == \
         ('or', (self.n_eq(0),
                 ('and', (plural.negate(self.n_eq(1)),
                          ('relation', ('in',
                                        ('mod', (self.n,
                                                 plural.value_node(100))),
                                        (make_range_list((1, 19)))))))
                 ))
Ejemplo n.º 4
0
 def test_or_and(self):
     assert plural._Parser('n = 0 or n != 1 and n % 100 = 1..19').ast == \
         ('or', (self.n_eq(0),
                 ('and', (plural.negate(self.n_eq(1)),
                          ('relation', ('in',
                                        ('mod', (self.n,
                                                 plural.value_node(100))),
                                        (make_range_list((1, 19)))))))
                 ))