src/main/java/com/basistech/tclre/Lex.java
boolean lexescape() throws RegexException {
        int c;
        int save;

        assert 0 != (v.cflags & Flags.REG_ADVF);

        assert !ateos();
        c = charAtNowAdvance();
        if (!iscalnum((char)c)) {
            return retv(Compiler.PLAIN, c);
        }

        note(Flags.REG_UNONPOSIX);
        switch (c) {
        case 'a':
            return retv(Compiler.PLAIN, '\007');

        case 'A':
            return retv(Compiler.SBEGIN, 0);

        case 'b':
            return retv(Compiler.PLAIN, '\b');

        case 'B':
            return retv(Compiler.PLAIN, '\\');

        case 'c':
            if (ateos()) {
                throw new RegexException("Incomplete \\c escape.");
            }
            return retv(Compiler.PLAIN, (char)(charAtNowAdvance() & 037));

        case 'd':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'd');

        case 'D':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'D');

        case 'e':
            return retv(Compiler.PLAIN, '\033');

        case 'f':
            return retv(Compiler.PLAIN, '\f');

        case 'm':
            return ret('<');

        case 'M':
            return ret('>');

        case 'n':
            return retv(Compiler.PLAIN, '\n');

        case 'r':
            return retv(Compiler.PLAIN, '\r');

        case 's':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 's');

        case 'S':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'S');

        case 't':
            return retv(Compiler.PLAIN, '\t');

        case 'u':
            c = lexdigits(16, 4, 4);
            return retv(Compiler.PLAIN, c);

        case 'U':
            c = lexdigits(16, 8, 8);
            // This escape is for UTF-32 characters. There are, ahem, certain requirements.
            if (c > Character.MAX_CODE_POINT) {
                throw new RegexException("Invalid UTF-32 escape.");
            }
            return retv(Compiler.PLAIN, c);

        case 'v':
            return retv(Compiler.PLAIN, '\u000b');

        case 'w':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'w');

        case 'W':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'W');

        case 'x':
            c = lexdigits(16, 1, 255);  /* REs >255 long outside spec */
            return retv(Compiler.PLAIN, c);

        case 'y':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.WBDRY, 0);

        case 'Y':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.NWBDRY, 0);

        case 'Z':
            return retv(Compiler.SEND, 0);

        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            save = v.now;
            v.now--;    /* put first digit back */
            c = lexdigits(10, 1, 255);  /* REs >255 long outside spec */
        /* ugly heuristic (first test is "exactly 1 digit?") */
            if (v.now - save == 0 || c <= v.getSubs().size()) {
                note(Flags.REG_UBACKREF);
                return retv(Compiler.BACKREF, (char)c);
            }
        /* oops, doesn't look like it's a backref after all... */
            v.now = save;
        /* and fall through into octal number */
        case '0':
            v.now--;    /* put first digit back */
            c = lexdigits(8, 1, 3);

            return retv(Compiler.PLAIN, c);

        default:
            throw new RegexException("Invalid escape"); // unknown escape.
        }
    }
boolean lexescape() throws RegexException {
        int c;
        int save;

        assert 0 != (v.cflags & Flags.REG_ADVF);

        assert !ateos();
        c = charAtNowAdvance();
        if (!iscalnum((char)c)) {
            return retv(Compiler.PLAIN, c);
        }

        note(Flags.REG_UNONPOSIX);
        switch (c) {
        case 'a':
            return retv(Compiler.PLAIN, '\007');

        case 'A':
            return retv(Compiler.SBEGIN, 0);

        case 'b':
            return retv(Compiler.PLAIN, '\b');

        case 'B':
            return retv(Compiler.PLAIN, '\\');

        case 'c':
            if (ateos()) {
                throw new RegexException("Incomplete \\c escape.");
            }
            return retv(Compiler.PLAIN, (char)(charAtNowAdvance() & 037));

        case 'd':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'd');

        case 'D':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'D');

        case 'e':
            return retv(Compiler.PLAIN, '\033');

        case 'f':
            return retv(Compiler.PLAIN, '\f');

        case 'm':
            return ret('<');

        case 'M':
            return ret('>');

        case 'n':
            return retv(Compiler.PLAIN, '\n');

        case 'r':
            return retv(Compiler.PLAIN, '\r');

        case 's':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 's');

        case 'S':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'S');

        case 't':
            return retv(Compiler.PLAIN, '\t');

        case 'u':
            c = lexdigits(16, 4, 4);
            return retv(Compiler.PLAIN, c);

        case 'U':
            c = lexdigits(16, 8, 8);
            // This escape is for UTF-32 characters. There are, ahem, certain requirements.
            if (c > Character.MAX_CODE_POINT) {
                throw new RegexException("Invalid UTF-32 escape.");
            }
            return retv(Compiler.PLAIN, c);

        case 'v':
            return retv(Compiler.PLAIN, '\u000b');

        case 'w':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'w');

        case 'W':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.CCLASS, 'W');

        case 'x':
            c = lexdigits(16, 1, 255);  /* REs >255 long outside spec */
            return retv(Compiler.PLAIN, c);

        case 'y':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.WBDRY, 0);

        case 'Y':
            note(Flags.REG_ULOCALE);
            return retv(Compiler.NWBDRY, 0);

        case 'Z':
            return retv(Compiler.SEND, 0);

        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            save = v.now;
            v.now--;    /* put first digit back */
            c = lexdigits(10, 1, 255);  /* REs >255 long outside spec */
        /* ugly heuristic (first test is "exactly 1 digit?") */
            if (v.now - save == 0 || c <= v.getSubs().size()) {
                note(Flags.REG_UBACKREF);
                return retv(Compiler.BACKREF, (char)c);
            }
        /* oops, doesn't look like it's a backref after all... */
            v.now = save;
        /* and fall through into octal number */
        case '0':
            v.now--;    /* put first digit back */
            c = lexdigits(8, 1, 3);

            return retv(Compiler.PLAIN, c);

        default:
            throw new RegexException("Invalid escape"); // unknown escape.
        }
    }
boolean lexescape ( ) throws RegexException { int c ; int save ; assert 0 != ( v . cflags & Flags . REG_ADVF ) ; assert ! ateos ( ) ; c = charAtNowAdvance ( ) ; if ( ! iscalnum ( ( char ) c ) ) { return retv ( Compiler . PLAIN , c ) ; } note ( Flags . REG_UNONPOSIX ) ; switch ( c ) { case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : return retv ( Compiler . SBEGIN , 0 ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : if ( ateos ( ) ) { throw new RegexException ( "Incomplete \\c escape." ) ; } return retv ( Compiler . PLAIN , ( char ) ( charAtNowAdvance ( ) & 037 ) ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : return ret ( ' ' ) ; case ' ' : return ret ( ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : c = lexdigits ( 16 , 4 , 4 ) ; return retv ( Compiler . PLAIN , c ) ; case ' ' : c = lexdigits ( 16 , 8 , 8 ) ; // This escape is for UTF-32 characters. There are, ahem, certain requirements. if ( c > Character . MAX_CODE_POINT ) { throw new RegexException ( "Invalid UTF-32 escape." ) ; } return retv ( Compiler . PLAIN , c ) ; case ' ' : return retv ( Compiler . PLAIN , ' ' ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . CCLASS , ' ' ) ; case ' ' : c = lexdigits ( 16 , 1 , 255 ) ; /* REs >255 long outside spec */ return retv ( Compiler . PLAIN , c ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . WBDRY , 0 ) ; case ' ' : note ( Flags . REG_ULOCALE ) ; return retv ( Compiler . NWBDRY , 0 ) ; case ' ' : return retv ( Compiler . SEND , 0 ) ; case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : save = v . now ; v . now -- ; /* put first digit back */ c = lexdigits ( 10 , 1 , 255 ) ; /* REs >255 long outside spec */ /* ugly heuristic (first test is "exactly 1 digit?") */ if ( v . now - save == 0 || c <= v . getSubs ( ) . size ( ) ) { note ( Flags . REG_UBACKREF ) ; return retv ( Compiler . BACKREF , ( char ) c ) ; } /* oops, doesn't look like it's a backref after all... */ v . now = save ; /* and fall through into octal number */ case ' ' : v . now -- ; /* put first digit back */ c = lexdigits ( 8 , 1 , 3 ) ; return retv ( Compiler . PLAIN , c ) ; default : throw new RegexException ( "Invalid escape" ) ; // unknown escape. } }
CHECKSTYLE:OFF
CHECKSTYLE : OFF