Пример #1
0
 def p_common_models_motorola(self, p):
     """
     common_models : COMMON_MODEL_MOTOROLA
     """
     p[0] = [
         ProductAttribute('brand', 'motorola'),
         ProductAttribute('model', p[1])
     ]
Пример #2
0
 def p_common_models_samsung(self, p):
     """
     common_models : COMMON_MODEL_SAMSUNG
     """
     p[0] = [
         ProductAttribute('brand', 'samsung'),
         ProductAttribute('model', p[1])
     ]
Пример #3
0
 def p_common_models_sony(self, p):
     """
     common_models : COMMON_MODEL_SONY
     """
     p[0] = [
         ProductAttribute('brand', 'sony'),
         ProductAttribute('model', p[1])
     ]
Пример #4
0
 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])
Пример #5
0
 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]
Пример #6
0
 def p_attribute_common_models(self, p):
     """
     attribute : COMMON_MODEL_SAMSUNG
               | COMMON_MODEL_SONY
               | COMMON_MODEL_MOTOROLA
     """
     p[0] = ProductAttribute('model', p[1])
Пример #7
0
 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])]
Пример #8
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]
Пример #9
0
 def p_attribute_provider(self, p):
     """
     attribute : PROVIDER          
     """
     p[0] = ProductAttribute('provider', p[1])
Пример #10
0
 def p_attribute_product(self, p):
     """
     attribute : PRODUCT
     """
     p[0] = ProductAttribute('product', p[1])
Пример #11
0
 def p_attribute_waterproof(self, p):
     """
     attribute : WATERPROOF
     """
     p[0] = ProductAttribute('waterproof', 1)
Пример #12
0
 def p_attribute_mp3_player(self, p):
     """
     attribute : MP NUMBER
     """
     p[0] = ProductAttribute('mp3_player', 1)
Пример #13
0
 def p_attribute_color(self, p):
     """
     attribute : COLOR
     """
     p[0] = ProductAttribute('color', p[1])
Пример #14
0
 def p_attribute_tech(self, p):
     """
     attribute : TECHNOLOGY
     """
     p[0] = ProductAttribute('technology', p[1])
Пример #15
0
 def p_product_prefix_provider(self, p):
     """
     product_prefix : PROVIDER          
     """
     p[0] = ProductAttribute('provider', p[1])
Пример #16
0
 def p_product_prefix_numchip(self, p):
     """
     product_prefix : NUMCHIP           
     """
     p[0] = ProductAttribute('numchip', p[1])
Пример #17
0
 def p_product_prefix_unlocked(self, p):
     """
     product_prefix : UNLOCKED           
     """
     p[0] = ProductAttribute('unlocked', 1)
Пример #18
0
 def p_attribute_numchip(self, p):
     """
     attribute : NUMCHIP
     """
     p[0] = ProductAttribute('numchip', p[1])
Пример #19
0
 def p_attribute_name(self, p):
     """
     attribute : ATTRIB
     """
     p[0] = ProductAttribute('generic', p[1])
Пример #20
0
 def p_attribute_lock(self, p):
     """
     attribute : UNLOCKED
     """
     p[0] = ProductAttribute('unlocked', 1)
Пример #21
0
 def p_attribute_number_rep(self, p):
     """
     attribute : NUMBER
               | FLOAT
     """
     p[0] = ProductAttribute('generic_num', p[1])
Пример #22
0
 def p_attribute_gps(self, p):
     """
     attribute : GPS
     """
     p[0] = ProductAttribute('gps', 1)
Пример #23
0
 def p_attribute_screen_diagonal(self, p):
     """
     attribute    : NUMBER INCHES
                  | FLOAT  INCHES
     """
     p[0] = ProductAttribute('screen_diagonal', p[1])
Пример #24
0
 def p_attribute_camera_resolution(self, p):
     """
     camera_resolution : NUMBER MP
                       | FLOAT  MP
     """
     p[0] = ProductAttribute('camera_resolution', p[1])
Пример #25
0
 def p_attribute_operating_system(self, p):
     """
     attribute  : OS_NAME NUMBER
                | OS_NAME FLOAT
     """
     p[0] = ProductAttribute('operating_system', p[1])
Пример #26
0
 def p_attribute_brand(self, p):
     """
     attribute : BRAND
     """
     p[0] = ProductAttribute('brand', p[1])
Пример #27
0
 def p_attribute_processor_type(self, p):
     """
     attribute  : PROCESSOR_TYPE
     """
     p[0] = ProductAttribute('processor_numcore', p[1]) 
Пример #28
0
 def p_attribute_smartphone(self, p):
     """
     attribute : SMARTPHONE
               | LPAREN SMARTPHONE RPAREN 
     """
     p[0] = ProductAttribute('product', 'smartphone')
Пример #29
0
 def p_attribute_storage(self, p):
     """
     attribute  :  NUMBER GIGABYTES
     """
     p[0] = ProductAttribute('storage', p[1])