Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Nov 23, 2021
1 parent 0df81af commit 6809bb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ string ReserveName(string prefix)

// Emit failure
writer.WriteLine("// No match");
MarkLabel(originalDoneLabel);
MarkLabel(originalDoneLabel, emitSemicolon: !expressionHasCaptures);
if (expressionHasCaptures)
{
EmitUncaptureUntil("0");
Expand Down Expand Up @@ -1156,7 +1156,7 @@ void EmitExpressionConditional(RegexNode node)

// Emit the no branch, first uncapturing any captures from the expression condition that failed
// to match and emit the branch.
MarkLabel(no);
MarkLabel(no, emitSemicolon: startingCrawlPos is null);
if (startingCrawlPos is not null)
{
EmitUncaptureUntil(startingCrawlPos);
Expand Down Expand Up @@ -1252,7 +1252,7 @@ void EmitNegativeLookaheadAssertion(RegexNode node)
writer.WriteLine($"goto {originalDoneLabel};");

// Failures (success for a negative lookahead) jump here.
MarkLabel(negativeLookaheadDoneLabel);
MarkLabel(negativeLookaheadDoneLabel, emitSemicolon: false);
Debug.Assert(doneLabel == negativeLookaheadDoneLabel);
doneLabel = originalDoneLabel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,14 +1159,14 @@ public async Task Blog_Levithan_BalancingGroups_MatchingParentheses(RegexEngine
}

Regex r = await RegexHelpers.GetRegexAsync(engine, @"^\(
(?>
[^()]+
|
\( (?<Depth>)
|
\) (?<-Depth>)
)*
(?(Depth)(?!))
(?>
[^()]+
|
\( (?<Depth>)
|
\) (?<-Depth>)
)*
(?(Depth)(?!))
\)$", RegexOptions.IgnorePatternWhitespace);

Assert.True(r.IsMatch("()"));
Expand All @@ -1190,15 +1190,15 @@ public async Task Blog_Levithan_BalancingGroups_WordLengthIncreases(RegexEngine
}

Regex r = await RegexHelpers.GetRegexAsync(engine, @"^(?:
(?(A)\s|)
(?<B>)
(?<C-B>\w)+ (?(B)(?!))
(?:
\s
(?<C>)
(?<B-C>\w)+ (?(C)(?!))
(?<A>)
)?
(?(A)\s|)
(?<B>)
(?<C-B>\w)+ (?(B)(?!))
(?:
\s
(?<C>)
(?<B-C>\w)+ (?(C)(?!))
(?<A>)
)?
)+ \b$", RegexOptions.IgnorePatternWhitespace);

Assert.True(r.IsMatch("a bc def ghij klmni"));
Expand Down

0 comments on commit 6809bb7

Please sign in to comment.