def expand(self, default_file, default_mask_file, poslist, id_dict): # create new struct, needed for template expansion new_mapping = [] for old_assignment in self.mapping: from_min_value = old_assignment.name.min.reduce_constant([id_dict]) from_max_value = from_min_value if old_assignment.name.max is None else old_assignment.name.max.reduce_constant( [id_dict]) to_min_value = old_assignment.value.min.reduce_constant([id_dict]) to_max_value = None if old_assignment.value.max is None else old_assignment.value.max.reduce_constant( [id_dict]) new_mapping.append( assignment.Assignment( assignment.Range(from_min_value, from_max_value), assignment.Range(to_min_value, to_max_value), old_assignment.pos)) return [RecolourSprite(new_mapping, poslist=poslist)]
def p_recolour_assignment_3(self, t): "recolour_assignment : expression RANGE expression COLON expression SEMICOLON" t[0] = assignment.Assignment(assignment.Range(t[1], t[3]), assignment.Range(t[5], None), t[1].pos)
def p_recolour_assignment_2(self, t): 'recolour_assignment : expression RANGE expression COLON expression RANGE expression SEMICOLON' t[0] = assignment.Assignment(assignment.Range(t[1], t[3]), assignment.Range(t[5], t[7]), t[1].pos)
def p_recolour_assignment_1(self, t): 'recolour_assignment : expression COLON expression SEMICOLON' t[0] = assignment.Assignment(assignment.Range(t[1], None), assignment.Range(t[3], None), t[1].pos)