mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-04 00:56:31 +02:00
Add string highlighting with DarkYellow and make sure variable coloring gets applied before others
This commit is contained in:
@@ -36,6 +36,19 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MatchCollection matches = VariableRegex().Matches(input);
|
||||
for (int i = 0; i < matches.Count; i++)
|
||||
{
|
||||
input = AddColorInformation(input, matches[i].Value, ConsoleColor.Cyan, SearchMode.Contains);
|
||||
}
|
||||
|
||||
matches = StringRegex().Matches(input);
|
||||
for (int i = 0; i < matches.Count; i++)
|
||||
{
|
||||
input = AddColorInformation(input, matches[i].Value, ConsoleColor.DarkYellow, SearchMode.Contains);
|
||||
}
|
||||
|
||||
for (int i = 0; i < replacementValues.Length; i++)
|
||||
{
|
||||
input = AddColorInformation(input, replacementValues[i], ConsoleColor.Blue, SearchMode.Contains);
|
||||
@@ -105,12 +118,6 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
||||
input = AddColorInformation(input, input, statement.Color, statement.SearchMode);
|
||||
}
|
||||
}
|
||||
|
||||
MatchCollection matches = VariableRegex().Matches(input);
|
||||
for (int i = 0; i < matches.Count; i++)
|
||||
{
|
||||
input = AddColorInformation(input, matches[i].Value, ConsoleColor.Cyan, SearchMode.Contains);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string part in input.Split("\0"))
|
||||
@@ -158,6 +165,11 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
||||
[GeneratedRegex("\\$\\{[a-zA-Z0-9]+\\}")]
|
||||
private static partial Regex VariableRegex();
|
||||
|
||||
// match all double quote pairs
|
||||
|
||||
[GeneratedRegex(@"(?<!\\)(?:\\\\{2})*""(?:\\.|[^""\\])*""")]
|
||||
private static partial Regex StringRegex();
|
||||
|
||||
[GeneratedRegex("(?<=(\\v))(.*)(?=\\v)")]
|
||||
private static partial Regex StringColorRegex();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user