Improve parser

This commit is contained in:
Loic Guegan 2022-01-27 08:04:32 +01:00
parent 92350c7cc9
commit 3fb48d4f29

View file

@ -190,6 +190,15 @@ loctype PGN::ParseHalfMove(loctype loc, HalfMove *hm) {
}
hm->move = move;
loc = GotoNextToken(loc);
EOF_CHECK(loc);
c = pgn_content[loc];
while (c == '{' || c == '$' || c == '(' || c == ';' || c == '%') {
if (c == '{') {
// Parse comment
loc = ParseComment(loc, hm);
} else if (c == '$') {
// Check for NAG
loc = GotoNextToken(loc);
EOF_CHECK(loc);
@ -206,10 +215,7 @@ loctype PGN::ParseHalfMove(loctype loc, HalfMove *hm) {
c = pgn_content[loc];
}
}
// Parse comment
loc = ParseComment(loc, hm);
} else if (c == '(') {
// Check for variations
loc = GotoNextToken(loc);
while (!IS_EOF && pgn_content[loc] == '(') {
@ -223,6 +229,11 @@ loctype PGN::ParseHalfMove(loctype loc, HalfMove *hm) {
EOF_CHECK(loc);
c = pgn_content[loc];
}
}
loc = GotoNextToken(loc);
EOF_CHECK(loc);
c = pgn_content[loc];
}
// Skip end of variation
loc = GotoNextToken(loc);