Snapshot for release 2026.10.12.1 (internal 8d252bd)
This commit is contained in:
parent
504a6f080a
commit
3c4f093e3d
60 changed files with 5748 additions and 602 deletions
|
|
@ -99,6 +99,7 @@ internal static class AfFileParser
|
|||
idx++; // consume STATE: line
|
||||
|
||||
bool pendingDisabled = false; // set by a "~~ @disabled" marker line
|
||||
string pendingName = ""; // set by a "~~ @name ..." marker line
|
||||
while (idx < lines.Length)
|
||||
{
|
||||
string trimmed = lines[idx].TrimStart();
|
||||
|
|
@ -113,6 +114,8 @@ internal static class AfFileParser
|
|||
{
|
||||
if (trimmed.Equals("~~ @disabled", StringComparison.OrdinalIgnoreCase))
|
||||
pendingDisabled = true;
|
||||
else if (TryRuleName(trimmed, out string name))
|
||||
pendingName = name;
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -120,8 +123,9 @@ internal static class AfFileParser
|
|||
// Look for IF: line
|
||||
if (trimmed.StartsWith("IF:"))
|
||||
{
|
||||
var rule = new MetaRule { State = stateName, Enabled = !pendingDisabled };
|
||||
var rule = new MetaRule { State = stateName, Enabled = !pendingDisabled, Name = pendingName };
|
||||
pendingDisabled = false;
|
||||
pendingName = "";
|
||||
int ifIndent = CountLeadingTabs(lines[idx]);
|
||||
ParseIfBlock(lines, ref idx, rule, ifIndent);
|
||||
rules.Add(rule);
|
||||
|
|
@ -133,6 +137,19 @@ internal static class AfFileParser
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>"~~ @name Rebuff when low" (AfFileWriter's rule name line): the name, trimmed.
|
||||
/// "~~ @names..." or an empty "~~ @name" is just a comment.</summary>
|
||||
internal static bool TryRuleName(string trimmedLine, out string name)
|
||||
{
|
||||
name = "";
|
||||
const string marker = "~~ @name";
|
||||
if (!trimmedLine.StartsWith(marker, StringComparison.OrdinalIgnoreCase)) return false;
|
||||
string rest = trimmedLine.Substring(marker.Length);
|
||||
if (rest.Length == 0 || !char.IsWhiteSpace(rest[0])) return false;
|
||||
name = rest.Trim();
|
||||
return name.Length > 0;
|
||||
}
|
||||
|
||||
private static void ParseIfBlock(string[] lines, ref int idx, MetaRule rule, int ifIndent)
|
||||
{
|
||||
// Parse condition from IF: line
|
||||
|
|
|
|||
Loading…
Reference in a new issue