Make synth reference patches readable

This commit is contained in:
Meta Vens 2026-05-12 22:10:02 +01:00
commit 64519d224d
8 changed files with 668 additions and 85 deletions

View file

@ -13,7 +13,7 @@ public static class PatchScript
{
var compiler = new Compiler();
var line = 1;
foreach (var statement in Statements(script))
foreach (var statement in PatchScriptStatements.Enumerate(script))
{
compiler.Apply(statement.Text, statement.Line);
line = statement.Line;
@ -27,24 +27,6 @@ public static class PatchScript
return compiler.Build();
}
private static IEnumerable<(string Text, int Line)> Statements(string script)
{
var lineNumber = 1;
foreach (var rawLine in script.Replace("\r\n", "\n").Split('\n'))
{
var uncommented = rawLine.Split('#', 2)[0];
foreach (var part in uncommented.Split(';'))
{
var statement = part.Trim();
if (statement.Length > 0)
{
yield return (statement, lineNumber);
}
}
lineNumber++;
}
}
private sealed class Compiler
{
private readonly Dictionary<string, Dictionary<string, string>> _templates = new(StringComparer.OrdinalIgnoreCase);