meet difficult problem on COUNT node

This commit is contained in:
Youmu Liu
2026-09-11 17:29:42 +08:00
parent f372f83171
commit 5a3286dc21
4 changed files with 188 additions and 70 deletions
@@ -180,6 +180,50 @@ namespace Nitload.RegularAnalysis.Text
#endregion
#region CONCAT continuation
private static void AppendConcatNodes(
RegexAstNode node,
List<RegexAstNode> sequence
)
{
if (RegexAstNode.IsNullOrEmpty(node)) {
return;
}
if (node.Label == RegexElementLabel.CONCAT &&
!RegexAstNode.IsDotStar(node.Left) && !IsNamedFind(node))
{
AppendConcatNodes(node.Left, sequence);
AppendConcatNodes(node.Right, sequence);
} else {
sequence.Add(node);
}
}
private static void GenerateConcatTail(
IReadOnlyList<RegexAstNode> sequence,
int start,
in SequenceEmitter<string> sc,
in List<SequenceEmitter<string>> func_list,
in SourceGenContext context,
in ExitLabel exit_label
)
{
for (int i = start; i < sequence.Count; i++)
{
RegexAstNode node = sequence[i];
if (node.Label == RegexElementLabel.COUNT)
{
// COUNT owns both its repetition and the continuation that may retry it.
GenerateCount(node, sc, func_list, context, exit_label, sequence, i + 1);
return;
}
GenerateMethodSource(node, sc, func_list, context, exit_label);
}
}
#endregion
#region FIND concatenation
private static bool TryGenerateFindConcat(