Skip to content

ItsDrike/pgnparse

Repository files navigation

PgnParse

supported python versions current PyPI version CI

This is a simple library capable of parsing chess PGNs, following the standard definition. It includes classes that form an Abstract Syntax Tree, fully representing the parsed PGN with code. These classes also include __str__ implementations that allow seamless conversion back to regular (normalized) PGN strings.

A unique feature of this library is the flatten function for a list of moves. This function allows for the flattening of a list of moves, recursively stripping away all of the variations in a chess game and returning full standalone lists for each variation.

The parsing is handled using the Lark library, which is therefore a dependecy of this library. Lark allows specifying a formal EBNF-like grammar definition, which it then uses to tokenize the given input. This token tree is then used to produce the AST.

Future Goals

  • Implement the basic PGN grammar & tokenizer
  • AST classes for PGN
  • Add some usage examples / docs
  • Consider re-exporting lark errors from the lib
  • Consider implementing a FEN parser
  • Consider implementing chess logic
    • Move validation
    • Board position evaluation
    • Potential for PGN -> FEN conversion

About

A library for parsing PGN chess notations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages