def p_common_models_motorola(self, p): """ common_models : COMMON_MODEL_MOTOROLA """ p[0] = [ ProductAttribute('brand', 'motorola'), ProductAttribute('model', p[1]) ]
def p_common_models_samsung(self, p): """ common_models : COMMON_MODEL_SAMSUNG """ p[0] = [ ProductAttribute('brand', 'samsung'), ProductAttribute('model', p[1]) ]
def p_common_models_sony(self, p): """ common_models : COMMON_MODEL_SONY """ p[0] = [ ProductAttribute('brand', 'sony'), ProductAttribute('model', p[1]) ]
def p_attribute_generation(self, p): """ attribute : NUMBER ORDINAL GENERATION | LPAREN NUMBER ORDINAL GENERATION RPAREN """ if len(p) == 6: p[0] = ProductAttribute('generation', p[2]) else: p[0] = ProductAttribute('generation', p[1])
def p_product_id(self, p): """ product_id : BRAND ATTRIB attribute_list """ p[0] = [ ProductAttribute('brand', p[1]), ProductAttribute('model', p[2]), ] if isinstance(p[3],(list,tuple)) and len(p[3]) > 0: p[0] += p[3]
def p_attribute_common_models(self, p): """ attribute : COMMON_MODEL_SAMSUNG | COMMON_MODEL_SONY | COMMON_MODEL_MOTOROLA """ p[0] = ProductAttribute('model', p[1])
def p_prod_definition(self, p): """ product : PRODUCT attribute_list """ p[0] = [ProductAttribute('product', p[1])] if isinstance(p[2], (list, tuple)) and len(p[2]) > 0: p[0] = p[0] + p[2] p[0] = [Product(p[0])]
def p_prod_definition(self, p): """ product : PRODUCT product_prefix_list product_id attribute_list | SMARTPHONE product_prefix_list product_id attribute_list """ p[0] = [ ProductAttribute('product', p[1]) ] if isinstance(p[2],(list,tuple)) and len(p[2]) > 0: p[0] = p[0] + p[2] if isinstance(p[3],(list,tuple)) and len(p[3]) > 0: p[0] = p[0] + p[3] if isinstance(p[4],(list,tuple)) and len(p[4]) > 0: p[0] = p[0] + p[4]
def p_attribute_provider(self, p): """ attribute : PROVIDER """ p[0] = ProductAttribute('provider', p[1])
def p_attribute_product(self, p): """ attribute : PRODUCT """ p[0] = ProductAttribute('product', p[1])
def p_attribute_waterproof(self, p): """ attribute : WATERPROOF """ p[0] = ProductAttribute('waterproof', 1)
def p_attribute_mp3_player(self, p): """ attribute : MP NUMBER """ p[0] = ProductAttribute('mp3_player', 1)
def p_attribute_color(self, p): """ attribute : COLOR """ p[0] = ProductAttribute('color', p[1])
def p_attribute_tech(self, p): """ attribute : TECHNOLOGY """ p[0] = ProductAttribute('technology', p[1])
def p_product_prefix_provider(self, p): """ product_prefix : PROVIDER """ p[0] = ProductAttribute('provider', p[1])
def p_product_prefix_numchip(self, p): """ product_prefix : NUMCHIP """ p[0] = ProductAttribute('numchip', p[1])
def p_product_prefix_unlocked(self, p): """ product_prefix : UNLOCKED """ p[0] = ProductAttribute('unlocked', 1)
def p_attribute_numchip(self, p): """ attribute : NUMCHIP """ p[0] = ProductAttribute('numchip', p[1])
def p_attribute_name(self, p): """ attribute : ATTRIB """ p[0] = ProductAttribute('generic', p[1])
def p_attribute_lock(self, p): """ attribute : UNLOCKED """ p[0] = ProductAttribute('unlocked', 1)
def p_attribute_number_rep(self, p): """ attribute : NUMBER | FLOAT """ p[0] = ProductAttribute('generic_num', p[1])
def p_attribute_gps(self, p): """ attribute : GPS """ p[0] = ProductAttribute('gps', 1)
def p_attribute_screen_diagonal(self, p): """ attribute : NUMBER INCHES | FLOAT INCHES """ p[0] = ProductAttribute('screen_diagonal', p[1])
def p_attribute_camera_resolution(self, p): """ camera_resolution : NUMBER MP | FLOAT MP """ p[0] = ProductAttribute('camera_resolution', p[1])
def p_attribute_operating_system(self, p): """ attribute : OS_NAME NUMBER | OS_NAME FLOAT """ p[0] = ProductAttribute('operating_system', p[1])
def p_attribute_brand(self, p): """ attribute : BRAND """ p[0] = ProductAttribute('brand', p[1])
def p_attribute_processor_type(self, p): """ attribute : PROCESSOR_TYPE """ p[0] = ProductAttribute('processor_numcore', p[1])
def p_attribute_smartphone(self, p): """ attribute : SMARTPHONE | LPAREN SMARTPHONE RPAREN """ p[0] = ProductAttribute('product', 'smartphone')
def p_attribute_storage(self, p): """ attribute : NUMBER GIGABYTES """ p[0] = ProductAttribute('storage', p[1])