     dict = @[pathname]
   else
     dict['f'] = pathname
+    dict['o'] = '%o'
     dict['b'] = path.basename pathname
     dict['B'] = dict['b'].replace /\..+$/, ''
 
   template.replace MistResolver.delimiterPattern, (m, p, c)->
     if c of dict then p + dict[c]
     else throw "unknown file delimiter: #{c}"
-
 MistResolver.delimitPath = MistResolver.delimitPath.bind {}
+
+###
+# Delimits a command
+#
+# command:
+#   The command to delimit
+###
+MistResolver.delimitCommand = (command)->
+  command.replace MistResolver.delimiterPattern, "$1${D_$2}"

  compile: ->
    result =
      targets: []

    compiler = (prop)-> (target)-> target[prop]

    for rule in @rootMist.rules
      if rule.src.foreach
        for input, target of rule.targets
          result.targets.push
            inputs: [input]
            dependenies: target.dependencies.compile()
            orderDependencies: target.orderDependencies.compile()

  constructor: (@rootDir, @rootMist)->
    @groupRefs = {}

    @compileCommands()
    @setupTargets()
    @generateTemplates()
    @generateTargets()

  ###
  # Compiles all commands
  ###
  compileCommands: ->
    for rule in @rootMist.rules
      rule.command =
        hash: Hasher.hash rule.src.command
        command: MistResolver.delimitCommand rule.src.command

  ###
  # Creates a targets object for each rule
