code: def apply(self, var, props, reverse=False):
          
          vs, vid = sort_vid_split(var)
          if reverse:
              # variable type mapping is disabled in reverse
              # tms = [(b, op, a) for a, op, b in self._typemap if op in _RL_OPS]
              tms = []
          else:
              tms = [(a, op, b) for a, op, b in self._typemap if op in _LR_OPS]
          for src, op, tgt in tms:
              if _valmatch([vs], src, op, None, self._semi, 'variables'):
                  vs = vs if tgt == ['*'] else tgt[0]
                  break
          newvar = '{}{}'.format(vs, vid)
  
          newprops = {}
          for featsets, valmap in self._propmap:
              if reverse:
                  tgtfeats, srcfeats = featsets
                  pms = [(b, op, a) for a, op, b in valmap if op in _RL_OPS]
              else:
                  srcfeats, tgtfeats = featsets
                  pms = [(a, op, b) for a, op, b in valmap if op in _LR_OPS]
              vals = [props.get(f) for f in srcfeats]
              for srcvals, op, tgtvals in pms:
                  if _valmatch(vals, srcvals, op, vs, self._semi, 'properties'):
                      for i, featval in enumerate(zip(tgtfeats, tgtvals)):
                          k, v = featval
                          if v == '*':
                              print(i, len(vals), vals, k, v)
                              if i < len(vals) and vals[i] is not None:
                                  newprops[k] = vals[i]
                          elif v != '!':
                              newprops[k] = v
                      break
  
          return newvar, newprops
docs: Apply the VPM to variable *var* and properties *props*.
  
          Args:
              var: a variable
              props: a dictionary mapping properties to values
              reverse: if `True`, apply the rules in reverse (e.g. from
                  grammar-external to grammar-internal forms)
          Returns:
              a tuple (v, p) of the mapped variable and properties