Latest 0.2.0
Homepage https://github.com/tigerpixel/PGNParser
License MIT
Platforms ios 8.0, watchos 2.0, osx 10.9, tvos 9.0, requires ARC
Dependencies Currier, ParserCombinator
Authors

Build Status
Version
Platform
Carthage compatible
License

PGNParser is designed to parse Portable Game Notation files describing Chess and Draughts moves into simple Swift structures.

Currently, only the draughts game strings have been implemented. Pull requests are welcome for further features.

Parsing can be enacted by simply making a single call on the draughts move objects.

A result type will be returned which will contain the resulting move array or details of any failure.

A failure contains an enumeration describing the reason for the failure and usually the token which failed.

The following will parse to on DraughtsMove structure containing a black and a white move.

let sinlgeMoveTwoPlayers = "1. 9-14 23-18"

switch DraughtsMove.parse(fromPortableGameNotation: sinlgeMoveTwoPlayers) {
case .success(let moves, let tail):
// moves - a list of the above moves and any comments parsed into DraughtsMove structs.
case .failure(let reason):

}

Requirements

There are 2 external requirements for this project. Both by Tigerpixel, the same authors.

Currier – A helper for currying functions and initializers which is used with the project.
ParserCombinator – A General parser combinator which is extended to build PGNParser.

  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

Cocoapods

PGNParser is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "PGNParser"

Carthage

If you use Carthage to manage your dependencies, simply add the following lines to your Cartfile:

github "tigerpixel/PGNParser"
github "tigerpixel/Currier"
github "tigerpixel/ParserCombinator"

If you use Carthage to build your dependencies, make sure you have added PGNParser.framework, Currier.framework and ParserCombinator.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.

Swift Package Manager

The Swift Package Manager is the official tool for managing the distribution of Swift code. It is currently available for macOS. It can also be used with Linux but this project does not fully support Linux at this point in time.

If you use it to manage your dependencies, simply add PGNParser to the dependencies value of your Package.swift file.

dependencies: [
.Package(url: "https://github.com/Tigerpixel/PGNParser.git", majorVersion: 0)
]

The Swift Package Manager can resolve sub-dependencies.

Git Submodule

  1. Add the PGNParser repository as a submodule of your application’s repository.
  2. Run git submodule update --init --recursive from within the PGNParser folder.
  3. Drag and drop PGNParser.xcodeproj into your application’s Xcode project or workspace.
  4. On the “General” tab of your application target’s settings, add PGNParser.framework. to the “Embedded Binaries” section.
  5. If your application target does not contain Swift code at all, you should also set the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting to “Yes”.

MIT License

PGNParser is available under the MIT license. Details can be found within the LICENSE file.

Latest podspec

{
    "name": "PGNParser",
    "version": "0.2.0",
    "summary": "A simple way to parse Portable Game Notation into Swift objects.",
    "description": "A simple way to parse Portable Game Notation into Swift objects. Easily parse game strings into Swift objects with just a single call. More work is required to fully suppourt the format. Pull requests for improvements are welcome.",
    "homepage": "https://github.com/tigerpixel/PGNParser",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Tigerpixel": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tigerpixel/PGNParser.git",
        "tag": "0.2.0"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0",
        "watchos": "2.0",
        "osx": "10.9",
        "tvos": "9.0"
    },
    "source_files": "Source/**/*.swift",
    "dependencies": {
        "Currier": [],
        "ParserCombinator": []
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This