That rather sounds like a Java problem. It seems you are manipulating an ArrayList (insert/delete) while your enumerating it. If you want to remove nodes collect the candidates first in a separate list. Then iterate over that candidate list and remove any candidate from the original list.
Add subtree to main tree?
-
03-06-2022 - |
Question
I am currently manually walking the tree instead doing a tree grammar using ANTLR/CommonTree. I have done some transformations and I would like to move some of them to the parent of that tree. It can also happen be the root.
Example:
Say this AST, I would like to move all VARDECL statement inside BLOCK to the root of the tree.
Doing so: I get an exception
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
at java.util.ArrayList$Itr.next(Unknown Source)
Any idea how can I go around this problem? Thanks in advance!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow