sgf-0.1: SGF (Smart Game Format) parser




collection :: Stream s m Word8 => ParsecT s u m (Collection, [Warning])Source

Parse a Word8 stream into an SGF collection. A collection is a list of games; the documentation for Game has more details. There are generally two kinds of errors in SGF files: recoverable ones (which will be accumulated in the [Warning] return) and unrecoverable ones (which will result in parse errors).

clipDate :: PartialDate -> PartialDateSource

Clip to a valid, representable date. Years are clipped to the 0000-9999 range; months are clipped to the 1-12 range, and days are clipped to the 1-<number of days in the given month> range (accounting for leap years in the case of February).

If a parsed date is changed by this function, a warning is emitted.

data PropertyType Source

Types of properties, as given in the SGF specification.



Technically, these properties have type "none" and attribute "inherit", but the property index lists them as properties of type "inherit" with no attributes, so we follow that lead.


properties :: GameType -> PropertyType -> [String]Source

All properties of each type listed in the SGF specification.

extraProperties :: GameType -> PropertyType -> [String]Source

Just the properties associated with specific games.

data Property Source




position :: SourcePos

Currently, this is pretty lame: it doesn't track line number and character number, only byte offset from the beginning of the file. This is because I don't really understand how to correctly track line number and character number properly in the face of dynamically changing encodings, whereas byte number is a totally braindead statistic to track.

name :: String

The literal name of the property. This is guaranteed to be a non-empty string of upper-case ASCII characters.

values :: [[Word8]]

The arguments to the property.