 shiftCapture = (captureIndices) ->
   [captureIndices.shift(), captureIndices.shift(), captureIndices.shift()]
 
+scopesFromStack = (stack) ->
+  _.compact(_.pluck(stack, "scopeName"))
+

      { match: @regex.getCaptureIndices(line, position), pattern: this }

  handleMatch: (stack, line, captureIndices) ->
    scopes = _.pluck(stack, "scopeName")
    scopes.push(@scopeName) if @scopeName and not @popRule

    if @captures

    position = 0

    loop
      scopes = scopesFromStack(stack)

      if line.length == 0
        tokens = [{value: "", scopes: scopes}]
