add COUNT and CONCAT ir emitter

This commit is contained in:
Youmu Liu
2026-06-17 18:32:55 +08:00
parent a7bb3209dd
commit 5570c6f338
6 changed files with 409 additions and 580 deletions
+66 -49
View File
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
@@ -36,12 +37,16 @@ namespace StgSharp.RegularAnalysis.TextRegex
internal enum RegexIRCommand
{
Search = 0,
Jump = 1,
Condition = 2,
Count = 3,
Try = 4,
Pop = 5,
Search_Seq = 0,
Search_Set = 1,
SearchChar = 2,
Jump = 3,
Condition = 4,
Try = 5,
Pop = 6,
Count = 7,
Count_Seq = 8,
Count_Set = 9
}
@@ -50,28 +55,6 @@ namespace StgSharp.RegularAnalysis.TextRegex
internal abstract RegexIRCommand Command { get; }
public static RegexIR Condition(
int success,
int fail
)
{
return new RegexConditionIR(success, fail);
}
public static RegexIR PopLevel(
bool isSuccess
)
{
return new RegexPopIR(isSuccess);
}
public static RegexIR Try(
int count
)
{
return new RegexTryIR(count);
}
internal abstract void Execute();
}
@@ -95,14 +78,14 @@ namespace StgSharp.RegularAnalysis.TextRegex
/// <summary>
/// Searches for a certain string pattern or charset from current position.
/// </summary>
internal sealed class RegexSearchStringIR(
internal sealed class RegexSearchSeqIR(
string pattern
) : RegexIR
{
public string Pattern { get; } = pattern;
internal override RegexIRCommand Command => RegexIRCommand.Search;
internal override RegexIRCommand Command => RegexIRCommand.Search_Seq;
internal override void Execute()
{
@@ -111,30 +94,14 @@ namespace StgSharp.RegularAnalysis.TextRegex
}
internal sealed class RegexSearchCharsetIR(
internal sealed class RegexMatchSetIR(
string charset
) : RegexIR
{
public string Charset { get; } = charset;
internal override RegexIRCommand Command => RegexIRCommand.Search;
internal override void Execute()
{
throw new NotImplementedException();
}
}
internal sealed class RegexSearchCharSetIR(
string c
) : RegexIR
{
public string Target { get; } = c;
internal override RegexIRCommand Command => RegexIRCommand.Search;
internal override RegexIRCommand Command => RegexIRCommand.Search_Set;
internal override void Execute()
{
@@ -200,7 +167,57 @@ namespace StgSharp.RegularAnalysis.TextRegex
public int OperationIndex { get; } = operation;
internal override RegexIRCommand Command => throw new NotImplementedException();
internal override RegexIRCommand Command { get; } = RegexIRCommand.Count;
internal override void Execute()
{
throw new NotImplementedException();
}
}
internal sealed class RegexCountSeqIR(
int min,
int max,
bool isGreedy,
string seq
) : RegexIR
{
public bool IsGreedy { get; } = isGreedy;
public int Min { get; } = min;
public int Max { get; } = max;
public string Sequence { get; } = seq;
internal override RegexIRCommand Command { get; } = RegexIRCommand.Count_Seq;
internal override void Execute()
{
throw new NotImplementedException();
}
}
internal sealed class RegexCountSetIR(
int min,
int max,
bool isGreedy,
string set
) : RegexIR
{
public bool IsGreedy { get; } = isGreedy;
public int Min { get; } = min;
public int Max { get; } = max;
public string CharSet { get; } = set;
internal override RegexIRCommand Command => RegexIRCommand.Count_Set;
internal override void Execute()
{