[vm] Update Irregexp to V8 commit 254cc758346f10be2a7e22e55d90d4defe9cad74.

Includes support for modifier spans and duplicate named capture groups.

Drops the flow graph implementation to ease maintenance.

TEST=corelib/regexp
Bug: https://github.com/dart-lang/sdk/issues/56573
Bug: https://github.com/dart-lang/sdk/issues/61337
Bug: https://github.com/dart-lang/sdk/issues/62349
Bug: https://github.com/dart-lang/sdk/issues/62708
Change-Id: I05640ba945a4fa5476e7ad463738f4f39d842c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-02-23 09:54:47 -08:00
committed by Commit Queue
parent 5b44ac37e5
commit e443b89f23
110 changed files with 21314 additions and 15656 deletions
@@ -0,0 +1,34 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void main() {
var r = RegExp(r"0x(?<digits>[a-f0-9]+)|(?<digits>\d+)");
var m = r.firstMatch("0xabc")!;
Expect.equals(2, m.groupCount);
Expect.listEquals(["digits"], [...m.groupNames]);
Expect.equals("abc", m.namedGroup("digits"));
Expect.equals("abc", m[1]);
Expect.isNull(m[2]);
m = r.firstMatch("123")!;
Expect.equals(2, m.groupCount);
Expect.listEquals(["digits"], [...m.groupNames]);
Expect.equals("123", m.namedGroup("digits"));
Expect.isNull(m[1]);
Expect.equals("123", m[2]);
r = RegExp(r"(?<unmatched>A)|(?<unmatched>B)|(?<matched>C)|(?<matched>D)");
m = r.firstMatch("D")!;
Expect.equals(4, m.groupCount);
Expect.listEquals(["unmatched", "matched"], [...m.groupNames]);
Expect.isNull(m.namedGroup("unmatched"));
Expect.equals("D", m.namedGroup("matched"));
Expect.isNull(m[1]);
Expect.isNull(m[2]);
Expect.isNull(m[3]);
Expect.equals("D", m[4]);
}
@@ -0,0 +1,19 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void main() {
var r = new RegExp(r"(?i:hello) world");
Expect.isTrue(r.hasMatch("hello world"));
Expect.isTrue(r.hasMatch("HELLO world"));
Expect.isFalse(r.hasMatch("hello WORLD"));
Expect.isFalse(r.hasMatch("HELLO WORLD"));
r = new RegExp(r"(?-i:hello) world", caseSensitive: false);
Expect.isTrue(r.hasMatch("hello world"));
Expect.isFalse(r.hasMatch("HELLO world"));
Expect.isTrue(r.hasMatch("hello WORLD"));
Expect.isFalse(r.hasMatch("HELLO WORLD"));
}
@@ -28,18 +28,16 @@
import 'v8_regexp_utils.dart';
// These test cases really belong in `named_captures_test` but they've been
// broken out because they currently fail on all web backends.
void main() {
assertThrows(() => RegExp(r"(?<$𐒤>a)"));
assertThrows(() => RegExp("(?<a\uD801\uDCA4>.)"));
assertThrows(() => RegExp(r"(?<a\uD801\uDCA4>.)"));
RegExp(r"(?<$𐒤>a)");
RegExp("(?<a\uD801\uDCA4>.)");
RegExp(r"(?<a\uD801\uDCA4>.)");
assertThrows(() => RegExp("(?<a\uD801>.)"));
assertThrows(() => RegExp(r"(?<a\uD801>.)"));
assertThrows(() => RegExp("(?<a\uDCA4>.)"));
assertThrows(() => RegExp(r"(?<a\uDCA4>.)"));
assertThrows(() => RegExp("(?<a\u{104A4}>.)"));
assertThrows(() => RegExp(r"(?<a\u{104A4}>.)"));
RegExp("(?<a\u{104A4}>.)");
RegExp(r"(?<a\u{104A4}>.)");
assertThrows(() => RegExp("(?<a\u{10FFFF}>.)"));
assertThrows(() => RegExp(r"(?<a\u{10FFFF}>.)"));
assertThrows(() => RegExp(r"(?<a\\u{110000}>.)"));
+1 -1
View File
@@ -5,7 +5,7 @@ void main() {
var re = RegExp(r'[c-');
} on FormatException catch (e, s) {
Expect.equals(
"FormatException: Unterminated character class [c-",
"FormatException: Unterminated character class\n[c-",
e.toString(),
);
}