/** * Utility method for parsing control escape sequences. */ private int c() { if (cursor < patternLength) { return read() ^ 64; } throw error("Illegal control escape sequence"); }
/** * Utility method for parsing control escape sequences. */ private int c() { if (cursor < patternLength) { return read() ^ 64; } throw error("Illegal control escape sequence"); }
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition {date:\d} at java.util.regex.Pattern.error(Pattern.java:1713) at java.util.regex.Pattern.closure(Pattern.java:2775)
/** * Parses and returns the name of a "named capturing group", the trailing * ">" is consumed after parsing. */ private String groupname(int ch) { StringBuilder sb = new StringBuilder(); sb.append(Character.toChars(ch)); while (ASCII.isLower(ch=read()) || ASCII.isUpper(ch) || ASCII.isDigit(ch)) { sb.append(Character.toChars(ch)); } if (sb.length() == 0) throw error("named capturing group has 0 length name"); if (ch != '>') throw error("named capturing group is missing trailing '>'"); return sb.toString(); }
/** * Parses and returns the name of a "named capturing group", the trailing * ">" is consumed after parsing. */ private String groupname(int ch) { StringBuilder sb = new StringBuilder(); sb.append(Character.toChars(ch)); while (ASCII.isLower(ch=read()) || ASCII.isUpper(ch) || ASCII.isDigit(ch)) { sb.append(Character.toChars(ch)); } if (sb.length() == 0) throw error("named capturing group has 0 length name"); if (ch != '>') throw error("named capturing group is missing trailing '>'"); return sb.toString(); }
CharProperty p = CharPropertyNames.charPropertyFor(name); if (p == null) throw error("Unknown character property name {" + name + "}"); return p;
/** * Match next character, signal error if failed. */ private void accept(int ch, String s) { int testChar = temp[cursor++]; if (has(COMMENTS)) testChar = parsePastWhitespace(testChar); if (ch != testChar) { throw error(s); } }
/** * Match next character, signal error if failed. */ private void accept(int ch, String s) { int testChar = temp[cursor++]; if (has(COMMENTS)) testChar = parsePastWhitespace(testChar); if (ch != testChar) { throw error(s); } }
CharProperty p = CharPropertyNames.charPropertyFor(name); if (p == null) throw error("Unknown character property name {" + name + "}"); return p;
throw error("Unclosed character class"); lastCodePoint = c;
throw error("Unclosed character class"); lastCodePoint = c;
private int uxxxx() { int n = 0; for (int i = 0; i < 4; i++) { int ch = read(); if (!ASCII.isHexDigit(ch)) { throw error("Illegal Unicode escape sequence"); } n = n * 16 + ASCII.toDigit(ch); } return n; }
private int uxxxx() { int n = 0; for (int i = 0; i < 4; i++) { int ch = read(); if (!ASCII.isHexDigit(ch)) { throw error("Illegal Unicode escape sequence"); } n = n * 16 + ASCII.toDigit(ch); } return n; }
/** * Utility method for parsing hexadecimal escape sequences. */ private int x() { int n = read(); if (ASCII.isHexDigit(n)) { int m = read(); if (ASCII.isHexDigit(m)) { return ASCII.toDigit(n) * 16 + ASCII.toDigit(m); } } else if (n == '{' && ASCII.isHexDigit(peek())) { int ch = 0; while (ASCII.isHexDigit(n = read())) { ch = (ch << 4) + ASCII.toDigit(n); if (ch > Character.MAX_CODE_POINT) throw error("Hexadecimal codepoint is too big"); } if (n != '}') throw error("Unclosed hexadecimal escape sequence"); return ch; } throw error("Illegal hexadecimal escape sequence"); }
/** * Utility method for parsing hexadecimal escape sequences. */ private int x() { int n = read(); if (ASCII.isHexDigit(n)) { int m = read(); if (ASCII.isHexDigit(m)) { return ASCII.toDigit(n) * 16 + ASCII.toDigit(m); } } else if (n == '{' && ASCII.isHexDigit(peek())) { int ch = 0; while (ASCII.isHexDigit(n = read())) { ch = (ch << 4) + ASCII.toDigit(n); if (ch > Character.MAX_CODE_POINT) throw error("Hexadecimal codepoint is too big"); } if (n != '}') throw error("Unclosed hexadecimal escape sequence"); return ch; } throw error("Illegal hexadecimal escape sequence"); }
/** * Utility method for parsing octal escape sequences. */ private int o() { int n = read(); if (((n-'0')|('7'-n)) >= 0) { int m = read(); if (((m-'0')|('7'-m)) >= 0) { int o = read(); if ((((o-'0')|('7'-o)) >= 0) && (((n-'0')|('3'-n)) >= 0)) { return (n - '0') * 64 + (m - '0') * 8 + (o - '0'); } unread(); return (n - '0') * 8 + (m - '0'); } unread(); return (n - '0'); } throw error("Illegal octal escape sequence"); }
/** * Utility method for parsing octal escape sequences. */ private int o() { int n = read(); if (((n-'0')|('7'-n)) >= 0) { int m = read(); if (((m-'0')|('7'-m)) >= 0) { int o = read(); if ((((o-'0')|('7'-o)) >= 0) && (((n-'0')|('3'-n)) >= 0)) { return (n - '0') * 64 + (m - '0') * 8 + (o - '0'); } unread(); return (n - '0') * 8 + (m - '0'); } unread(); return (n - '0'); } throw error("Illegal octal escape sequence"); }