import ast sys for regex runtime build

This commit is contained in:
Youmu Liu
2026-02-04 09:27:56 +08:00
parent fe0e4ad7a4
commit f1688583cf
15 changed files with 1141 additions and 37 deletions
@@ -36,9 +36,11 @@ using System.Threading.Tasks;
namespace StgSharp.RegularAnalysis
{
internal class RegularBranchNode : RegularStateNode
internal sealed class RegularBranchNode : RegularStateNode
{
private int _afterBranch;
private int _lastBranch;
private List<BranchMeasureResult> _result;
@@ -59,15 +61,26 @@ namespace StgSharp.RegularAnalysis
out int label
)
{
int pos = context.LastBranch.Peek();
if (AvailableNodes.Length > _lastBranch)
if (context.StateCode == 0)
{
// return measure result
label = 0;
// branch match
label = _afterBranch;
_ = context.LastBranch.Pop();
_lastBranch = 0;
return true;
}
label = FailNodeIndex;
return false;
// restore sequence position
int pos = context.LastBranch.Peek();
context.Position = pos;
if (AvailableNodes.Length > _lastBranch)
{
label = FailNodeIndex;
return false;
}
_lastBranch++;
label = AvailableNodes[_lastBranch];
return true;
}
}