[−][src]Crate sgf_parser
SGF Parser for Rust
A sgf parser for rust. Supports all SGF properties, and tree branching.
Using pest for the actual parsing part.
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);
Structs
| GameNode | A game node, containing a vector of tokens | 
| GameTree | A game tree, containing it's nodes and possible variations following the last node | 
| SgfError | SGF parsing, or traversal, related errors | 
Enums
| Action | |
| Color | Indicates what color the token is related to | 
| DisplayNodes | |
| Encoding | |
| Game | |
| Outcome | |
| RuleSet | Provides the used rules for this game. Because there are many different rules, SGF requires mandatory names only for a small set of well known rule sets. Note: it's beyond the scope of this specification to give an exact specification of these rule sets. Mandatory names for Go (GM[1]): "AGA" (rules of the American Go Association) "GOE" (the Ing rules of Goe) "Japanese" (the Nihon-Kiin rule set) "NZ" (New Zealand rules) | 
| SgfErrorKind | Describes what kind of error we're dealing with | 
| SgfToken | Enum describing all possible SGF Properties | 
Functions
| parse | Main entry point to the library. Parses an SGF string, and returns a  |