   dict = MistResolver.generateDict pathname
 
   template.replace MistResolver.delimiterPattern, (m, p, c)->
-    if c of dict then (p || '') + dict[c]
+    c = (p || '') + c
+    if c of dict then dict[c]
     else throw "unknown file delimiter: #{c}"
 
 ###

  if pathname of @
    dict = @[pathname]
  else
    dict['f'] = pathname
    dict['o'] = '%o'
    dict['O'] = '%O'
    dict['b'] = path.basename pathname
    dict['B'] = dict['b'].replace /\..+$/, ''
  return dict
MistResolver.generateDict = MistResolver.generateDict.bind {}


#   The command to delimit
###
MistResolver.delimitCommand = (command)->
  command.replace MistResolver.delimiterPattern, (m, c, d)->
    if d is '%' then '%'
    c = (c || '').replace '-', '_'
    "${D_#{c}#{d}}"

MistResolver.compileVars = (inputs, outputs)->
  result = {}
  outputDirs = outputs.map path.dirname
  for input in inputs.map MistResolver.generateDict
    for k, v of input
      if k is '%' then continue
      if k is 'o' then v = outputs
      if k is 'O' then v = outputDirs
      k = k.replace '-', '_'
      k = "D_#{k}"
      result[k] = [] if k not of result
      result[k] = result[k].concat v
