Closed Michael-F-Bryan closed 3 years ago
As mentioned in https://github.com/projectfluent/fluent-rs/pull/183#issuecomment-659661542:
It's possible to build a new tree by using a pushdown automaton which will build up a new AST on each transition, but you'll likely run into issues with the borrow checker.... When you recurse and add a new state to the stack, you'd be forced to "find" where you want to insert new nodes instead of just holding a reference to the parent in the automaton (multiple nested states means multiple mutable pointers into the same tree, which is no bueno).
I'm sure you could work around this with enough dynamic dispatch and indirection, but to be honest I'd just write the traversal/modification by hand at that point. That way you're free to do whatever you want and don't need to conform to a particular interface.
This experiment was useful, but I don't think we'll want to go down this path so I'm going to close the PR.
See https://github.com/projectfluent/fluent-rs/pull/183#issuecomment-651517745