Newick tree format parser using nearley.js. This attempts to solve parsing issues that are common in other Newick parsers that rely on stacks to track the most recent (
. Due to the naturally nested nature of trees, recursion should be leveraged to parse deeply-nested trees. This library uses Nearley.js parser to convert Newick string into Abstract Syntax Tree to encode the tree structure and metadata (node name, edge length, whether the node is leaf or internal).
├── lib
│ ├── newick_grammar.ne # nearley grammar for parsing newick format
│ ├── newick_grammar.js # parser from nearley compilation, generated by `npm run compile`
│ ├
│ ├── index.js # main
│ ├── parser.js # newick format parser
│ ├── grammar.js # grammar used for `parser.js`
Edit lib/newick_grammar.ne
and run npm run compile
to generate lib/newick_grammar.js
.
Compilation should be done at library development. nearley-newick
library user should only use the compiled grammar newick_grammar.js
via grammar.js
.
npm run test