def p_dimlist(p):
 if (len(p) == 4):
  p[0] = p[1]
  p[0].append(p[3])
 else:
  p[0] = [p[1]]

def p_dimlist ( p ) : if ( len ( p ) == 4 ) : p [ 0 ] = p [ 1 ] p [ 0 ] . append ( p [ 3 ] ) else : p [ 0 ] = [ p [ 1 ] ]
dimlist : dimlist comma dimitem | dimitem .