private def quote()

in rsc/src/main/scala/rsc/scan/java/Scanner.scala [412:480]


  private def quote(delim: Char): String = {
    val buf = new StringBuilder
    while (ch != delim && ch != CR && ch != LF && ch != FF && ch != SU) {
      if (ch == '\\') {
        nextChar()
        ch match {
          case 'b' =>
            nextChar()
            buf += '\b'
          case 't' =>
            nextChar()
            buf += '\t'
          case 'n' =>
            nextChar()
            buf += '\n'
          case 'f' =>
            nextChar()
            buf += '\f'
          case 'r' =>
            nextChar()
            buf += '\r'
          case '"' =>
            nextChar()
            buf += '"'
          case '\'' =>
            nextChar()
            buf += '\''
          case '\\' =>
            nextChar()
            buf += '\\'
          case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' =>
            val leadch: Char = ch
            var oct: Int = ch - '0'
            nextChar()
            if ('0' <= ch && ch <= '7') {
              oct = oct * 8 + (ch - '0')
              nextChar()
              if (leadch <= '3' && '0' <= ch && ch <= '7') {
                oct = oct * 8 + (ch - '0')
                nextChar()
              }
            }
            buf += oct.toChar
          case 'u' =>
            val uoffset = offset
            nextChar()
            var unicode: Int = 0
            var i = 0
            while (i < 4) {
              if (isHexadecimalDigit(ch)) {
                unicode = (unicode << 4) + Integer.parseInt(ch.toString, 16)
              } else {
                reportOffset(uoffset, IllegalEscape)
              }
              nextChar()
              i += 1
            }
            buf += unicode.toChar
          case other =>
            reportOffset(offset, IllegalEscape)
            nextChar()
        }
      } else {
        buf += ch
        nextChar()
      }
    }
    buf.toString
  }