class CodeRay::Scanners::Ruby::StringState

def self.simple_key_pattern delim

def self.simple_key_pattern delim
  if delim == "'"
    / (?> (?: [^\\']+ | \\. )* ) ' : /mx
  else
    / (?> (?: [^\\"\#]+ | \\. | \#\$[\\"] | \#\{[^\{\}]+\} | \#(?!\{) )* ) " : /mx
  end
end

def heredoc_pattern delim, interpreted, indented

def heredoc_pattern delim, interpreted, indented
  # delim = delim.dup  # workaround for old Ruby
  delim_pattern = Regexp.escape(delim)
  delim_pattern = / (?:\A|\n) #{ '(?>[ \t]*)' if indented } #{ Regexp.new delim_pattern } $ /x
  if interpreted
    / (?= #{delim_pattern}() | \\ | \# [{$@] ) /mx  # $1 set == end of heredoc
  else
    / (?= #{delim_pattern}() | \\ ) /mx
  end
end

def initialize kind, interpreted, delim, heredoc = false

def initialize kind, interpreted, delim, heredoc = false
  if heredoc
    pattern = heredoc_pattern delim, interpreted, heredoc == :indented
    delim = nil
  else
    pattern = STRING_PATTERN[ [delim, interpreted] ]
    if closing_paren = CLOSING_PAREN[delim]
      opening_paren = delim
      delim = closing_paren
      paren_depth = 1
    end
  end
  super kind, interpreted, delim, heredoc, opening_paren, paren_depth, pattern, :initial
end