langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
changeset 25600 7f93cb0536fd
parent 25445 603f0c93d5c9
equal deleted inserted replaced
25456:39cfdc2dcaf3 25600:7f93cb0536fd
   211             skipIllegalUnderscores();
   211             skipIllegalUnderscores();
   212             if (reader.ch == '+' || reader.ch == '-') {
   212             if (reader.ch == '+' || reader.ch == '-') {
   213                 reader.putChar(true);
   213                 reader.putChar(true);
   214             }
   214             }
   215             skipIllegalUnderscores();
   215             skipIllegalUnderscores();
   216             if ('0' <= reader.ch && reader.ch <= '9') {
   216             if (reader.digit(pos, 10) >= 0) {
   217                 scanDigits(pos, 10);
   217                 scanDigits(pos, 10);
   218                 if (!hexFloatsWork)
   218                 if (!hexFloatsWork)
   219                     lexError(pos, "unsupported.cross.fp.lit");
   219                     lexError(pos, "unsupported.cross.fp.lit");
   220             } else
   220             } else
   221                 lexError(pos, "malformed.fp.lit");
   221                 lexError(pos, "malformed.fp.lit");
   237 
   237 
   238     /** Read fractional part of floating point number.
   238     /** Read fractional part of floating point number.
   239      */
   239      */
   240     private void scanFraction(int pos) {
   240     private void scanFraction(int pos) {
   241         skipIllegalUnderscores();
   241         skipIllegalUnderscores();
   242         if ('0' <= reader.ch && reader.ch <= '9') {
   242         if (reader.digit(pos, 10) >= 0) {
   243             scanDigits(pos, 10);
   243             scanDigits(pos, 10);
   244         }
   244         }
   245         int sp1 = reader.sp;
   245         int sp1 = reader.sp;
   246         if (reader.ch == 'e' || reader.ch == 'E') {
   246         if (reader.ch == 'e' || reader.ch == 'E') {
   247             reader.putChar(true);
   247             reader.putChar(true);
   248             skipIllegalUnderscores();
   248             skipIllegalUnderscores();
   249             if (reader.ch == '+' || reader.ch == '-') {
   249             if (reader.ch == '+' || reader.ch == '-') {
   250                 reader.putChar(true);
   250                 reader.putChar(true);
   251             }
   251             }
   252             skipIllegalUnderscores();
   252             skipIllegalUnderscores();
   253             if ('0' <= reader.ch && reader.ch <= '9') {
   253             if (reader.digit(pos, 10) >= 0) {
   254                 scanDigits(pos, 10);
   254                 scanDigits(pos, 10);
   255                 return;
   255                 return;
   256             }
   256             }
   257             lexError(pos, "malformed.fp.lit");
   257             lexError(pos, "malformed.fp.lit");
   258             reader.sp = sp1;
   258             reader.sp = sp1;
   382                 } else {
   382                 } else {
   383                     if (Character.isIdentifierIgnorable(reader.ch)) {
   383                     if (Character.isIdentifierIgnorable(reader.ch)) {
   384                         reader.scanChar();
   384                         reader.scanChar();
   385                         continue;
   385                         continue;
   386                     } else {
   386                     } else {
   387                         high = reader.scanSurrogates();
   387                         int codePoint = reader.peekSurrogates();
   388                         if (high != 0) {
   388                         if (codePoint >= 0) {
   389                             reader.putChar(high);
   389                             if (isJavaIdentifierPart = Character.isJavaIdentifierPart(codePoint)) {
   390                             isJavaIdentifierPart = Character.isJavaIdentifierPart(
   390                                 reader.putChar(true);
   391                                 Character.toCodePoint(high, reader.ch));
   391                             }
   392                         } else {
   392                         } else {
   393                             isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch);
   393                             isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch);
   394                         }
   394                         }
   395                     }
   395                     }
   396                 }
   396                 }
   528                 case '5': case '6': case '7': case '8': case '9':
   528                 case '5': case '6': case '7': case '8': case '9':
   529                     scanNumber(pos, 10);
   529                     scanNumber(pos, 10);
   530                     break loop;
   530                     break loop;
   531                 case '.':
   531                 case '.':
   532                     reader.scanChar();
   532                     reader.scanChar();
   533                     if ('0' <= reader.ch && reader.ch <= '9') {
   533                     if (reader.digit(pos, 10) >= 0) {
   534                         reader.putChar('.');
   534                         reader.putChar('.');
   535                         scanFractionAndSuffix(pos);
   535                         scanFractionAndSuffix(pos);
   536                     } else if (reader.ch == '.') {
   536                     } else if (reader.ch == '.') {
   537                         int savePos = reader.bp;
   537                         int savePos = reader.bp;
   538                         reader.putChar('.'); reader.putChar('.', true);
   538                         reader.putChar('.'); reader.putChar('.', true);
   611                     break loop;
   611                     break loop;
   612                 case '\'':
   612                 case '\'':
   613                     reader.scanChar();
   613                     reader.scanChar();
   614                     if (reader.ch == '\'') {
   614                     if (reader.ch == '\'') {
   615                         lexError(pos, "empty.char.lit");
   615                         lexError(pos, "empty.char.lit");
       
   616                         reader.scanChar();
   616                     } else {
   617                     } else {
   617                         if (reader.ch == CR || reader.ch == LF)
   618                         if (reader.ch == CR || reader.ch == LF)
   618                             lexError(pos, "illegal.line.end.in.char.lit");
   619                             lexError(pos, "illegal.line.end.in.char.lit");
   619                         scanLitChar(pos);
   620                         scanLitChar(pos);
   620                         char ch2 = reader.ch;
       
   621                         if (reader.ch == '\'') {
   621                         if (reader.ch == '\'') {
   622                             reader.scanChar();
   622                             reader.scanChar();
   623                             tk = TokenKind.CHARLITERAL;
   623                             tk = TokenKind.CHARLITERAL;
   624                         } else {
   624                         } else {
   625                             lexError(pos, "unclosed.char.lit");
   625                             lexError(pos, "unclosed.char.lit");
   640                 default:
   640                 default:
   641                     if (isSpecial(reader.ch)) {
   641                     if (isSpecial(reader.ch)) {
   642                         scanOperator();
   642                         scanOperator();
   643                     } else {
   643                     } else {
   644                         boolean isJavaIdentifierStart;
   644                         boolean isJavaIdentifierStart;
       
   645                         int codePoint = -1;
   645                         if (reader.ch < '\u0080') {
   646                         if (reader.ch < '\u0080') {
   646                             // all ASCII range chars already handled, above
   647                             // all ASCII range chars already handled, above
   647                             isJavaIdentifierStart = false;
   648                             isJavaIdentifierStart = false;
   648                         } else {
   649                         } else {
   649                             char high = reader.scanSurrogates();
   650                             codePoint = reader.peekSurrogates();
   650                             if (high != 0) {
   651                             if (codePoint >= 0) {
   651                                 reader.putChar(high);
   652                                 if (isJavaIdentifierStart = Character.isJavaIdentifierStart(codePoint)) {
   652 
   653                                     reader.putChar(true);
   653                                 isJavaIdentifierStart = Character.isJavaIdentifierStart(
   654                                 }
   654                                     Character.toCodePoint(high, reader.ch));
       
   655                             } else {
   655                             } else {
   656                                 isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch);
   656                                 isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch);
   657                             }
   657                             }
   658                         }
   658                         }
   659                         if (isJavaIdentifierStart) {
   659                         if (isJavaIdentifierStart) {
   660                             scanIdent();
   660                             scanIdent();
       
   661                         } else if (reader.digit(pos, 10) >= 0) {
       
   662                             scanNumber(pos, 10);
   661                         } else if (reader.bp == reader.buflen || reader.ch == EOI && reader.bp + 1 == reader.buflen) { // JLS 3.5
   663                         } else if (reader.bp == reader.buflen || reader.ch == EOI && reader.bp + 1 == reader.buflen) { // JLS 3.5
   662                             tk = TokenKind.EOF;
   664                             tk = TokenKind.EOF;
   663                             pos = reader.buflen;
   665                             pos = reader.buflen;
   664                         } else {
   666                         } else {
   665                             String arg = (32 < reader.ch && reader.ch < 127) ?
   667                             String arg;
   666                                             String.format("%s", reader.ch) :
   668 
   667                                             String.format("\\u%04x", (int)reader.ch);
   669                             if (codePoint >= 0) {
       
   670                                 char high = reader.ch;
       
   671                                 reader.scanChar();
       
   672                                 arg = String.format("\\u%04x\\u%04x", (int) high, (int)reader.ch);
       
   673                             } else {
       
   674                                 arg = (32 < reader.ch && reader.ch < 127) ?
       
   675                                                 String.format("%s", reader.ch) :
       
   676                                                 String.format("\\u%04x", (int)reader.ch);
       
   677                             }
   668                             lexError(pos, "illegal.char", arg);
   678                             lexError(pos, "illegal.char", arg);
   669                             reader.scanChar();
   679                             reader.scanChar();
   670                         }
   680                         }
   671                     }
   681                     }
   672                     break loop;
   682                     break loop;