This PR rewrites the rnix parser to instead of storing everything in enums with values, store everything inside a struct with kind and children. In a way, the tree is now a tree of tokens. This is another suggestion by matklad.
Pros:
Vec<NodeId>
at times. Now, one node can only have one child... but each child can have one sibling. This means we can get all children by getting the first child and iterate from sibling to sibling until we reach the end.fmt::Display
code is simpler. Just iterate recursively and print out all the tokens and identifiers and values etc!Cons:
name
, now requires looking the element up in the iterator of children. This should be done by adding different methods to parser/types.rs
, most of the times as a trait like HasPair for 1 + 2, but sometimes also functions specific to types. I've made a convenience macro for generating wrapper types.