chem-parse 0.3.0

A parser for simple chemical forumulas.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use chem_parse::parse;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let string = String::from("4Fe+3O2->2Fe2O");
    let ast = parse(string)?;
    // Node: comment broken up into multiple lines
    // Ast: Equation(
    //   Reactants([ForumulaUnit(4, [Element(1, "Fe")]), ForumulaUnit(3, [Element(2, "O")])]),
    //   Products([ForumulaUnit(2, [Element(2, "Fe"), Element(1, "O")])])
    // )
    println!("Ast: {:?}", ast);
    Ok(())
}