RegexGenerator.Emitter.cs (34)
62writer.WriteLine($"/// <code>{EscapeXmlComment(Literal(regexMethod.Pattern, quote: false))}</code><br/>");
111rm.MatchTimeout is not null ? $"new({Literal(rm.Pattern)}, {Literal(rm.Options)}, {GetTimeoutExpression(rm.MatchTimeout.Value)});" :
112rm.Options != 0 ? $"new({Literal(rm.Pattern)}, {Literal(rm.Options)});" :
113$"new({Literal(rm.Pattern)});");
141writer.WriteLine($" base.pattern = {Literal(rm.Pattern)};");
172writer.Write(Literal(s));
407: Literal(chars.ToString());
494string setLiteral = Literal(new string(chars));
1047$"/// <summary>Supports searching for the string {EscapeXmlComment(Literal(substring))}.</summary>",
1048$"internal static readonly SearchValues<string> {fieldName} = SearchValues.Create([{Literal(substring)}], StringComparison.{stringComparison});",
1052writer.WriteLine($"// The pattern has the literal {Literal(substring)} {offsetDescription}. Find the next occurrence.");
1094string prefixes = string.Join(", ", opts.LeadingPrefixes.Select(prefix => Literal(prefix)));
1124writer.WriteLine($"// The pattern begins with a literal {Literal(prefix)}. Find the next occurrence right-to-left.");
1126writer.WriteLine($"pos = inputSpan.Slice(0, pos).LastIndexOf({Literal(prefix)});");
1371target.Literal.String is not null ? $"the {stringComparisonComment}string {Literal(target.Literal.String)}." :
1372target.Literal.Chars is not null ? $"one of the characters {Literal(new string(target.Literal.Chars))}" :
1392target.Literal.String is string literalString ? $"IndexOf({Literal(literalString)}{stringComparisonArgument});" :
3043writer.Write($"!{sourceSpan}.StartsWith({Literal(caseInsensitiveString)}, StringComparison.OrdinalIgnoreCase)");
3044prevDescription = $"Match the string {Literal(caseInsensitiveString)} (ordinal case-insensitive)";
3290using (EmitBlock(writer, $"if (inputSpan[--pos] != {Literal(str)}[{str.Length - 1} - i])"))
3300string clause = $"!{sourceSpan}.StartsWith({Literal(str)})";
4942indexOfExpr = $"{last}IndexOf({Literal(node.Str!)})";
5344$"((ch = {chExpr}) >= {Literal((char)analysis.UpperBoundExclusiveIfOnlyRanges)} || ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) == 0)" :
5345$"((ch = {chExpr}) < {Literal((char)analysis.UpperBoundExclusiveIfOnlyRanges)} && ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0)";
5353$"((ch = {chExpr}) < 128 && ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) == 0)" :
5354$"((ch = {chExpr}) >= 128 || ({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) != 0)";
5375_ => $"({Literal(bitVectorString)}[ch >> 4] & (1 << (ch & 0xF))) {(negate ? "=" : "!")}= 0",
5377return $"((ch = {chExpr}) < 128 ? {asciiExpr} : {(negate ? "!" : "")}RegexRunner.CharInClass((char)ch, {Literal(charClass)}))";
5382$"((ch = {chExpr}) < 128 || !RegexRunner.CharInClass((char)ch, {Literal(charClass)}))" :
5383$"((ch = {chExpr}) >= 128 && RegexRunner.CharInClass((char)ch, {Literal(charClass)}))";
5389$"((ch = {chExpr}) >= 128 && !RegexRunner.CharInClass((char)ch, {Literal(charClass)}))" :
5390$"((ch = {chExpr}) < 128 || RegexRunner.CharInClass((char)ch, {Literal(charClass)}))";
5479RegexNodeKind.Multi => $"Match the string {Literal(node.Str!)}{direction}.",
5508name = Literal(name);