Skip to content

Conversation

bulasevich
Copy link
Contributor

This PR backports:

Conflicts: There were conflicts:

<<<<<<< HEAD
=======
        test("((a|){2,3}){2,3}", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("((a?){2,3}){2,3}", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("((|a){2,3}){2,3}", "", "aaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((a??){2,3}){2,3}", "", "aaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("(|(a\\zb)|e\\2f)??\\1", "", "xxxxx", 0, true, 0, 0, 0, 0, -1, -1);
        test("(a{2}?|)*", "", "abaaaaaa", 0, true, 0, 0, 0, 0);
        test("(a{2}?|)*", "", "aaaaaaaa", 0, true, 0, 8, 8, 8);
        test("(a$){1,23}?", "", "aaa", 0, true, 2, 3, 2, 3);
        test("(a\\1|){2,5}?", "", "a", 0, true, 0, 0, 0, 0);
        test("(a\\1|){2,5}?$", "", "a", 0, true, 1, 1, 1, 1);
        test("(a\\1\\1|){2,5}?$", "", "a", 0, true, 1, 1, 1, 1);
        test("(a\\1\\1|){2,5}?$||", "", "a", 0, true, 0, 0, -1, -1);
        test("(a\\1\\1|){2,5}?$|()\\2", "", "a", 0, true, 0, 0, -1, -1, 0, 0);
        test("(a\\1\\1|){2,5}?$||()\\2", "", "a", 0, true, 0, 0, -1, -1, -1, -1);
        test("(a{2}|())+", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("(a{0,2})*", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a{0,2})*", "", "aaaa", 0, true, 0, 4, 4, 4);
        test("(\\1|a){35,74}?", "", "aaaaaaaaaaaaaaaaaaaa", 0, false);
        test("^a(b*)\\1{4,6}?", "", "abbbb", 0, true, 0, 1, 1, 1);
        test("^a(b*)\\1{4,6}?", "", "abbbbb", 0, true, 0, 6, 1, 2);
        test("(a|)\\1{20,20}", "", "aaaa", 0, true, 0, 0, 0, 0);
        test("(a|)a*\\1{20,20}", "", "aaaa", 0, true, 0, 4, 0, 0);
        test("(a)b\\1()?", "", "aba", 0, true, 0, 3, 0, 1, 3, 3);
        test("(a)(|\\1){4,4}bb", "", "aaabb", 0, true, 0, 5, 0, 1, 3, 3);
        test("(\\1|a|)*", "", "aaa", 0, true, 0, 3, 3, 3);
        test("a([bc]|()\\1|\\2){27,222}?", "", "abcbbc", 0, true, 0, 6, 6, 6, 4, 4);
        test("((a)\\2){4,10}", "", "aaaaaaaa", 0, true, 0, 8, 6, 8, 6, 7);
        test("()\\1(|b){2,2}?c", "", "bc", 0, true, 0, 2, 0, 0, 1, 1);
        test("\u0282\\\ud807\udfdd+\u1cf2", "", "\u0282\ud807\udfdd\ud807\udfdd\u1cf2", 0, true, 0, 13);
        test("((A|){7,10}?){10,17}", "", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, true, 0, 86, 86, 86, 86, 86);
        test("(a{1,30}){1,4}", "", "a", 0, true, 0, 1, 0, 1);
        test("((a|){4,6}){4,6}", "", "aaaaaaa", 0, true, 0, 7, 7, 7, 7, 7);
        test("((a?){4,6}){4,6}", "", "aaaaaaa", 0, true, 0, 7, 7, 7, 7, 7);
        test("((|a){4,6}){4,6}", "", "aaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((a??){4,6}){4,6}", "", "aaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((a?){4,6}){4,6}", "", "aaaaaa", 0, true, 0, 6, 6, 6, 6, 6);
        test("(a|^){100}", "", "a", 0, true, 0, 0, 0, 0);
        test("(a|^){100}", "", "aa", 0, true, 0, 0, 0, 0);
        test("(a|^){100}", "", "aa", 1, false);
        test("(a|^){100}", "", "ab", 1, false);
        test("(a|){4,6}", "", "a", 0, true, 0, 1, 1, 1);
        test("(a|){4,6}", "", "aa", 0, true, 0, 2, 2, 2);
        test("(a|){4,6}", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|){4,6}", "", "aaaa", 0, true, 0, 4, 4, 4);
        test("(a|){4,6}", "", "aaaaa", 0, true, 0, 5, 5, 5);
        test("(a|){4,6}", "", "aaaaaa", 0, true, 0, 6, 5, 6);
        test("(a|){4,6}", "", "aaaaaaa", 0, true, 0, 6, 5, 6);
        test("(a|){4,6}?", "", "a", 0, true, 0, 1, 1, 1);
        test("(a|){4,6}?", "", "aa", 0, true, 0, 2, 2, 2);
        test("(a|){4,6}?", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|){4,6}?", "", "aaaa", 0, true, 0, 4, 3, 4);
        test("(a|){4,6}?", "", "aaaaa", 0, true, 0, 4, 3, 4);
        test("(a|){4,6}?", "", "aaaaaa", 0, true, 0, 4, 3, 4);
        test("(a|){4,6}?", "", "aaaaaaa", 0, true, 0, 4, 3, 4);
        test("(a|){4,6}?a", "", "a", 0, true, 0, 1, 0, 0);
        test("(a|){4,6}?a", "", "aa", 0, true, 0, 2, 1, 1);
        test("(a|){4,6}?a", "", "aaa", 0, true, 0, 3, 2, 2);
        test("(a|){4,6}?a", "", "aaaa", 0, true, 0, 4, 3, 3);
        test("(a|){4,6}?a", "", "aaaaa", 0, true, 0, 5, 3, 4);
        test("(a|){4,6}?a", "", "aaaaaa", 0, true, 0, 5, 3, 4);
        test("(a|){4,6}?a", "", "aaaaaaa", 0, true, 0, 5, 3, 4);
        test("(a|){4,6}?a", "", "aaaaaaaa", 0, true, 0, 5, 3, 4);
        test("(|a){4,6}a", "", "a", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aa", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aaa", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aaaa", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aaaaa", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aaaaaa", 0, true, 0, 1, 0, 0);
        test("(|a){4,6}a", "", "aaaaaaa", 0, true, 0, 1, 0, 0);
        test("((a|){4,6}){4,6}", "", "a", 0, true, 0, 1, 1, 1, 1, 1);
        test("((a|){4,6}){4,6}", "", "aa", 0, true, 0, 2, 2, 2, 2, 2);
        test("((a|){4,6}){4,6}", "", "aaa", 0, true, 0, 3, 3, 3, 3, 3);
        test("((a|){4,6}){4,6}", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("((a|){4,6}){4,6}", "", "aaaaa", 0, true, 0, 5, 5, 5, 5, 5);
        test("((a|){4,6}){4,6}", "", "aaaaaa", 0, true, 0, 6, 6, 6, 6, 6);
        test("((a|){4,6}){4,6}", "", "aaaaaaa", 0, true, 0, 7, 7, 7, 7, 7);
        test("((a|){4,6}){4,6}", "", "aaaaaaaa", 0, true, 0, 8, 8, 8, 8, 8);
        test("((a|){4,6}){4,6}", "", "aaaaaaaaa", 0, true, 0, 9, 9, 9, 9, 9);
        test("((a|){4,6}){4,6}", "", "aaaaaaaaaa", 0, true, 0, 10, 10, 10, 10, 10);
        test("((a|){4,6}){4,6}", "", "aaaaaaaaaaa", 0, true, 0, 11, 11, 11, 11, 11);
        test("((a|){4,6}){4,6}", "", "aaaaaaaaaaaa", 0, true, 0, 12, 12, 12, 12, 12);
        test("((a|){4,6}){4,6}", "", "aaaaaaaaaaaaa", 0, true, 0, 13, 13, 13, 13, 13);
        test("((|a){4,6}){4,6}", "", "a", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((|a){4,6}){4,6}", "", "aaaaaaaaaaaaa", 0, true, 0, 0, 0, 0, 0, 0);
        test("((a|){4,6}?){4,6}", "", "a", 0, true, 0, 1, 1, 1, 1, 1);
        test("((a|){4,6}?){4,6}", "", "aa", 0, true, 0, 2, 2, 2, 2, 2);
        test("((a|){4,6}?){4,6}", "", "aaa", 0, true, 0, 3, 3, 3, 3, 3);
        test("((a|){4,6}?){4,6}", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("((a|){4,6}?){4,6}", "", "aaaaa", 0, true, 0, 5, 5, 5, 5, 5);
        test("((a|){4,6}?){4,6}", "", "aaaaaa", 0, true, 0, 6, 6, 6, 6, 6);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaa", 0, true, 0, 8, 8, 8, 8, 8);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaa", 0, true, 0, 9, 9, 9, 9, 9);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaa", 0, true, 0, 10, 10, 10, 10, 10);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaa", 0, true, 0, 11, 11, 11, 11, 11);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaa", 0, true, 0, 12, 12, 12, 12, 12);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaa", 0, true, 0, 13, 13, 13, 13, 13);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaaa", 0, true, 0, 14, 14, 14, 14, 14);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaaaa", 0, true, 0, 15, 15, 15, 15, 15);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaa", 0, true, 0, 16, 16, 16, 16, 16);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaa", 0, true, 0, 17, 17, 17, 17, 17);
        test("((a|){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaaa", 0, true, 0, 18, 18, 18, 18, 18);
        test("((a){4,6}?){4,6}", "", "a", 0, false);
        test("((a){4,6}?){4,6}", "", "aa", 0, false);
        test("((a){4,6}?){4,6}", "", "aaa", 0, false);
        test("((a){4,6}?){4,6}", "", "aaaa", 0, false);
        test("((a){4,6}?){4,6}", "", "aaaaa", 0, false);
        test("((a){4,6}?){4,6}", "", "aaaaaa", 0, false);
        test("((a){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaa", 0, true, 0, 16, 12, 16, 15, 16);
        test("((a){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaa", 0, true, 0, 16, 12, 16, 15, 16);
        test("((a){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaaaaa", 0, true, 0, 20, 16, 20, 19, 20);
        test("((a){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 24, 20, 24, 23, 24);
        test("((a){4,6}?){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 24, 20, 24, 23, 24);
        test("((a){4,6}){4,6}", "", "a", 0, false);
        test("((a){4,6}){4,6}", "", "aa", 0, false);
        test("((a){4,6}){4,6}", "", "aaa", 0, false);
        test("((a){4,6}){4,6}", "", "aaaa", 0, false);
        test("((a){4,6}){4,6}", "", "aaaaa", 0, false);
        test("((a){4,6}){4,6}", "", "aaaaaa", 0, false);
        test("((a){4,6}){4,6}", "", "aaaaaaaaaaaaaaaa", 0, true, 0, 16, 12, 16, 15, 16);
        test("((a){4,6}){4,6}", "", "aaaaaaaaaaaaaaaaa", 0, true, 0, 17, 13, 17, 16, 17);
        test("((a){4,6}){4,6}", "", "aaaaaaaaaaaaaaaaaaaa", 0, true, 0, 20, 16, 20, 19, 20);
        test("((a){4,6}){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 24, 18, 24, 23, 24);
        test("((a){4,6}){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 24, 18, 24, 23, 24);
        test("((a){4,}){4,6}", "", "a", 0, false);
        test("((a){4,}){4,6}", "", "aa", 0, false);
        test("((a){4,}){4,6}", "", "aaa", 0, false);
        test("((a){4,}){4,6}", "", "aaaa", 0, false);
        test("((a){4,}){4,6}", "", "aaaaa", 0, false);
        test("((a){4,}){4,6}", "", "aaaaaa", 0, false);
        test("((a){4,}){4,6}", "", "aaaaaaaaaaaaaaaa", 0, true, 0, 16, 12, 16, 15, 16);
        test("((a){4,}){4,6}", "", "aaaaaaaaaaaaaaaaa", 0, true, 0, 17, 13, 17, 16, 17);
        test("((a){4,}){4,6}", "", "aaaaaaaaaaaaaaaaaaaa", 0, true, 0, 20, 16, 20, 19, 20);
        test("((a){4,}){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 24, 20, 24, 23, 24);
        test("((a){4,}){4,6}", "", "aaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 25, 21, 25, 24, 25);
        test("(.)\\1{2,}", "", "billiam", 0, false);
        test("(^_(a{1,2}[:])*a{1,2}[:]a{1,2}([.]a{1,4})?_)+", "", "_a:a:a.aaa_", 0, true, 0, 11, 0, 11, 1, 3, 6, 10);
        test("(a{2}|())+$", "", "aaaa", 0, true, 0, 4, 4, 4, 4, 4);
        test("^a(b*)\\1{4,6}?", "", "abbbb", 0, true, 0, 1, 1, 1);
        test("^a(b*)\\1{4,6}?", "", "abbbbb", 0, true, 0, 6, 1, 2);
        test("(?<=|$)", "", "a", 0, true, 1, 1, 1, 1);
        test("(?=ab)a", "", "ab", 0, false);
        test("(?=()|^)|x", "", "empty", 0, true, 0, 0, 0, 0, -1, -1);
        test("a(?<=ba)", "", "ba", 0, false);
        expectSyntaxError("(?<=(?<=a)[])", "i", "", getTRegexEncoding(), "empty", 0, ErrorCode.UnmatchedBracket);
        test("(?<=(?=|()))", "", "aa", 0, false);
        test("\\d\\W", "i", "4\u017f", 0, false);
        test("[\u08bc-\ucf3a]", "i", "\u03b0", 0, false);
        test("[\u0450-\u6c50]\u7e57\u55ad()\u64e7\\d|", "i", "\u03b0\u7e57\u55ad\u64e79", 0, true, 0, 0, -1, -1);
        test("(?<=(?<=a)b^c)c", "", "abcc", 0, false);
        test("a(?:|()\\1){1,2}", "", "a", 0, false);
        test("|(?<\\d\\1)\ub7e4", "", "error", 0, true, 0, 0, -1, -1);
        test("[a-z][a-z\u2028\u2029].|ab(?<=[a-z]w.)", "", "aac", 0, true, 0, 3, -1, -1);
        test("(animation|animation-name)", "", "animation", 0, true, 0, 9, 0, 9);
        test("(a|){7,7}b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(a|){7,7}?b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(|a){7,7}b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(|a){7,7}?b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(a||b){7,7}c", "", "aaabc", 0, true, 0, 5, 4, 4);
        test("(a||b){7,7}c", "", "aaac", 0, true, 0, 4, 3, 3);
        test("(a||b){7,7}c", "", "aaabac", 0, true, 0, 6, 5, 5);
        test("($|a){7,7}", "", "aaa", 0, true, 0, 3, 3, 3);
        test("($|a){7,7}?", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|$){7,7}", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|$){7,7}?", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|$|b){7,7}", "", "aaab", 0, true, 0, 4, 4, 4);
        test("(a|$|b){7,7}", "", "aaa", 0, true, 0, 3, 3, 3);
        test("(a|$|b){7,7}", "", "aaaba", 0, true, 0, 5, 5, 5);
        test("((?=a)|a){7,7}b", "", "aaa", 0, false);
        test("((?=[ab])|a){7,7}b", "", "aaab", 0, false);
        test("((?<=a)|a){7,7}b", "", "aaab", 0, false);
        test("a((?<=a)|a){7,7}b", "", "aaab", 0, false);
        test("(a|){0,7}b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(a|){0,7}?b", "", "aaab", 0, true, 0, 4, 2, 3);
        test("(|a){0,7}b", "", "aaab", 0, true, 0, 4, 3, 3);
        test("(|a){0,7}?b", "", "aaab", 0, true, 0, 4, 2, 3);
        test("(a||b){0,7}c", "", "aaabc", 0, true, 0, 5, 4, 4);
        test("(a||b){0,7}c", "", "aaac", 0, true, 0, 4, 3, 3);
        test("(a||b){0,7}c", "", "aaabac", 0, true, 0, 6, 5, 5);
        test("((?=a)|a){0,7}b", "", "aaab", 0, true, 0, 4, 2, 3, -1, -1);
        test("((?=[ab])|a){0,7}b", "", "aaab", 0, true, 0, 4, 2, 3, -1, -1);
        test("((?<=a)|a){0,7}b", "", "aaab", 0, true, 0, 4, 2, 3, -1, -1);
        test("a((?<=a)|a){0,7}b", "", "aaab", 0, true, 0, 4, 2, 3, -1, -1);
        test("(a*?){11,11}?b", "", "aaaaaaaaaaaaaaaaaaaaaaaaab", 0, true, 0, 26, 10, 25);
        test("\\w(?<=\\W([l-w]{0,19}?){1,2}\\w)\\2\ua2d2\\1\\z", "", "[qowwllu3\u0002\ua2d2qowwlluz", 0, false);
        test("(?:a(b{0,19})c)", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("(?:a(b{0,19})c)de", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("(?<=a(b{0,19})c)de", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("(?<=a(b{0,19}){1,2}c)de", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("(?<=a(b{0,19}){2,2}c)de", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("c(?<=a(b{0,19}){1,2}c)de\\1f", "", "abbbbbbbcdebbbbbbbf", 0, false);
        test("[\ud0d9](?<=\\S)", "", "\ud0d9", 0, false);
        test("[\ud0d9](?<=\\W)", "", "\ud0d9", 0, false);
        test("\u0895(?<=\\S)", "", "\u0895", 0, false);
        test("\u0895(?<=\\W)", "", "\u0895", 0, false);
        test("[\u8053](?<=\\S)", "", "\u8053", 0, false);
        test("[\u8053](?<=\\W)", "", "\u8053", 0, false);
        test("\u0895(?<=\\S)", "", "\u0895", 0, false);
        test("\u0895(?<=\\W)", "", "\u0895", 0, false);
        test("\u0895|[\u8053\ud0d9]+(?<=\\S\\W\\S)", "", "\ud0d9\ud0d9\ud0d9\ud0d9", 0, false);
        test("\u0895|[\u8053\ud0d9]+(?<=\\S\\W\\S)", "", "\ud0d9\ud0d9\ud0d9\ud0d9", 0, false);
        test("\u0895|[\u8053\ud0d9]+(?<=\\S\\W\\S)", "", "\ud0d9\ud0d9\ud0d9\ud0d9", 0, false);
        test("a|[bc]+(?<=[abc][abcd][abc])", "", "bbbb", 0, false);
        test("a(b*)*c\\1d", "", "abbbbcbbd", 0, true, 0, 9, 3, 5);
        test("(|a)||b(?<=cde)|", "", "a", 0, true, 0, 0, 0, 0, -1, -1);
        test("^(\\1)?\\D*", "", "empty", 0, true, 0, 5, -1, -1);
        test("abcd(?<=d|c()d)", "", "_abcd", 0, false);
        test("\\Dw\u3aa7\\A\\S(?<=\ue3b3|\\A()\\S)", "", "\udad1\udcfaw\u3aa7A\ue3b3", 0, false);
        test("a(?:c|b(?=()))*", "", "abc", 0, true, 0, 1, -1, -1, -1, -1, -1, -1);
        test("a(?:c|b(?=(c)))*", "", "abc", 0, true, 0, 1, -1, -1, -1, -1, -1, -1);
        test("a(?:c|(?<=(a))b)*", "", "abc", 0, true, 0, 1, -1, -1, -1, -1, -1, -1);
        test("(a||b){15,18}c", "", "ababaabbaaac", 0, true, 0, 12, 11, 11);
        test("(a||b){15,18}?c", "", "ababaabbaaac", 0, true, 0, 12, 11, 11);
        test("(?:ab|c|^){103,104}", "", "abcababccabccabababccabcababcccccabcababababccccabcabcabccabcabcccabababccabababcababababccababccabcababcabcabccabababccccabcab", 0, true, 0, 0, 0, 0);
        test("((?<=a)bec)*d", "", "abecd", 0, true, 4, 5, -1, -1, -1, -1);
        test("(|(^|\\z){2,77}?)?", "", "empty", 0, true, 0, 0, 0, 0, -1, -1);
        test("a(|a{15,36}){10,11}", "", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 1, 1, 1);
        test("a(|a{15,36}?){10,11}", "", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 1, 1, 1);
        test("a(|a{15,36}){10,11}$", "", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, true, 0, 66, 66, 66);
        test("a(|a{15,36}?){10,11}b$", "", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", 0, true, 0, 67, 66, 66);
        test("(?:a()|b??){22,26}c", "", "aabbbaabaaaaaabaaaac", 0, true, 19, 20, 19, 19, -1, -1);
        test("b()(a\\1|){4,4}\\2c", "", "baaaac", 0, false);
        test("a((?=b()|)[a-d])+", "", "abbbcbd", 0, true, 0, 7, 6, 7, 6, 6, -1, -1);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)

resolution: accept all new tests

<<<<<<< HEAD
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Stream;
=======
import com.oracle.truffle.regex.RegexSyntaxException.ErrorCode;
import com.oracle.truffle.regex.charset.Range;
import com.oracle.truffle.regex.tregex.parser.CaseFoldData;
import com.oracle.truffle.regex.tregex.parser.flavors.java.JavaFlags;
import com.oracle.truffle.regex.tregex.string.Encodings;
import com.oracle.truffle.regex.util.EmptyArrays;
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)

why: extra import in jdk21 version: java.util.concurrent.TimeUnit;
resolution: move the block, keeping the needed TimeUnit import.

<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INCOMPLETE_QUANTIFIER);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INCOMPLETE_QUANTIFIER, ErrorCode.InvalidQuantifier);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_CHARACTER_CLASS);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_CHARACTER_CLASS, ErrorCode.InvalidCharacterClass);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_ESCAPE);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_ESCAPE, ErrorCode.InvalidEscape);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.MISSING_GROUP_FOR_BACKREFERENCE);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.MISSING_GROUP_FOR_BACKREFERENCE, ErrorCode.InvalidBackReference);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_ESCAPE);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_ESCAPE, ErrorCode.InvalidEscape);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.UNMATCHED_RIGHT_BRACKET);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.UNMATCHED_RIGHT_BRACKET, ErrorCode.UnmatchedBracket);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
                if (flags.isEitherUnicode() && lookahead(RegexLexer::isDecimalDigit, 1)) {
                    throw syntaxError(JsErrorMessages.INVALID_ESCAPE);
=======
                if (getLocalFlags().isEitherUnicode() && lookahead(RegexLexer::isDecimalDigit, 1)) {
                    throw syntaxError(JsErrorMessages.INVALID_ESCAPE, ErrorCode.InvalidEscape);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
        if (flags.isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_CONTROL_CHAR_ESCAPE);
=======
        if (getLocalFlags().isEitherUnicode()) {
            throw syntaxError(JsErrorMessages.INVALID_CONTROL_CHAR_ESCAPE, ErrorCode.InvalidEscape);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
            if (flags.isEitherUnicode()) {
                throw syntaxError(JsErrorMessages.INVALID_UNICODE_ESCAPE);
=======
            if (getLocalFlags().isEitherUnicode()) {
                throw syntaxError(JsErrorMessages.INVALID_UNICODE_ESCAPE, ErrorCode.InvalidEscape);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
                    if (flags.isEitherUnicode() && astBuilder.getCurTerm().isLookAheadAssertion()) {
                        throw syntaxError(JsErrorMessages.QUANTIFIER_ON_LOOKAHEAD_ASSERTION);
=======
                    if (getLocalFlags().isEitherUnicode() && astBuilder.getCurTerm().isLookAheadAssertion()) {
                        throw syntaxError(JsErrorMessages.QUANTIFIER_ON_LOOKAHEAD_ASSERTION, ErrorCode.InvalidQuantifier);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)
<<<<<<< HEAD
    private void literalChar(int codePoint) {
        if (flags.isIgnoreCase()) {
=======
    private void literalChar(Token.LiteralCharacter literalCharacter) {
        if (getLocalFlags().isIgnoreCase()) {
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)

why: extra change in mainline:
commit oracle/graal@2fd3c55
Author: Jirka Marsik [email protected]
Date: Mon Dec 2 18:08:31 2024 +0100
Implement the JS regexp-modifiers proposal in TRegex

-        return flags.isIgnoreCase();
+        return getLocalFlags().isIgnoreCase();

resolution: combine extra syntaxError parameter and direct flags field usage

<<<<<<< HEAD
        return null;
=======
        if (RegexFlags.isValidFlagChar(charAfterQuestionMark) || charAfterQuestionMark == '-') {
            return parseFlagModifier(charAfterQuestionMark);
        } else {
            return null;
        }
    }

    private RegexFlags parseLocalFlags(char firstChar) {
        char ch = firstChar;
        RegexFlags flags = RegexFlags.DEFAULT;
        while (RegexFlags.isValidFlagChar(ch)) {
            if (!RegexFlags.isValidLocalFlagChar(ch)) {
                throw syntaxError(JsErrorMessages.flagNotAllowedInModifier(ch), ErrorCode.InvalidInlineFlag);
            }
            flags = flags.addNewFlagModifier(source, ch);
            if (atEnd()) {
                throw syntaxError(JsErrorMessages.INCOMPLETE_MODIFIER, ErrorCode.InvalidInlineFlag);
            }
            ch = consumeChar();
        }
        return flags;
    }

    private Token parseFlagModifier(char charAfterQuestionMark) {
        RegexFlags addFlags = parseLocalFlags(charAfterQuestionMark);
        char ch = prevChar();
        switch (ch) {
            case ':':
                return finishFlagModifier(addFlags, RegexFlags.DEFAULT);
            case '-':
                if (atEnd()) {
                    throw syntaxError(JsErrorMessages.INCOMPLETE_MODIFIER, ErrorCode.InvalidInlineFlag);
                }
                ch = consumeChar();
                RegexFlags removeFlags = parseLocalFlags(ch);
                ch = prevChar();
                if (ch != ':') {
                    if (Character.isAlphabetic(ch)) {
                        throw syntaxError(JsErrorMessages.UNSUPPORTED_FLAG_IN_MODIFIER, ErrorCode.InvalidInlineFlag);
                    } else {
                        throw syntaxError(JsErrorMessages.INVALID_MODIFIER, ErrorCode.InvalidInlineFlag);
                    }
                }
                return finishFlagModifier(addFlags, removeFlags);
            default:
                if (Character.isAlphabetic(ch)) {
                    throw syntaxError(JsErrorMessages.UNSUPPORTED_FLAG_IN_MODIFIER, ErrorCode.InvalidInlineFlag);
                } else {
                    throw syntaxError(JsErrorMessages.INVALID_MODIFIER, ErrorCode.InvalidInlineFlag);
                }
        }
    }

    private Token finishFlagModifier(RegexFlags addFlags, RegexFlags removeFlags) {
        if (addFlags.overlaps(removeFlags)) {
            throw syntaxError(JsErrorMessages.MODIFIER_BOTH_ADDING_AND_REMOVING_FLAG, ErrorCode.InvalidInlineFlag);
        }
        if (addFlags.isNone() && removeFlags.isNone()) {
            throw syntaxError(JsErrorMessages.EMPTY_MODIFIER, ErrorCode.InvalidInlineFlag);
        }
        RegexFlags newFlags = getLocalFlags().addFlags(addFlags).delFlags(removeFlags);
        return Token.createInlineFlags(newFlags, false);
>>>>>>> d7af1852fe8 (TRegex: NFA generator improvements.)

why: missing code block introduced on mainline:
commit oracle/graal@2fd3c55
Author: Jirka Marsik [email protected]
Date: Mon Dec 2 18:08:31 2024 +0100
Implement the JS regexp-modifiers proposal in TRegex

+    private RegexFlags parseLocalFlags(char firstChar) {
+    private Token parseFlagModifier(char charAfterQuestionMark) {
+    private Token finishFlagModifier(RegexFlags addFlags, RegexFlags removeFlags) {

resolution: accept local version

Please note. With an additional commit I disabled three tests. Reason of the fails are changes on mailine that was not backported:

The next TRegex change to backport (depends on this one): [GR-60222] TRegex: multiple fixes for look-behind merging across main expression boundary.

This PR is a part of the Oracle GraalVM for JDK 21.0.7 backports and fixes

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 23, 2025
@JohnTortugo
Copy link
Contributor

I'll try and run some tests on this but it's difficult to review because it's pretty large PR.

@zakkak
Copy link
Contributor

zakkak commented Sep 10, 2025

@bulasevich could you please resolve the conflicts before @JohnTortugo reviews this?

@JohnTortugo
Copy link
Contributor

Apologies for the delay.. we've been pretty busy with the release of G25.. I'll look into this and the other patches tomorrow.

@JohnTortugo
Copy link
Contributor

I was finally able to push these changes through our CI system.. I'll have results tomorrow morning PST.

@zakkak
Copy link
Contributor

zakkak commented Oct 9, 2025

Thank you @JohnTortugo. Did you resolve the conflicts with master before doing so?

Please be aware that the code freeze was on Tuesday, so this PR won't make it for the 23.1.9 release.

Copy link
Contributor

@JohnTortugo JohnTortugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, all our tests passed. Thank you for working on this.

@JohnTortugo
Copy link
Contributor

@zakkak - yes, I fixed the conflicts.

Please be aware that the code freeze was on Tuesday, so this PR won't make it for the 23.1.9 release.

No problem.

djoooooe and others added 4 commits October 9, 2025 14:27
(cherry picked from commit d7af1852fe827409ff970f57fd630385dce54c30)
(cherry picked from commit 8fbfee856e2f334ff78ea545b4fb26cba1e02db7)
(cherry picked from commit 1ee4c15b4ebe5f473c9cb8f61913f060d5c0f17f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants