 
   getRegexPatternPairs: (included) ->
     if @include
-      @grammar.ruleForInclude(@include).getRegexPatternPairs(included)
+      rule = @grammar.ruleForInclude(@include)
+      console.log "Could not find rule for include #{@include} in #{@grammar.name} grammar" unless rule
+      rule?.getRegexPatternPairs(included) ? []
     else
       [[@regex, this]]
+
+  compileRegex: ->
+    @pushRule?.compileRegex()
 
   getNextMatch: (line, position) ->
     if @include

      currentCaptureIndex += 1 + regex.getCaptureCount()
    @regex = new OnigRegExp('(' + regexComponents.join(')|(') + ')')

  getRegexPatternPairs: (included=[]) ->
    return [] if _.include(included, this)
    included.push(this)
    regexPatternPairs = []
    for pattern in @patterns
      regexPatternPairs.push(pattern.getRegexPatternPairs(included)...)
    regexPatternPairs

    previousCaptureEndPosition = 0
    if tree.captures
      for capture in tree.captures
        continue unless capture.text.length # TODO: This can be removed since the tree will have no empty captures

        currentCaptureStartPosition = capture.position - tree.position
        if previousCaptureEndPosition < currentCaptureStartPosition
