import ast sys for regex runtime build
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.RegularAnalysis
|
||||
{
|
||||
internal class RegularSequenceNode : RegularStateNode
|
||||
internal sealed class RegularSequenceNode : RegularStateNode
|
||||
{
|
||||
|
||||
private string _sequence;
|
||||
@@ -17,20 +18,9 @@ namespace StgSharp.RegularAnalysis
|
||||
RegularStateNode former,
|
||||
RegularContext context
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TryTransaction(
|
||||
ReadOnlySpan<RegularStateNode> nodeSpan,
|
||||
RegularContext context,
|
||||
out int label
|
||||
)
|
||||
{
|
||||
int pos = context.Position + 1;
|
||||
if (true) { }
|
||||
label = -1;
|
||||
return false;
|
||||
return context.CurrentCharSpan[pos.._sequence.Length].SequenceEqual(_sequence);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,6 +127,8 @@ namespace StgSharp.RegularAnalysis
|
||||
|
||||
public int Position { get; set; } = -1;
|
||||
|
||||
public int StateCode { get; set; } = 0;
|
||||
|
||||
public ReadOnlySpan<char> CurrentCharSpan => Source.AsSpan()[Begin..Position];
|
||||
|
||||
public string Source { get; init; }
|
||||
|
||||
Reference in New Issue
Block a user