629 scanLitChar(pos);
630 if (reader.ch == '\'') {
631 reader.scanChar();
632 tk = TokenKind.CHARLITERAL;
633 } else {
634 lexError(pos, Errors.UnclosedCharLit);
635 }
636 }
637 break loop;
638 case '\"':
639 reader.scanChar();
640 while (reader.ch != '\"' && reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen)
641 scanLitChar(pos);
642 if (reader.ch == '\"') {
643 tk = TokenKind.STRINGLITERAL;
644 reader.scanChar();
645 } else {
646 lexError(pos, Errors.UnclosedStrLit);
647 }
648 break loop;
649 default:
650 if (isSpecial(reader.ch)) {
651 scanOperator();
652 } else {
653 boolean isJavaIdentifierStart;
654 int codePoint = -1;
655 if (reader.ch < '\u0080') {
656 // all ASCII range chars already handled, above
657 isJavaIdentifierStart = false;
658 } else {
659 codePoint = reader.peekSurrogates();
660 if (codePoint >= 0) {
661 if (isJavaIdentifierStart = Character.isJavaIdentifierStart(codePoint)) {
662 reader.putChar(true);
663 }
664 } else {
665 isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch);
666 }
667 }
668 if (isJavaIdentifierStart) {
|
629 scanLitChar(pos);
630 if (reader.ch == '\'') {
631 reader.scanChar();
632 tk = TokenKind.CHARLITERAL;
633 } else {
634 lexError(pos, Errors.UnclosedCharLit);
635 }
636 }
637 break loop;
638 case '\"':
639 reader.scanChar();
640 while (reader.ch != '\"' && reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen)
641 scanLitChar(pos);
642 if (reader.ch == '\"') {
643 tk = TokenKind.STRINGLITERAL;
644 reader.scanChar();
645 } else {
646 lexError(pos, Errors.UnclosedStrLit);
647 }
648 break loop;
649 case '`':
650 checkSourceLevel(pos, Feature.RAW_STRING_LITERALS);
651 // Ensure that the backtick was not a Unicode escape sequence
652 if (reader.peekBack() != '`') {
653 reader.scanChar();
654 lexError(pos, Errors.UnicodeBacktick);
655 break loop;
656 }
657 // Turn off unicode processsing and save previous state
658 boolean oldState = reader.setUnicodeConversion(false);
659 // Count the number of backticks in the open quote sequence
660 int openCount = reader.skipRepeats();
661 // Skip last backtick
662 reader.scanChar();
663 while (reader.bp < reader.buflen) {
664 // If potential close quote sequence
665 if (reader.ch == '`') {
666 // Count number of backticks in sequence
667 int closeCount = reader.skipRepeats();
668 // If the counts match we can exit the raw string literal
669 if (openCount == closeCount) {
670 break;
671 }
672 // Emit non-close backtick sequence
673 for (int i = 0; i <= closeCount; i++) {
674 reader.putChar('`', false);
675 }
676 // Skip last backtick
677 reader.scanChar();
678 } else if (reader.ch == LF) {
679 reader.putChar(true);
680 processLineTerminator(pos, reader.bp);
681 } else if (reader.ch == CR) {
682 if (reader.peekChar() == LF) {
683 reader.scanChar();
684 }
685 // Translate CR and CRLF sequences to LF
686 reader.putChar('\n', true);
687 processLineTerminator(pos, reader.bp);
688 } else {
689 reader.putChar(true);
690 }
691 }
692 // Restore unicode processsing
693 reader.setUnicodeConversion(oldState);
694 // Ensure the close quote was encountered
695 if (reader.bp == reader.buflen) {
696 lexError(pos, Errors.UnclosedStrLit);
697 } else {
698 tk = TokenKind.STRINGLITERAL;
699 reader.scanChar();
700 }
701 break loop;
702 default:
703 if (isSpecial(reader.ch)) {
704 scanOperator();
705 } else {
706 boolean isJavaIdentifierStart;
707 int codePoint = -1;
708 if (reader.ch < '\u0080') {
709 // all ASCII range chars already handled, above
710 isJavaIdentifierStart = false;
711 } else {
712 codePoint = reader.peekSurrogates();
713 if (codePoint >= 0) {
714 if (isJavaIdentifierStart = Character.isJavaIdentifierStart(codePoint)) {
715 reader.putChar(true);
716 }
717 } else {
718 isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch);
719 }
720 }
721 if (isJavaIdentifierStart) {
|