Open syegulalp opened 5 years ago
The grammar rules/tables aren't stored in instances of Parser, but on the class itself. Thus, that information won't be stored as part of any kind of pickle.
Trying to cache parsing tables has caused no end of headaches in the related "PLY" project. SLY does not do that. How much startup time are you seeing?
Not a gigantic amount, but it's a noticeable pause (maybe 0.3/0.4 sec?). It's more of a nice-to-have than a must-have, especially since the project (which I thank you for, BTW) is still so young.
Another idea that comes to mind is code generation a la ANTLR, but I imagine you are getting flashbacks and horror chills just contemplating the idea.
BTW, here is how I'm currently implementing the lex/parse classes in my project:
https://github.com/syegulalp/Akilang/blob/master/aki/core/lex.py https://github.com/syegulalp/Akilang/blob/master/aki/core/parse.py
(They're probably quite messy, I'm still learning)
Is there any way to take a given lexer/parser and pickle the results once the class is instantiated, and then reuse it later (to save us some startup time)? I tried to pickle a created Parser class with rules but the resulting file didn't seem to have any of the grammar data in it.