ReviewOS

also looking at this

zig-utils/zig-regex

Port to latest zig-master

#2
Closed armagidon-exception wants to merge main into main
53 files +1149 -1017
benchmarks/basic.zigmodified+10-10
Changes to benchmarks/basic.zig
@@ -27,7 +27,7 @@ const Benchmark = struct {
2727 }
2828};
2929
30pub fn main() !void {
30pub fn main(init: std.process.Init) !void {
3131 var gpa = std.heap.GeneralPurposeAllocator(.{}){};
3232 defer _ = gpa.deinit();
3333 const allocator = gpa.allocator();
@@ -36,7 +36,7 @@ pub fn main() !void {
3636
3737 // Benchmark 1: Simple literal matching
3838 {
39 var regex = try Regex.compile(allocator, "hello");
39 var regex = try Regex.compile(allocator, init.io, "hello");
4040 defer regex.deinit();
4141 const input = "hello world";
4242
@@ -50,7 +50,7 @@ pub fn main() !void {
5050
5151 // Benchmark 2: Quantifier matching
5252 {
53 var regex = try Regex.compile(allocator, "a+b*c?");
53 var regex = try Regex.compile(allocator, init.io, "a+b*c?");
5454 defer regex.deinit();
5555 const input = "aaabbbbc";
5656
@@ -64,7 +64,7 @@ pub fn main() !void {
6464
6565 // Benchmark 3: Alternation
6666 {
67 var regex = try Regex.compile(allocator, "cat|dog|bird");
67 var regex = try Regex.compile(allocator, init.io, "cat|dog|bird");
6868 defer regex.deinit();
6969 const input = "dog";
7070
@@ -78,7 +78,7 @@ pub fn main() !void {
7878
7979 // Benchmark 4: Character class
8080 {
81 var regex = try Regex.compile(allocator, "[a-z]+");
81 var regex = try Regex.compile(allocator, init.io, "[a-z]+");
8282 defer regex.deinit();
8383 const input = "abcdefghijklmnop";
8484
@@ -92,7 +92,7 @@ pub fn main() !void {
9292
9393 // Benchmark 5: Digit matching
9494 {
95 var regex = try Regex.compile(allocator, "\\d{3}-\\d{4}");
95 var regex = try Regex.compile(allocator, init.io, "\\d{3}-\\d{4}");
9696 defer regex.deinit();
9797 const input = "555-1234";
9898
@@ -106,7 +106,7 @@ pub fn main() !void {
106106
107107 // Benchmark 6: Email-like pattern
108108 {
109 var regex = try Regex.compile(allocator, "\\w+@\\w+\\.\\w+");
109 var regex = try Regex.compile(allocator, init.io, "\\w+@\\w+\\.\\w+");
110110 defer regex.deinit();
111111 const input = "user@example.com";
112112
@@ -120,7 +120,7 @@ pub fn main() !void {
120120
121121 // Benchmark 7: Find operation
122122 {
123 var regex = try Regex.compile(allocator, "\\d+");
123 var regex = try Regex.compile(allocator, init.io, "\\d+");
124124 defer regex.deinit();
125125 const input = "The price is $123 and tax is $45";
126126
@@ -137,7 +137,7 @@ pub fn main() !void {
137137
138138 // Benchmark 8: Replace operation
139139 {
140 var regex = try Regex.compile(allocator, "\\d+");
140 var regex = try Regex.compile(allocator, init.io, "\\d+");
141141 defer regex.deinit();
142142 const input = "Call 555-1234 or 555-5678";
143143
@@ -166,7 +166,7 @@ pub fn main() !void {
166166
167167 // Benchmark 10: Complex pattern
168168 {
169 var regex = try Regex.compile(allocator, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
169 var regex = try Regex.compile(allocator, init.io, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
170170 defer regex.deinit();
171171 const input = "test.user+tag@example.co.uk";
172172