Revert "Add flag to indicate whether single game or multi game pgn is being parsed, handle linebreaks accordingly"

This reverts commit db66704b0e.
This commit is contained in:
Kaustubh Khavnekar
2024-10-07 00:40:43 -04:00
parent e97e820f2d
commit 331c24b89e
2 changed files with 8 additions and 13 deletions
+4 -9
View File
@@ -103,7 +103,7 @@ class PgnGame<T extends PgnNodeData> {
final List<PgnGame<PgnNodeData>> games = [];
_PgnParser((PgnGame<PgnNodeData> game) {
games.add(game);
}, initHeaders, true)
}, initHeaders)
.parse(pgn);
if (games.isEmpty) {
@@ -126,7 +126,7 @@ class PgnGame<T extends PgnNodeData> {
final List<PgnGame<PgnNodeData>> games = [];
_PgnParser((PgnGame<PgnNodeData> game) {
games.add(game);
}, initHeaders, false)
}, initHeaders)
.parse(pgn);
return games;
}
@@ -678,10 +678,7 @@ class _PgnParser {
/// Function to create the headers
final PgnHeaders Function() initHeaders;
/// If true, pgn string is parsed for a single game. If false, pgn string is considered to have multiple games and any linebreak is considered as start of a new game
final bool singleGame;
_PgnParser(this.emitGame, this.initHeaders, this.singleGame) {
_PgnParser(this.emitGame, this.initHeaders) {
_resetGame();
_state = _ParserState.bom;
}
@@ -779,9 +776,7 @@ class _PgnParser {
{
if (freshLine) {
if (_isCommentLine(line)) return;
if (!singleGame) {
if (_isWhitespace(line)) return _emit();
}
if (_isWhitespace(line)) return _emit();
}
final tokenRegex = RegExp(
r'(?:[NBKRQ]?[a-h]?[1-8]?[-x]?[a-h][1-8](?:=?[nbrqkNBRQK])?|[pnbrqkPNBRQK]?@[a-h][1-8]|O-O-O|0-0-0|O-O|0-0)[+#]?|--|Z0|0000|@@@@|{|;|\$\d{1,4}|[?!]{1,2}|\(|\)|\*|1-0|0-1|1\/2-1\/2/');