parse method
Parses text and returns the root RecursiveNode.
If the input is a parenthesized game or contains multiple top-level
variations, a dummy anchor (with negative id) is returned and its
children represent top-level roots.
Implementation
RecursiveNode parse(
String text, {
IdGenerator? getId,
NodeCallback? onNodeCreated,
}) {
getId ??= (() {
var id = 0;
return () => id++;
})();
onNodeCreated ??= (_) {};
final tokens = TokenIterator(text);
final root = _parseTokens(
tokens,
null,
getId: getId,
onNodeCreated: onNodeCreated,
);
return root ?? RecursiveNode(-1, null, {}, []);
}