#4965·antlr4

caching parse tree object

Author: janikFrickCreated Jul 30, 2026Updated Jul 31, 2026

Hi, I use antlr for a translation task. My translator is written in python and I use the visitor pattern. This requires multiple steps and calls of my software with the same input but different parameters. The translation itself is quite fast, even on larger inputs. But the creation of the parsetree takes quite some time is the creation of the parse-tree object. The idea was to cache the tree in a file, but the context is not serializable. The second thought was to keep it alive in a seperate process or sth like this, but the time betwenn the different calls for the different steps can vary a lot, so this would not be really applicable.

Does anyone have an idea how i could manage this situation?