Hi, I'm working on a parser for a simple assembly language and struggled to update the symbol_table stored in a state that's passed throughout the parser. I tried implementing the symbol_table as HashMap<String, usize> and Box<HashMap<String, usize>> but updates in both are lost.
Thank you for looking through the code. I think output is only an argument to the closure and the returned state of the closure is set to be the new state in update_state.
Thanks for the suggestion. I replaced the std::collections::HashMap with the im version but the problem persisted. I believe it's a problem of returning new struct from a function. For some reason, the new struct is not remembered but the old version is kept. Do you have any idea on how to correct this?
Thank you so much for pointing me in the right direction. I finaly found and fixed the bug. It is a logic error indeed and a lot of them... It turns out the HashMap is updated very time but I didn't use the new state in most of the parser combinators so they are discarded😭. An even more absurd loophole is in the map_with_state function where I didn't even expose the new state. I went through an afternoon of refactoring and simply lost my mind.