Skip to content
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

Parsing crashes on game with {...} indicating incomplete move log #4

Closed
atduskgreg opened this issue Jul 25, 2014 · 2 comments
Closed

Comments

@atduskgreg
Copy link

The following PGN appears in the http://chessgames.com archive of games played in 2014:

[Event "Bunratty Masters"]
[Site "Bunratty Co. Clare, Ireland"]
[Date "2014.02.08"]
[EventDate "2014.??.??"]
[Round "3"]
[Result "1-0"]
[White "Drahoslav Stejskal"]
[Black "Brendan Lyons"]
[ECO "B01"]
[WhiteElo "2129"]
[BlackElo "1888"]
[PlyCount "60"]

1. e4 d5 2. exd5 Nf6 3. Bb5+ Bd7 4. Be2 Bf5 5. Nf3 Nxd5 6. c3
e6 7. d4 Bd6 8. Bg5 f6 9. Be3 Nf4 10. Bxf4 Bxf4 11. Nh4 Be4
12. Bc4 Qd6 13. Qg4 Nd7 14. Qxe6+ Qxe6 15. Bxe6 Bc6 16. a4
O-O-O 17. O-O Bg5 18. Nf3 Bxf3 19. gxf3 Rhe8 20. Bc4 Nb6
21. Bd3 g6 22. Na3 c5 23. Nb5 Re7 24. dxc5 Nd7 25. Bc4 Nxc5
26. Rad1 Bf4 27. b4 Nd7 28. Nd6+ Kc7 29. Ne4 f5 30. Ng3 {...}
1-0

Trying to parse this with PGN raises the following error:

Whittle::UnconsumedInputError: Unmatched input "{...}\n1-0" on line 19
    from /Users/greg/.rvm/gems/ruby-1.9.3-p362/gems/whittle-0.0.8/lib/whittle/parser.rb:251:in `block in lex'
    from /Users/greg/.rvm/gems/ruby-1.9.3-p362/gems/whittle-0.0.8/lib/whittle/parser.rb:250:in `tap'
    from /Users/greg/.rvm/gems/ruby-1.9.3-p362/gems/whittle-0.0.8/lib/whittle/parser.rb:250:in `lex'
    from /Users/greg/.rvm/gems/ruby-1.9.3-p362/gems/whittle-0.0.8/lib/whittle/parser.rb:204:in `parse'
    from /Users/greg/.rvm/gems/ruby-1.9.3-p362/gems/pgn-0.0.6/lib/pgn.rb:23:in `parse'
    from (irb):5
    from /Users/greg/.rvm/rubies/ruby-1.9.3-p362/bin/irb:16:in `<main>'    

I think that "{...}" is meant to indicate an incomplete move log. Even though it doesn't appear in any PGN documentation that I can find. Not sure what the best policy in parsing is here, however the current result where I'm PGN crashes midway through parsing this archive of ~10,000 games and forces me to write code that splits up the games myself with a regex and iterates over the resulting strings in order to pass them one-by-one into PGN to rescue just the one that crashes is probably not the optimal situation.

@tobiasvl
Copy link
Contributor

I've added support for comments in my fork (see #3), can you test there?

@capicue
Copy link
Owner

capicue commented Feb 16, 2016

Merged & released https://rubygems.org/gems/pgn/versions/0.1.0

Thanks for reporting this. Sorry about the wait!

@capicue capicue closed this as completed Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants