pub fn parse(input: &str) -> Result<GameTree, SgfError>
Expand description
Main entry point to the library. Parses an SGF string, and returns a GameTree
.
Returns an SgfError
when parsing failed, but it tries to recover from most kind of invalid input and insert SgfToken::Invalid
or SgfToken::Unknown
rather than failing
use sgf_parser::*;
let tree: Result<GameTree, SgfError> = parse("(;EV[event]PB[black]PW[white]C[comment];B[aa];W[bb])");
let tree = tree.unwrap();
assert_eq!(tree.count_max_nodes(), 3);