     { match: nextMatch, pattern: matchedPattern }
 
   getScopes: ->
-    (@parentRule?.getScopes() ? []).concat(@scopeName)
+    scopes = @parentRule?.getScopes() ? []
+    scopes = scopes.concat(@scopeName) if @scopeName
+    scopes
 
 class Pattern
   parentRule: null

  captures: null

  constructor: (@parentRule, { name, match, begin, end, captures, beginCaptures, endCaptures, patterns, include}) ->
    @scopeName = name
    if match
      @regex = new OnigRegExp(match)
      @captures = captures
      @nextRule = @parentRule
    else if begin
      @regex = new OnigRegExp(begin)
      @captures = beginCaptures ? captures
      endPattern = new Pattern(@parentRule, { name: @scopeName, match: end, captures: endCaptures ? captures })
      @nextRule = new Rule(@parentRule.grammar, {@parentRule, @scopeName, patterns, endPattern})

  getNextMatch: (line, position) ->
    {pattern: this, match: @regex?.search(line, position)}

  getTokensForMatch: (match) ->
    tokens = []


  constructor: (@grammar, {@parentRule, @scopeName, patterns, @endPattern}) ->
    patterns ?= []
    @patterns = patterns.map (pattern) => new Pattern(this, pattern)
    @patterns.push(@endPattern) if @endPattern

  getNextTokens: (line, position) ->
    { match, pattern } = @getNextMatch(line, position)
