Skip to content

Commit 6809bb7

Browse files
committed
Address PR feedback
1 parent 0df81af commit 6809bb7

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ string ReserveName(string prefix)
783783

784784
// Emit failure
785785
writer.WriteLine("// No match");
786-
MarkLabel(originalDoneLabel);
786+
MarkLabel(originalDoneLabel, emitSemicolon: !expressionHasCaptures);
787787
if (expressionHasCaptures)
788788
{
789789
EmitUncaptureUntil("0");
@@ -1156,7 +1156,7 @@ void EmitExpressionConditional(RegexNode node)
11561156

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

12541254
// Failures (success for a negative lookahead) jump here.
1255-
MarkLabel(negativeLookaheadDoneLabel);
1255+
MarkLabel(negativeLookaheadDoneLabel, emitSemicolon: false);
12561256
Debug.Assert(doneLabel == negativeLookaheadDoneLabel);
12571257
doneLabel = originalDoneLabel;
12581258

src/libraries/System.Text.RegularExpressions/tests/Regex.KnownPattern.Tests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,14 @@ public async Task Blog_Levithan_BalancingGroups_MatchingParentheses(RegexEngine
11591159
}
11601160

11611161
Regex r = await RegexHelpers.GetRegexAsync(engine, @"^\(
1162-
(?>
1163-
[^()]+
1164-
|
1165-
\( (?<Depth>)
1166-
|
1167-
\) (?<-Depth>)
1168-
)*
1169-
(?(Depth)(?!))
1162+
(?>
1163+
[^()]+
1164+
|
1165+
\( (?<Depth>)
1166+
|
1167+
\) (?<-Depth>)
1168+
)*
1169+
(?(Depth)(?!))
11701170
\)$", RegexOptions.IgnorePatternWhitespace);
11711171

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

11921192
Regex r = await RegexHelpers.GetRegexAsync(engine, @"^(?:
1193-
(?(A)\s|)
1194-
(?<B>)
1195-
(?<C-B>\w)+ (?(B)(?!))
1196-
(?:
1197-
\s
1198-
(?<C>)
1199-
(?<B-C>\w)+ (?(C)(?!))
1200-
(?<A>)
1201-
)?
1193+
(?(A)\s|)
1194+
(?<B>)
1195+
(?<C-B>\w)+ (?(B)(?!))
1196+
(?:
1197+
\s
1198+
(?<C>)
1199+
(?<B-C>\w)+ (?(C)(?!))
1200+
(?<A>)
1201+
)?
12021202
)+ \b$", RegexOptions.IgnorePatternWhitespace);
12031203

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

0 commit comments

Comments
 (0)