Skip to content

Commit a018239

Browse files
committed
[+] PrepFix3、4
1 parent 5696f3a commit a018239

6 files changed

Lines changed: 45 additions & 3 deletions

File tree

i18n/Locale.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

i18n/Locale.resx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,15 @@
152152
<value>This note is closer than a 384th note to the previous note. MA2 can only represent timing down to 1/384 of a whole note, so these two notes cannot be represented exactly and may be emitted as a yellow EACH pair. If you want a "fake EACH", use syntax such as "1`2", or offset the notes by at least one 384th note.</value>
153153
</data>
154154
<data name="PrepFix1" xml:space="preserve">
155-
<value>TODO</value>
155+
<value>Attempted to fix {0} syntax error(s) in the chart (inserting possibly missing commas): {1}</value>
156156
</data>
157157
<data name="PrepFix2" xml:space="preserve">
158-
<value>TODO</value>
158+
<value>Attempted to fix {0} syntax error(s) in the chart (duration markers used "-" instead of ":"): {1}</value>
159159
</data>
160160
<data name="PrepFix3" xml:space="preserve">
161-
<value>TODO</value>
161+
<value>Attempted to fix {0} syntax error(s) in the chart (star-head modifiers should appear after the lane number and before the star type marker): {1}</value>
162+
</data>
163+
<data name="PrepFix4" xml:space="preserve">
164+
<value>Attempted to fix {0} syntax error(s) in the chart (redundant duplicate parentheses, possibly from extra typing): {1}</value>
162165
</data>
163166
</root>

i18n/Locale.zh-hans.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@
160160
<data name="PrepFix3" xml:space="preserve">
161161
<value>尝试修复了谱面中的{0}处语法错误(对星星头的修饰符,应该出现在键位号后、星星类型标记之前): {1}</value>
162162
</data>
163+
<data name="PrepFix4" xml:space="preserve">
164+
<value>尝试修复了谱面中的{0}处语法错误(重复的括号,可能是多打了一些): {1}</value>
165+
</data>
163166
</root>

i18n/Locale.zh-hant.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,16 @@
151151
<data name="NoteTooNear" xml:space="preserve">
152152
<value>此音符與前一個音符的時間距離小於 384 分音!受 MA2 語法限制,MA2 所能表示的時間精度僅能達到 1/384,因此這兩個音符無法被精確表示,且可能被生成為黃色雙押。若您需要的是「偽雙押」,請使用「1`2」這類語法表示偽雙押,或將兩個音符至少錯開一個 384 分音的時間。</value>
153153
</data>
154+
<data name="PrepFix1" xml:space="preserve">
155+
<value>嘗試修復了譜面中的{0}處語法錯誤(補上了可能缺失的逗號): {1}</value>
156+
</data>
157+
<data name="PrepFix2" xml:space="preserve">
158+
<value>嘗試修復了譜面中的{0}處語法錯誤(持續時間標記中誤用了「-」,而不是「:」): {1}</value>
159+
</data>
160+
<data name="PrepFix3" xml:space="preserve">
161+
<value>嘗試修復了譜面中的{0}處語法錯誤(對星星頭的修飾符,應該出現在鍵位號後、星星類型標記之前): {1}</value>
162+
</data>
163+
<data name="PrepFix4" xml:space="preserve">
164+
<value>嘗試修復了譜面中的{0}處語法錯誤(重複的括號,可能是多打了一些): {1}</value>
165+
</data>
154166
</root>

parser/simai/SimaiParser.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ private void _warnPrepfixMsg(string messageTemplate, List<string> msgArr)
7979
[GeneratedRegex(@"\[(\d+)-(\d+)\]")]
8080
private static partial Regex PrepFix2(); // 错误的Duration语法
8181

82+
[GeneratedRegex(@"(\d)([\-v<>\^pqVszw]|pp|qq)([@?!bx]+)(\d)")]
83+
private static partial Regex PrepFix3(); // 星星头的modifier应该在键位号之后、星星体之前
84+
85+
[GeneratedRegex(@"\((\(\d+\))\)?|(\(\d+\))\)|\[(\[\d+\])\]?|(\[\d+\])\]|\{(\{\d+\})\}?|(\{\d+\})\}")]
86+
private static partial Regex PrepFix4(); // 重复的冗余括号
87+
8288
public string Preprocess(string text, bool tryFix = false)
8389
{
8490
// 移除注释
@@ -94,6 +100,14 @@ public string Preprocess(string text, bool tryFix = false)
94100
List<string> prepFix2Msgs = [];
95101
text = PrepFix2().Replace(text, m => _replaceAndRecord(m, "[$1:$2]", prepFix2Msgs));
96102
_warnPrepfixMsg(Locale.PrepFix2, prepFix2Msgs);
103+
104+
List<string> prepFix3Msgs = [];
105+
text = PrepFix3().Replace(text, m => _replaceAndRecord(m, "$1$3$2$4", prepFix3Msgs));
106+
_warnPrepfixMsg(Locale.PrepFix3, prepFix3Msgs);
107+
108+
List<string> prepFix4Msgs = [];
109+
text = PrepFix4().Replace(text, m => _replaceAndRecord(m, "$1$2$3$4$5$6", prepFix4Msgs));
110+
_warnPrepfixMsg(Locale.PrepFix4, prepFix4Msgs);
97111
}
98112

99113
return text;

tests/Simai预处理纠错测试.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace MuConvert.Tests;
77
/// <summary>
88
/// 针对另一项目中 <c>FixChartSimaiSharp</c> / <c>SimaiParser.Preprocess</c> 计划支持的常见非标准 Simai 写法。
99
/// 每个用例比较:纠错后应与「规范写法」解析得到的 MA2 完全一致。
10+
/// 另含带 <c>#</c>、<c>||</c> 行注释的谱面(见 <see cref="Comment_Cases"/> / <see cref="含有注释"/>),与 Preprocess 去注释行为对齐。
1011
/// 在 <see cref="SimaiParser.Preprocess"/> 尚未接入对应替换逻辑前,本文件中的测试失败或抛错属于预期行为(TDD)。
1112
/// </summary>
1213
public class Simai预处理纠错测试

0 commit comments

Comments
 (0)