From a74ebcd0b78b627868c912e7a77f4dde35b9ad7e Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Thu, 23 Jul 2026 18:51:34 +0800 Subject: [PATCH] mainly theoratical work on semi, add regex sample --- test/SingleFile/regex.cs | 73 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/test/SingleFile/regex.cs b/test/SingleFile/regex.cs index 25c08561..b74b5ae5 100644 --- a/test/SingleFile/regex.cs +++ b/test/SingleFile/regex.cs @@ -50,6 +50,75 @@ static void Match_Dot(ReadOnlySpan input) int region_start = ptr; int region_end = region_start; - ptr += 1; - region_end = ptr; + ptr += 1; + region_end = ptr; +} + +//a{3,5} + +static void Match_A_3_5(ReadOnlySpan input) +{ + int ptr = 0; + int region_start = ptr; + int region_end = region_start; + + do + { + if(input[ptr..].StartsWith("aaa")) + { + ptr += 3; + region_end = ptr; + } + else + { + break; + } + for(int i = 0; i < 2; i++) + { + if(input[ptr] == 'a') + { + ptr += 1; + region_end = ptr; + } + else + { + break; + } + } + + } while(false); +} + +//(ab){2,3} +static void Match_AB_2_3(ReadOnlySpan input) +{ + int ptr = 0; + int region_start = ptr; + int region_end = region_start; + + do + { + if(input[ptr..].StartsWith("abab")) + { + ptr += 4; + region_end = ptr; + } + else + { + break; + } + for(int i = 0; i < 1; i++) + { + if(input[ptr..].StartsWith("ab")) + { + ptr += 2; + region_end = ptr; + } + else + { + break; + } + } + + } while(false); }