private Token identifier(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char)c); for (;;) { d = read(); if (Character.isIdentifierIgnorable(d)) ; else if (Character.isJavaIdentifierPart(d)) text.append((char)d); else break; } unread(d); return new Token(IDENTIFIER, text.toString()); }
@Nonnull private String _number_part(StringBuilder text, int base, boolean sign) throws IOException, LexerException { StringBuilder part = new StringBuilder(); int d = read(); if (sign && d == '-') { text.append((char) d); part.append((char) d); d = read(); } while (Character.digit(d, base) != -1) { text.append((char) d); part.append((char) d); d = read(); } unread(d); return part.toString(); }
@Nonnull private Token identifier(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char) c); for (;;) { d = read(); if (Character.isIdentifierIgnorable(d)) ; else if (Character.isJavaIdentifierPart(d)) text.append((char) d); else break; } unread(d); return new Token(IDENTIFIER, text.toString()); }
private Token whitespace(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char)c); for (;;) { d = read(); if (ppvalid && isLineSeparator(d)) /* XXX Ugly. */ break; if (Character.isWhitespace(d)) text.append((char)d); else break; } unread(d); return new Token(WHITESPACE, text.toString()); }
private Token identifier(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char)c); for (;;) { d = read(); if (Character.isIdentifierIgnorable(d)) ; else if (Character.isJavaIdentifierPart(d)) text.append((char)d); else break; } unread(d); return new Token(IDENTIFIER, text.toString()); }
private Token whitespace(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char)c); for (;;) { d = read(); if (ppvalid && isLineSeparator(d)) /* XXX Ugly. */ break; if (Character.isWhitespace(d)) text.append((char)d); else break; } unread(d); return new Token(WHITESPACE, text.toString()); }
@Nonnull private Token whitespace(int c) throws IOException, LexerException { StringBuilder text = new StringBuilder(); int d; text.append((char) c); for (;;) { d = read(); if (ppvalid && isLineSeparator(d)) /* XXX Ugly. */ break; if (Character.isWhitespace(d)) text.append((char) d); else break; } unread(d); return new Token(WHITESPACE, text.toString()); }
private Token cppcomment() throws IOException, LexerException { StringBuilder text = new StringBuilder("//"); int d = read(); while (!isLineSeparator(d)) { text.append((char)d); d = read(); } unread(d); return new Token(CPPCOMMENT, text.toString()); }
@Nonnull private Token cppcomment() throws IOException, LexerException { StringBuilder text = new StringBuilder("//"); int d = read(); while (!isLineSeparator(d)) { text.append((char) d); d = read(); } unread(d); return new Token(CPPCOMMENT, text.toString()); }
private Token cppcomment() throws IOException, LexerException { StringBuilder text = new StringBuilder("//"); int d = read(); while (!isLineSeparator(d)) { text.append((char)d); d = read(); } unread(d); return new Token(CPPCOMMENT, text.toString()); }
@Nonnull private Token invalid(StringBuilder text, String reason) throws IOException, LexerException { int d = read(); while (!isLineSeparator(d)) { text.append((char) d); d = read(); } unread(d); return new Token(INVALID, text.toString(), reason); }
private Token invalid(StringBuilder text, String reason) throws IOException, LexerException { int d = read(); while (!isLineSeparator(d)) { text.append((char)d); d = read(); } unread(d); return new Token(INVALID, text.toString(), reason); }
private Token invalid(StringBuilder text, String reason) throws IOException, LexerException { int d = read(); while (!isLineSeparator(d)) { text.append((char)d); d = read(); } unread(d); return new Token(INVALID, text.toString(), reason); }
private Token number_hex(char x) throws IOException, LexerException { StringBuilder text = new StringBuilder("0"); text.append(x); int d = read(); if (Character.digit(d, 16) == -1) { unread(d); // error("Illegal hexadecimal constant " + (char)d); return new Token(INVALID, text.toString(), "Illegal hexadecimal digit " + (char)d + " after "+ text); } long val = 0; do { val = (val << 4) + Character.digit(d, 16); text.append((char)d); d = read(); } while (Character.digit(d, 16) != -1); return _number(text, val, d); }
@Nonnull private Token cond(char c, int yes, int no) throws IOException, LexerException { int d = read(); if (c == d) return new Token(yes); unread(d); return new Token(no); }
private Token number_hex(char x) throws IOException, LexerException { StringBuilder text = new StringBuilder("0"); text.append(x); int d = read(); if (Character.digit(d, 16) == -1) { unread(d); // error("Illegal hexadecimal constant " + (char)d); return new Token(INVALID, text.toString(), "Illegal hexadecimal digit " + (char)d + " after "+ text); } long val = 0; do { val = (val << 4) + Character.digit(d, 16); text.append((char)d); d = read(); } while (Character.digit(d, 16) != -1); return _number(text, val, d); }
private Token cond(char c, int yes, int no) throws IOException, LexerException { int d = read(); if (c == d) return new Token(yes); unread(d); return new Token(no); }
private Token cond(char c, int yes, int no) throws IOException, LexerException { int d = read(); if (c == d) return new Token(yes); unread(d); return new Token(no); }