/** Scan surrogate pairs. If 'ch' is a high surrogate and * the next character is a low surrogate, then put the low * surrogate in 'ch', and return the high surrogate. * otherwise, just return 0. */ protected char scanSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; scanChar(); if (Character.isLowSurrogate(ch)) { return high; } ch = high; } return 0; }
protected UnicodeReader(ScannerFactory sf, char[] input, int inputLength) { log = sf.log; names = sf.names; if (inputLength == input.length) { if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { inputLength--; } else { input = Arrays.copyOf(input, inputLength + 1); } } buf = input; buflen = inputLength; buf[buflen] = EOI; bp = -1; scanChar(); }
protected UnicodeReader(ScannerFactory sf, char[] input, int inputLength) { log = sf.log; names = sf.names; if (inputLength == input.length) { if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { inputLength--; } else { input = Arrays.copyOf(input, inputLength + 1); } } buf = input; buflen = inputLength; buf[buflen] = EOI; bp = -1; scanChar(); }
/** Scan surrogate pairs. If 'ch' is a high surrogate and * the next character is a low surrogate, then put the low * surrogate in 'ch', and return the high surrogate. * otherwise, just return 0. */ protected char scanSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; scanChar(); if (Character.isLowSurrogate(ch)) { return high; } ch = high; } return 0; }
private void skipIllegalUnderscores() { if (reader.ch == '_') { lexError(reader.bp, "illegal.underscore"); while (reader.ch == '_') reader.scanChar(); } }
/** Append a character to sbuf. */ protected void putChar(char ch, boolean scan) { sbuf = ArrayUtils.ensureCapacity(sbuf, sp); sbuf[sp++] = ch; if (scan) scanChar(); }
/** Append a character to sbuf. */ protected void putChar(char ch, boolean scan) { sbuf = ArrayUtils.ensureCapacity(sbuf, sp); sbuf[sp++] = ch; if (scan) scanChar(); }
private void skipIllegalUnderscores() { if (reader.ch == '_') { lexError(reader.bp, "illegal.underscore"); while (reader.ch == '_') reader.scanChar(); } }
/** Read next character in comment, skipping over double '\' characters. */ protected void scanCommentChar() { scanChar(); if (ch == '\\') { if (peekChar() == '\\' && !isUnicode()) { skipChar(); } else { convertUnicode(); } } }
/** Read next character in comment, skipping over double '\' characters. */ protected void scanCommentChar() { scanChar(); if (ch == '\\') { if (peekChar() == '\\' && !isUnicode()) { skipChar(); } else { convertUnicode(); } } }
/** Read longest possible sequence of special characters and convert * to token. */ private void scanOperator() { while (true) { reader.putChar(false); Name newname = reader.name(); TokenKind tk1 = tokens.lookupKind(newname); if (tk1 == TokenKind.IDENTIFIER) { reader.sp--; break; } tk = tk1; reader.scanChar(); if (!isSpecial(reader.ch)) break; } }
/** Read longest possible sequence of special characters and convert * to token. */ private void scanOperator() { while (true) { reader.putChar(false); Name newname = reader.name(); TokenKind tk1 = tokens.lookupKind(newname); if (tk1 == TokenKind.IDENTIFIER) { reader.sp--; break; } tk = tk1; reader.scanChar(); if (!isSpecial(reader.ch)) break; } }
private void scanDigits(int pos, int digitRadix) { char saveCh; int savePos; do { if (reader.ch != '_') { reader.putChar(false); } else { if (!allowUnderscoresInLiterals) { lexError(pos, "unsupported.underscore.lit", source.name); allowUnderscoresInLiterals = true; } } saveCh = reader.ch; savePos = reader.bp; reader.scanChar(); } while (reader.digit(pos, digitRadix) >= 0 || reader.ch == '_'); if (saveCh == '_') lexError(savePos, "illegal.underscore"); }
private void scanDigits(int pos, int digitRadix) { char saveCh; int savePos; do { if (reader.ch != '_') { reader.putChar(false); } else { if (!allowUnderscoresInLiterals) { lexError(pos, "unsupported.underscore.lit", source.name); allowUnderscoresInLiterals = true; } } saveCh = reader.ch; savePos = reader.bp; reader.scanChar(); } while (reader.digit(pos, digitRadix) >= 0 || reader.ch == '_'); if (saveCh == '_') lexError(savePos, "illegal.underscore"); }
reader.putChar('\\', true); } else { reader.scanChar(); switch (reader.ch) { case '0': case '1': case '2': case '3': char leadch = reader.ch; int oct = reader.digit(pos, 8); reader.scanChar(); if ('0' <= reader.ch && reader.ch <= '7') { oct = oct * 8 + reader.digit(pos, 8); reader.scanChar(); if (leadch <= '3' && '0' <= reader.ch && reader.ch <= '7') { oct = oct * 8 + reader.digit(pos, 8); reader.scanChar();
reader.putChar('\\', true); } else { reader.scanChar(); switch (reader.ch) { case '0': case '1': case '2': case '3': char leadch = reader.ch; int oct = reader.digit(pos, 8); reader.scanChar(); if ('0' <= reader.ch && reader.ch <= '7') { oct = oct * 8 + reader.digit(pos, 8); reader.scanChar(); if (leadch <= '3' && '0' <= reader.ch && reader.ch <= '7') { oct = oct * 8 + reader.digit(pos, 8); reader.scanChar();
} else { if (reader.ch == 'l' || reader.ch == 'L') { reader.scanChar(); tk = TokenKind.LONGLITERAL; } else {
} else { if (reader.ch == 'l' || reader.ch == 'L') { reader.scanChar(); tk = TokenKind.LONGLITERAL; } else {