State with nom (>5) and `alt`
Such side effect are an anti pattern in a parser conbinator. You may use the wrong tool for your code style. it's the parser that own the ast
that should mutate it, by sharing ast
with your sub parser you ask for bug specially using alt
.
Nom linked issue, note that if you really want to do that as Geal said you may use Rc<RefCell<AST>>
.
You could also just do alt()
manually it's just a bunch of if
.