From 75cc4bd62e248cdca3cdbdc0f62c486b83c63b21 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 28 Jun 2026 16:16:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=87=A6=E7=90=86=E3=81=AE=E5=85=B1=E9=80=9A=E5=8C=96?= =?UTF-8?q?=E3=81=A8=E6=8A=BD=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/Compat/AviUtlParameterLayout.cs | 26 +++++------------------ LuaScript/Compat/AviUtlScript.cs | 24 ++++----------------- LuaScript/Compat/ScriptParserHelper.cs | 21 ++++++++++++++++++ 3 files changed, 30 insertions(+), 41 deletions(-) create mode 100644 LuaScript/Compat/ScriptParserHelper.cs diff --git a/LuaScript/Compat/AviUtlParameterLayout.cs b/LuaScript/Compat/AviUtlParameterLayout.cs index ef4c92a..3cca856 100644 --- a/LuaScript/Compat/AviUtlParameterLayout.cs +++ b/LuaScript/Compat/AviUtlParameterLayout.cs @@ -49,13 +49,13 @@ namespace LuaScript.Compat int sectionEnd = lines.Length; for (int i = 0; i < lines.Length; i++) { - if (!IsSectionHeader(lines[i])) + if (!ScriptParserHelper.IsSectionHeader(lines[i])) continue; sectionStart = i + 1; sectionEnd = lines.Length; for (int j = sectionStart; j < lines.Length; j++) { - if (IsSectionHeader(lines[j])) + if (ScriptParserHelper.IsSectionHeader(lines[j])) { sectionEnd = j; break; @@ -72,7 +72,7 @@ namespace LuaScript.Compat private void ParseLine(string line) { - int i = SkipSpaces(line, 0); + int i = ScriptParserHelper.SkipSpaces(line, 0); if (i + 1 >= line.Length || line[i] != '-' || line[i + 1] != '-') return; i += 2; @@ -80,7 +80,7 @@ namespace LuaScript.Compat return; int nameStart = i; - while (i < line.Length && IsNameChar(line[i])) + while (i < line.Length && ScriptParserHelper.IsNameChar(line[i])) i++; if (i >= line.Length || line[i] != ':') return; @@ -174,27 +174,11 @@ namespace LuaScript.Compat private static string FirstToken(string content) { - int start = SkipSpaces(content, 0); + int start = ScriptParserHelper.SkipSpaces(content, 0); int i = start; while (i < content.Length && content[i] != ',' && content[i] != ' ' && content[i] != '\t') i++; return content.Substring(start, i - start); } - - private static bool IsSectionHeader(string line) - { - int i = SkipSpaces(line, 0); - return i < line.Length && line[i] == '@'; - } - - private static int SkipSpaces(string text, int index) - { - while (index < text.Length && (text[index] == ' ' || text[index] == '\t')) - index++; - return index; - } - - private static bool IsNameChar(char c) => - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } } diff --git a/LuaScript/Compat/AviUtlScript.cs b/LuaScript/Compat/AviUtlScript.cs index af71045..681a66a 100644 --- a/LuaScript/Compat/AviUtlScript.cs +++ b/LuaScript/Compat/AviUtlScript.cs @@ -26,7 +26,7 @@ namespace LuaScript.Compat for (int i = 0; i < lines.Length; i++) { - if (!IsSectionHeader(lines[i])) + if (!ScriptParserHelper.IsSectionHeader(lines[i])) continue; hasSection = true; @@ -34,7 +34,7 @@ namespace LuaScript.Compat sectionEnd = lines.Length; for (int j = sectionStart; j < lines.Length; j++) { - if (IsSectionHeader(lines[j])) + if (ScriptParserHelper.IsSectionHeader(lines[j])) { sectionEnd = j; break; @@ -59,15 +59,9 @@ namespace LuaScript.Compat return builder.ToString(); } - private static bool IsSectionHeader(string line) - { - int i = SkipSpaces(line, 0); - return i < line.Length && line[i] == '@'; - } - private static void AppendDeclarations(string line, List prelude) { - int i = SkipSpaces(line, 0); + int i = ScriptParserHelper.SkipSpaces(line, 0); if (i + 1 >= line.Length || line[i] != '-' || line[i + 1] != '-') return; i += 2; @@ -75,7 +69,7 @@ namespace LuaScript.Compat return; int nameStart = i; - while (i < line.Length && IsNameChar(line[i])) + while (i < line.Length && ScriptParserHelper.IsNameChar(line[i])) i++; if (i >= line.Length || line[i] != ':') return; @@ -125,15 +119,5 @@ namespace LuaScript.Compat if (trimmed.Length != 0) prelude.Add(trimmed); } - - private static int SkipSpaces(string text, int index) - { - while (index < text.Length && (text[index] == ' ' || text[index] == '\t')) - index++; - return index; - } - - private static bool IsNameChar(char c) => - (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } } diff --git a/LuaScript/Compat/ScriptParserHelper.cs b/LuaScript/Compat/ScriptParserHelper.cs new file mode 100644 index 0000000..2842c34 --- /dev/null +++ b/LuaScript/Compat/ScriptParserHelper.cs @@ -0,0 +1,21 @@ +namespace LuaScript.Compat +{ + internal static class ScriptParserHelper + { + public static bool IsSectionHeader(string line) + { + int i = SkipSpaces(line, 0); + return i < line.Length && line[i] == '@'; + } + + public static int SkipSpaces(string text, int index) + { + while (index < text.Length && (text[index] == ' ' || text[index] == '\t')) + index++; + return index; + } + + public static bool IsNameChar(char c) => + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); + } +}