The variable is later read if there's any backtracking and/or the conditional backreference is in a loop, but it was only being initialized if there was backtracking.
writer.WriteLine();
TransferSliceStaticPosToPos(); // make sure sliceStaticPos is 0 after each branch
string postYesDoneLabel = doneLabel;
- if (postYesDoneLabel != originalDoneLabel)
+ if (postYesDoneLabel != originalDoneLabel || isInLoop)
{
writer.WriteLine($"{resumeAt} = 0;");
}
writer.WriteLine();
TransferSliceStaticPosToPos(); // make sure sliceStaticPos is 0 after each branch
postNoDoneLabel = doneLabel;
- if (postNoDoneLabel != originalDoneLabel)
+ if (postNoDoneLabel != originalDoneLabel || isInLoop)
{
writer.WriteLine($"{resumeAt} = 1;");
}
// There's only a yes branch. If it's going to cause us to output a backtracking
// label but code may not end up taking the yes branch path, we need to emit a resumeAt
// that will cause the backtracking to immediately pass through this node.
- if (postYesDoneLabel != originalDoneLabel)
+ if (postYesDoneLabel != originalDoneLabel || isInLoop)
{
writer.WriteLine($"{resumeAt} = 2;");
}
EmitNode(yesBranch);
TransferSliceStaticPosToPos();
Label postYesDoneLabel = doneLabel;
- if (!isAtomic && postYesDoneLabel != originalDoneLabel)
+ if ((!isAtomic && postYesDoneLabel != originalDoneLabel) || isInLoop)
{
// resumeAt = 0;
Ldc(0);
EmitNode(noBranch);
TransferSliceStaticPosToPos(); // make sure sliceStaticPos is 0 after each branch
postNoDoneLabel = doneLabel;
- if (!isAtomic && postNoDoneLabel != originalDoneLabel)
+ if ((!isAtomic && postNoDoneLabel != originalDoneLabel) || isInLoop)
{
// resumeAt = 1;
Ldc(1);
// There's only a yes branch. If it's going to cause us to output a backtracking
// label but code may not end up taking the yes branch path, we need to emit a resumeAt
// that will cause the backtracking to immediately pass through this node.
- if (!isAtomic && postYesDoneLabel != originalDoneLabel)
+ if ((!isAtomic && postYesDoneLabel != originalDoneLabel) || isInLoop)
{
// resumeAt = 2;
Ldc(2);
yield return (@"(...)(?(1)\w*|\s*)[a1 ]", "---- ", RegexOptions.None, 0, 11, true, "--- ");
yield return (@"(...)(?(1)\w*|\s*)[a1 ]", "zabcaaaaaaa", RegexOptions.RightToLeft, 0, 11, true, "aaaa");
yield return (@"(...)(?(1)\w*|\s*)[a1 ]", "---- ", RegexOptions.RightToLeft, 0, 11, true, "--- ");
+ yield return (@"(aaa)(?(1)aaa|b?)*", "aaaaaa", RegexOptions.None, 0, 6, true, "aaaaaa");
}
// Character Class Subtraction