class RDoc::RubyLex

def identify_string(ltype, quoted = ltype)

def identify_string(ltype, quoted = ltype)
  @ltype = ltype
  @quoted = quoted
  str = if ltype == quoted then
          ltype.dup
        else
          "%#{PERCENT_PAREN_REV[quoted]}"
        end
  subtype = nil
  begin
    nest = 0
    while ch = getc
      str << ch
      if @quoted == ch and nest == 0
        break
      elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
        ch = getc
        subtype = true
        if ch == "{" then
          str << ch << skip_inner_expression
          next
        else
          ungetc
        end
      elsif ch == '\\' and @ltype == "'" #'
        case ch = getc
        when "\\", "\n", "'"
        else
          ungetc
        end
      elsif ch == '\\' #'
        str << read_escape
      end
      if PERCENT_PAREN.values.include?(@quoted)
        if PERCENT_PAREN[ch] == @quoted
          nest += 1
        elsif ch == @quoted
          nest -= 1
        end
      end
    end
    if @ltype == "/"
      if peek(0) =~ /i|m|x|o|e|s|u|n/
        getc
      end
    end
    if subtype
      Token(DLtype2Token[ltype], str)
    else
      Token(Ltype2Token[ltype], str)
    end
  ensure
    @ltype = nil
    @quoted = nil
    @lex_state = EXPR_END
  end
end