Skip to content

优化谱面容错 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SimaiSharp/src/Internal/LexicalAnalysis/Tokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public IEnumerable<Token> GetTokens()
}

default:
throw new UnsupportedSyntaxException(_line, _charIndex);
// throw new UnsupportedSyntaxException(_line, _charIndex);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ private static void DecorateSlide(in Token token, ref SlidePath path)
path.type = NoteType.Break;
return;
default:
throw new UnsupportedSyntaxException(token.line, token.character);
// throw new UnsupportedSyntaxException(token.line, token.character);
return;
}
}

Expand Down Expand Up @@ -190,7 +191,7 @@ private static void ReadDuration(TimingChange timing, in Token token, ref SlideP
}
}

var durationDeclaration = token.lexeme.Span[startOfDurationDeclaration..];
var durationDeclaration = token.lexeme.Span[startOfDurationDeclaration..].ToString().Replace(" ", "");
var indexOfSeparator = durationDeclaration.IndexOf(':');

// Slide duration:
Expand Down
12 changes: 7 additions & 5 deletions SimaiSharp/src/SimaiFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public SimaiFile(FileSystemInfo file)
var fileStream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);

// Determine the encoding of the file
var buffer = new byte[64];
var buffer = new byte[64];
var numCharsRead = fileStream.Read(buffer, 0, 64);
var encoding = buffer[..numCharsRead].TryGetEncoding(sampleSize);
var encoding = buffer[..numCharsRead].TryGetEncoding(sampleSize);

// We've already read 64 chars, so we'll reset here.
fileStream.Position = 0;
Expand Down Expand Up @@ -59,7 +59,7 @@ public SimaiFile(StreamReader reader)

public IEnumerable<KeyValuePair<string, string>> ToKeyValuePairs()
{
var currentKey = string.Empty;
var currentKey = string.Empty;
var currentValue = new StringBuilder();

while (!_simaiReader.EndOfStream)
Expand All @@ -78,6 +78,8 @@ public IEnumerable<KeyValuePair<string, string>> ToKeyValuePairs()
}

var keyValuePair = line.Split('=', 2);
if (keyValuePair.Length != 2)
continue;
currentKey = keyValuePair[0][1..];
currentValue.AppendLine(keyValuePair[1]);
}
Expand All @@ -93,10 +95,10 @@ public IEnumerable<KeyValuePair<string, string>> ToKeyValuePairs()

public string? GetValue(string key)
{
var keyPart = $"&{key}=";
var keyPart = $"&{key}=";
var keyPartLength = keyPart.Length;

var result = new StringBuilder();
var result = new StringBuilder();
var readingValue = false;

while (!_simaiReader.EndOfStream)
Expand Down