Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Fix PGN parsing of games w/ nested variations #125

Merged
merged 3 commits into from
Nov 24, 2024

Conversation

mikeb26
Copy link
Contributor

@mikeb26 mikeb26 commented May 26, 2023

Existing moveListWithComments() contains a parsing bug when the pgn in question contains a game with nested variations. In this case the moveListTokenRe regex doesn't work as expected and results in attempts to parse an illegal game. To demonstrate the problem this commit adds a TestScannerWithNested() test case along with a 0013.pgn fixture which is an export of a lichess study. This commit also fixes the problem by adding a stripVariations() preprocess step in moveListWithComments(). I have a subsequent commit coming which adds a Scanner option to include variations in the game list when processing a pgn.

Existing moveListWithComments() contains a parsing bug when the pgn in
question contains a game with nested variations. In this case the
moveListTokenRe regex doesn't work as expected and results in attempts
to parse an illegal game. To demonstrate the problem this commit adds
a TestScannerWithNested() test case along with a 0013.pgn fixture
which is an export of a lichess study. This commit also fixes the
problem by adding a stripVariations() preprocess step in
moveListWithComments(). I have a subsequent commit coming which adds a
Scanner option to include variations in the game list when processing
a pgn.
@notnil notnil merged commit 61dffef into notnil:master Nov 24, 2024
0 of 2 checks passed
@mikeb26 mikeb26 deleted the nestedVariationsFix branch November 26, 2024 17:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants