8 releases (4 stable)

✓ Uses Rust 2018 edition

new 2.2.0 Sep 15, 2019
2.1.0 Sep 12, 2019
1.0.0 Apr 29, 2019
0.4.0 Apr 14, 2019
0.1.0 Dec 19, 2018

#109 in Parser tooling

Download history 10/week @ 2019-06-02 15/week @ 2019-06-09 13/week @ 2019-06-16 17/week @ 2019-06-23 41/week @ 2019-06-30 11/week @ 2019-07-07 1/week @ 2019-07-21 4/week @ 2019-07-28 18/week @ 2019-08-04 6/week @ 2019-08-11 14/week @ 2019-08-25 17/week @ 2019-09-01 49/week @ 2019-09-08

64 downloads per month
Used in 1 crate

MIT license

40KB
938 lines

Build Status Crate

SGF Parser

A SGF Parser for Rust. Supports all SGF properties, and tree branching.

Using pest for the actual parsing part.

Development

Code quality is ensured by running both cargo clippy and cargo fmt on each commit.

All code should also be unit tested.

Example usage

use sgf_parser::*;

let sgf_source = "(;C[comment]EV[event]PB[black]PW[white];B[aa])";
let tree: Result<GameTree, SgfError> = parse(sgf_source);

let tree = tree.unwrap();
let unknown_nodes = tree.get_unknown_nodes();
assert_eq!(unknown_nodes.len(), 0);

let invalid_nodes = tree.get_invalid_nodes();
assert_eq!(invalid_nodes.len(), 0);

tree.iter().for_each(|node| {
  assert!(!node.tokens.is_empty());
});

let sgf_string: String = tree.into();
assert_eq!(sgf_source, sgf_string());

Dependencies

~3.5MB
~87K SLoC