Skip to content

Commit

Permalink
minor regex cleanup (#88026)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmoseley committed Jun 27, 2023
1 parent b16b29b commit e685ff9
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ private static void EmitTryFindNextPossibleStartingPosition(IndentedTextWriter w
}

// We're done. Patch up any additional declarations.
ReplaceAdditionalDeclarations(writer, additionalDeclarations, additionalDeclarationsPosition, additionalDeclarationsIndent);
InsertAdditionalDeclarations(writer, additionalDeclarations, additionalDeclarationsPosition, additionalDeclarationsIndent);
return;

// Emit a goto for the specified label.
Expand Down Expand Up @@ -1379,7 +1379,7 @@ private static void EmitTryMatchAtCurrentPosition(IndentedTextWriter writer, Reg
// We're done with the match.

// Patch up any additional declarations.
ReplaceAdditionalDeclarations(writer, additionalDeclarations, additionalDeclarationsPosition, additionalDeclarationsIndent);
InsertAdditionalDeclarations(writer, additionalDeclarations, additionalDeclarationsPosition, additionalDeclarationsIndent);

// And emit any required helpers.
if (additionalLocalFunctions.Count != 0)
Expand Down Expand Up @@ -5054,14 +5054,14 @@ string EmitAllAsciiContained()
}

/// <summary>
/// Replaces <see cref="AdditionalDeclarationsPlaceholder"/> in <paramref name="writer"/> with
/// all of the variable declarations in <paramref name="declarations"/>.
/// Inserts all of the variable declarations in <paramref name="declarations"/> into the
/// <paramref name="writer"/> at <paramref name="position"/> with <paramref name="indent"/>.
/// </summary>
/// <param name="writer">The writer around a StringWriter to have additional declarations inserted into.</param>
/// <param name="declarations">The additional declarations to insert.</param>
/// <param name="position">The position into the writer at which to insert the additional declarations.</param>
/// <param name="indent">The indentation to use for the additional declarations.</param>
private static void ReplaceAdditionalDeclarations(IndentedTextWriter writer, HashSet<string> declarations, int position, int indent)
private static void InsertAdditionalDeclarations(IndentedTextWriter writer, HashSet<string> declarations, int position, int indent)
{
if (declarations.Count != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@
<data name="UnterminatedComment" xml:space="preserve">
<value>Unterminated (?#...) comment.</value>
</data>
<data name="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups" xml:space="preserve">
<value>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</value>
<comment>{Locked="RegexOptions.NonBacktracking"}</comment>
</data>
<data name="UseRegexSourceGeneratorMessage" xml:space="preserve">
<value>Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Výsledek nelze volat pro shodu, která se nezdařila.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Nahrazení regulárních výrazů pomocí substitucí skupin se u RegexOptions.NonBacktracking nepodporuje.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Kolekce je jen pro čtení.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Das Ergebnis kann nicht für eine fehlgeschlagene Übereinstimmung aufgerufen werden.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">RegEx-Ersätze durch Austausch von Gruppen werden bei RegexOptions.NonBacktracking nicht unterstützt.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Die Sammlung ist schreibgeschützt.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">No se puede llamar al resultado si no se encuentra ninguna coincidencia.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Los reemplazos de regex con sustituciones de grupos no se admiten con RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La colección es de sólo lectura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Le résultat ne peut pas être appelé sur un Match ayant échoué.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Les remplacements d'expressions régulières avec des substitutions de groupes ne sont pas pris en charge avec RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La collection est en lecture seule.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Impossibile chiamare Result su un Match non riuscito.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Le sostituzioni regex con sostituzioni di gruppi non sono supportate con RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La raccolta è di sola lettura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">失敗した Match で Result を呼び出すことはできません。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">RegexOptions.NonBacktracking では、グループの置換による正規表現の置換はサポートされていません。</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">コレクションは読み取り専用です。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">실패한 Match에서 결과를 호출할 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">RegexOptions.NonBacktracking에서는 그룹을 대체하는 Regex 대체가 지원되지 않습니다.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">읽기 전용 컬렉션입니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Nie można wywołać wyniku błędnego dopasowania.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Zamiany wyrażeń regularnych z podstawieniami grup nie są obsługiwane w przypadku metody RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Kolekcja jest tylko do odczytu.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Não é possível chamar resultado quando há falha na correspondência.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Substituições de regex com substituições de grupos não são suportadas com RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">A coleção é somente leitura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Вызов результата невозможен при сбойном соответствии.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Замена регулярных выражений на группы не поддерживается в RegexOptions.NonBacktracking.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Данная коллекция предназначена только для чтения.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">Sonuç, başarısız Eşleştirmede çağrılamaz.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">Grup değiştirmeleri içeren normal ifade değiştirmeleri RegexOptions.NonBacktracking ile desteklenmez.</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Koleksiyon salt okunur.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">不能对失败的匹配调用结果。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">RegexOptions.NonBacktracking 不支持使用组替换的正则表达式替换。</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">集合是只读的。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@
<target state="translated">無法在已失敗的對應 (Match) 上呼叫結果。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="translated">RegexOptions.NonBacktracking 不支援以替代群組取代 Regex。</target>
<note>{Locked="RegexOptions.NonBacktracking"}</note>
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">集合是唯讀的。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,6 @@
<data name="UnterminatedComment" xml:space="preserve">
<value>Unterminated (?#...) comment.</value>
</data>
<data name="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups" xml:space="preserve">
<value>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</value>
<comment>{Locked="RegexOptions.NonBacktracking"}</comment>
</data>
<data name="NotSupported_NonBacktrackingConflictingExpression" xml:space="preserve">
<value>RegexOptions.NonBacktracking is not supported in conjunction with expressions containing: '{0}'.</value>
<comment>{Locked="RegexOptions.NonBacktracking"}</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2893,7 +2893,12 @@ private string Describe()
sb.Append(' ').Append($"index = {M}");
break;
case RegexNodeKind.Multi:
sb.Append(" \"").Append(Str).Append('"');
sb.Append(" \"");
foreach(char c in Str!)
{
sb.Append(RegexCharClass.DescribeChar(c));
}
sb.Append('"');
break;
case RegexNodeKind.Set:
case RegexNodeKind.Setloop:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,47 @@ internal enum RegexOpcode
/// <summary>Repeater of the specified character.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the repetition count.</remarks>
Onerep = 0,

/// <summary>Repeater of a single character other than the one specified.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the repetition count.</remarks>
Notonerep = 1,

/// <summary>Repeater of a single character matching the specified set</summary>
/// <remarks>Operand 0 is index into the strings table of the character class description. Operand 1 is the repetition count.</remarks>
Setrep = 2,

/// <summary>Greedy loop of the specified character.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the max iteration count.</remarks>
Oneloop = 3,

/// <summary>Greedy loop of a single character other than the one specified.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the max iteration count.</remarks>
Notoneloop = 4,

/// <summary>Greedy loop of a single character matching the specified set</summary>
/// <remarks>Operand 0 is index into the strings table of the character class description. Operand 1 is the repetition count.</remarks>
Setloop = 5,

/// <summary>Lazy loop of the specified character.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the max iteration count.</remarks>
Onelazy = 6,

/// <summary>Lazy loop of a single character other than the one specified.</summary>
/// <remarks>Operand 0 is the character. Operand 1 is the max iteration count.</remarks>
Notonelazy = 7,

/// <summary>Lazy loop of a single character matching the specified set</summary>
/// <remarks>Operand 0 is index into the strings table of the character class description. Operand 1 is the repetition count.</remarks>
Setlazy = 8,

/// <summary>Single specified character.</summary>
/// <remarks>Operand 0 is the character.</remarks>
One = 9,

/// <summary>Single character other than the one specified.</summary>
/// <remarks>Operand 0 is the character.</remarks>
Notone = 10,

/// <summary>Single character matching the specified set.</summary>
/// <remarks>Operand 0 is index into the strings table of the character class description.</remarks>
Set = 11,
Expand Down
Loading

0 comments on commit e685ff9

Please sign in to comment.