/** 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. */ private char scanSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; scanChar(); if (Character.isLowSurrogate(ch)) { return high; } ch = high; } return 0; }
/** 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. */ private char scanSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; scanChar(); if (Character.isLowSurrogate(ch)) { return high; } ch = high; } return 0; }
/** Read next character in comment, skipping over double '\' characters. */ private void scanCommentChar() { scanChar(); if (ch == '\\') { if (buf[bp+1] == '\\' && unicodeConversionBp != bp) { bp++; } else { convertUnicode(); } } }
/** Read next character in comment, skipping over double '\' characters. */ private void scanCommentChar() { scanChar(); if (ch == '\\') { if (buf[bp+1] == '\\' && unicodeConversionBp != bp) { bp++; } else { convertUnicode(); } } }
/** * Create a scanner from the input array. This method might * modify the array. To avoid copying the input array, ensure * that {@code inputLength < input.length} or * {@code input[input.length -1]} is a white space character. * * @param fac the factory which created this Scanner * @param input the input, might be modified * @param inputLength the size of the input. * Must be positive and less than or equal to input.length. */ protected Scanner(Factory fac, char[] input, int inputLength) { this(fac); eofPos = inputLength; if (inputLength == input.length) { if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { inputLength--; } else { char[] newInput = new char[inputLength + 1]; System.arraycopy(input, 0, newInput, 0, input.length); input = newInput; } } buf = input; buflen = inputLength; buf[buflen] = EOI; bp = -1; scanChar(); }
/** * Create a scanner from the input array. This method might * modify the array. To avoid copying the input array, ensure * that {@code inputLength < input.length} or * {@code input[input.length -1]} is a white space character. * * @param fac the factory which created this Scanner * @param input the input, might be modified * @param inputLength the size of the input. * Must be positive and less than or equal to input.length. */ protected Scanner(Factory fac, char[] input, int inputLength) { this(fac); eofPos = inputLength; if (inputLength == input.length) { if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { inputLength--; } else { char[] newInput = new char[inputLength + 1]; System.arraycopy(input, 0, newInput, 0, input.length); input = newInput; } } buf = input; buflen = inputLength; buf[buflen] = EOI; bp = -1; scanChar(); }
/** Read fractional part and 'd' or 'f' suffix of floating point number. */ private void scanFractionAndSuffix() { this.radix = 10; scanFraction(); if (ch == 'f' || ch == 'F') { putChar(ch); scanChar(); token = FLOATLITERAL; } else { if (ch == 'd' || ch == 'D') { putChar(ch); scanChar(); } token = DOUBLELITERAL; } }
/** Read fractional part and 'd' or 'f' suffix of floating point number. */ private void scanFractionAndSuffix() { this.radix = 10; scanFraction(); if (ch == 'f' || ch == 'F') { putChar(ch); scanChar(); token = FLOATLITERAL; } else { if (ch == 'd' || ch == 'D') { putChar(ch); scanChar(); } token = DOUBLELITERAL; } }
/** Read fractional part of floating point number. */ private void scanFraction() { while (digit(10) >= 0) { putChar(ch); scanChar(); } int sp1 = sp; if (ch == 'e' || ch == 'E') { putChar(ch); scanChar(); if (ch == '+' || ch == '-') { putChar(ch); scanChar(); } if ('0' <= ch && ch <= '9') { do { putChar(ch); scanChar(); } while ('0' <= ch && ch <= '9'); return; } lexError("malformed.fp.lit"); sp = sp1; } }
/** Read fractional part of floating point number. */ private void scanFraction() { while (digit(10) >= 0) { putChar(ch); scanChar(); } int sp1 = sp; if (ch == 'e' || ch == 'E') { putChar(ch); scanChar(); if (ch == '+' || ch == '-') { putChar(ch); scanChar(); } if ('0' <= ch && ch <= '9') { do { putChar(ch); scanChar(); } while ('0' <= ch && ch <= '9'); return; } lexError("malformed.fp.lit"); sp = sp1; } }
bp++; putChar('\\'); scanChar(); } else { scanChar(); switch (ch) { case '0': case '1': case '2': case '3': char leadch = ch; int oct = digit(8); scanChar(); if ('0' <= ch && ch <= '7') { oct = oct * 8 + digit(8); scanChar(); if (leadch <= '3' && '0' <= ch && ch <= '7') { oct = oct * 8 + digit(8); scanChar(); break; case 'b': putChar('\b'); scanChar(); break; case 't': putChar('\t'); scanChar(); break; case 'n': putChar('\n'); scanChar(); break; case 'f': putChar('\f'); scanChar(); break; case 'r': putChar('\r'); scanChar(); break;
bp++; putChar('\\'); scanChar(); } else { scanChar(); switch (ch) { case '0': case '1': case '2': case '3': char leadch = ch; int oct = digit(8); scanChar(); if ('0' <= ch && ch <= '7') { oct = oct * 8 + digit(8); scanChar(); if (leadch <= '3' && '0' <= ch && ch <= '7') { oct = oct * 8 + digit(8); scanChar(); break; case 'b': putChar('\b'); scanChar(); break; case 't': putChar('\t'); scanChar(); break; case 'n': putChar('\n'); scanChar(); break; case 'f': putChar('\f'); scanChar(); break; case 'r': putChar('\r'); scanChar(); break;
/** Read fractional part and 'd' or 'f' suffix of floating point number. */ private void scanHexFractionAndSuffix(boolean seendigit) { this.radix = 16; assert ch == '.'; putChar(ch); scanChar(); while (digit(16) >= 0) { seendigit = true; putChar(ch); scanChar(); } if (!seendigit) lexError("invalid.hex.number"); else scanHexExponentAndSuffix(); }
/** Read fractional part and 'd' or 'f' suffix of floating point number. */ private void scanHexFractionAndSuffix(boolean seendigit) { this.radix = 16; assert ch == '.'; putChar(ch); scanChar(); while (digit(16) >= 0) { seendigit = true; putChar(ch); scanChar(); } if (!seendigit) lexError("invalid.hex.number"); else scanHexExponentAndSuffix(); }
/** Read longest possible sequence of special characters and convert * to token. */ private void scanOperator() { while (true) { putChar(ch); Name newname = names.fromChars(sbuf, 0, sp); if (keywords.key(newname) == IDENTIFIER) { sp--; break; } name = newname; token = keywords.key(newname); scanChar(); if (!isSpecial(ch)) break; } }
/** Read longest possible sequence of special characters and convert * to token. */ private void scanOperator() { while (true) { putChar(ch); Name newname = names.fromChars(sbuf, 0, sp); if (keywords.key(newname) == IDENTIFIER) { sp--; break; } name = newname; token = keywords.key(newname); scanChar(); if (!isSpecial(ch)) break; } }