What I ultimately wound up doing was turning off optimization. I was going through the PLY 3.4 source and I found this little nugget in the lexer code:
# If in optimize mode, we write the lextab
if lextab and optimize:
lexobj.writetab(lextab,outputdir)
return lexobj
By changing the code that builds the lexer and parser to:
self.lexer = lex.lex(module=self, optimize=False, debug=False, **kwargs)
and
self.lexer = lex.lex(module=self, optimize=False, debug=False, **kwargs)
I avoided all file write-outs. The debugger writes .out
files into the directory and the Python files are the result of the optimize
flag.
While this works for the time being, I cannot say I am entirely happy with this approach. Presumably, having some way to keep optimization on and, at the same time, keep the working directory clean would be a superior solution would result in better performance. If someone else has a better methodology, I am more than open to it.
ply
. You can change the filename or directory to use, or choose to always regenerate the tables (which may not be an option, depending the size of your grammar). But to ship the parser table generated... don't know. :/ – Alabama