code: func lexEscape(l *lexer) {
  	var n int
  	var base, max uint32
  
  	ch := l.next()
  	switch ch {
  	case 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', l.stringOpen:
  		return
  	case '0', '1', '2', '3', '4', '5', '6', '7':
  		n, base, max = 3, 8, 255
  	case 'x':
  		ch = l.next()
  		n, base, max = 2, 16, 255
  	case 'u':
  		ch = l.next()
  		n, base, max = 4, 16, unicode.MaxRune
  	case 'U':
  		ch = l.next()
  		n, base, max = 8, 16, unicode.MaxRune
  	case eof:
  		l.errorf("escape sequence not terminated")
  	default:
  		l.errorf("unknown escape sequence %#U", ch)
  	}
  
  	var x uint32
  	for n > 0 {
  		d := uint32(digitVal(ch))
  		if d >= base {
  			if ch == eof {
  				l.errorf("escape sequence not terminated")
  			}
  			l.errorf("illegal character %#U in escape sequence", ch)
  		}
  		x = x*base + d
  		ch = l.next()
  		n--
  	}
  
  	if x > max || 0xD800 <= x && x < 0xE000 {
  		l.errorf("escape sequence is an invalid Unicode code point")
  	}
  }
docs: // lexEscape scans a string escape sequence. The initial escaping character (\)
  // has already been seen.
  //
  // NOTE: This function as well as the helper function digitVal() and associated
  // tests have been adapted from the corresponding functions in the "go/scanner"
  // package of the Go standard library to work for Prometheus-style strings.
  // None of the actual escaping/quoting logic was changed in this function - it
  // was only modified to integrate with our lexer.