Skip to content

Commit 7fc3dfa

Browse files
committed
Refactor.
1 parent 469b1ce commit 7fc3dfa

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

Prequel/SqlCmdPreprocessor.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -425,62 +425,62 @@ public void AppendRangeTo(StringBuilder builder, int start, int end)
425425
}
426426

427427
private static readonly Regex TokenRegex = new(
428-
@"
429-
' ( [^'] | '' )* ( ' | \z ) | # string
430-
\[ ( [^\]] | \]\] )* ( \] | \z ) | # quoted identifier
431-
-- .*? ( \r?\n | \z ) | # line comment
432-
/\* ( . | \n )*? ( \*/ | \z ) | # block comment
433-
\$\( (?<name> [\w-]+ ) ( \) | \z ) | # variable replacement
434-
^GO ( \r?\n | \z ) | # batch separator
435-
^:(r|setvar) (?<args> # directives
436-
( [^""\r\n]
437-
| \r (?!\n)
438-
| "" ( [^""] | """" )* ( "" | \z )
439-
)*
440-
) ( \r?\n | \z )
441-
",
428+
"""
429+
' ( [^'] | '' )* ( ' | \z ) | # string
430+
\[ ( [^\]] | \]\] )* ( \] | \z ) | # quoted identifier
431+
-- .*? ( \r?\n | \z ) | # line comment
432+
/\* ( . | \n )*? ( \*/ | \z ) | # block comment
433+
\$\( (?<name> [\w-]+ ) ( \) | \z ) | # variable replacement
434+
^GO ( \r?\n | \z ) | # batch separator
435+
^:(r|setvar) (?<args> # directives
436+
( [^"\r\n]
437+
| \r (?!\n)
438+
| " ( [^"] | "" )* ( " | \z )
439+
)*
440+
) ( \r?\n | \z )
441+
""",
442442
Options
443443
);
444444

445445
private static readonly Regex VariableRegex = new(
446-
@"
447-
\$\( (?<name>\w+) \)
448-
",
446+
"""
447+
\$\( (?<name>\w+) \)
448+
""",
449449
Options
450450
);
451451

452452
private static readonly Regex IncludeRegex = new(
453-
@"
454-
\A [ \t]+
453+
"""
454+
\A [ \t]+
455455
456-
(?<path> [^"" \t\r\n]+ # unquoted
457-
| "" ( [^""] | """" )* ( "" | \z ) # quoted
458-
)
456+
(?<path> [^" \t\r\n]+ # unquoted
457+
| " ( [^"] | "" )* ( " | \z ) # quoted
458+
)
459459
460-
[ \t]* (-- .*)? \z
461-
",
460+
[ \t]* (-- .*)? \z
461+
""",
462462
Options
463463
);
464464

465465
private static readonly Regex SetVariableRegex = new(
466-
@"
467-
\A [ \t]+
466+
"""
467+
\A [ \t]+
468468
469-
(?<name> [\w-[0-9]] [\w-]* )
469+
(?<name> [\w-[0-9]] [\w-]* )
470470
471-
(?> [ \t]+
472-
(?<value> [^"" \t\r\n]+ # unquoted
473-
| "" ( [^""] | """" )* ( "" | \z ) # quoted
474-
)
475-
)?
471+
(?> [ \t]+
472+
(?<value> [^" \t\r\n]+ # unquoted
473+
| " ( [^"] | "" )* ( " | \z ) # quoted
474+
)
475+
)?
476476
477-
[ \t]* (-- .*)? \z
478-
",
477+
[ \t]* (-- .*)? \z
478+
""",
479479
Options
480480
);
481481

482482
private const RegexOptions Options
483-
= Multiline
483+
= Multiline // ^ and $ match start and end of line; use \A and \z for start and end of input
484484
| IgnoreCase
485485
| CultureInvariant
486486
| IgnorePatternWhitespace

0 commit comments

Comments
 (0)