chem_parse/ast_types.rs
1// TODO: change Node to be proper types once
2// we get variants as types, eventually
3/// A Node in the AST (abstract syntax tree)
4#[derive(Debug, PartialEq)]
5pub enum Node {
6 /// Chemical elements e.g. O2.
7 /// The number is the subscript, in this case 2
8 Element(u16, String),
9 /// Groups of elements or other groups (Polyatoms) e.g. (2FeO2)4
10 /// The number is the subscript, in this case 4
11 Group(u16, Vec<Node>),
12 /// Forumula Unit, a few elements and/or polyatoms eg 7(NH4)2SO4
13 /// This number is the coeffecient, in this case 7
14 ForumulaUnit(u16, Vec<Node>),
15 /// The reactants side (left) of yields (->)
16 Reactants(Vec<Node>),
17 /// The products side (right) of yeilds (->)
18 Products(Vec<Node>),
19 /// The whole equation
20 Equation(Box<Node>, Box<Node>),
21}