haoxiang47 / ply

Automatically exported from code.google.com/p/ply
0 stars 0 forks source link

Wrong output filename for the parsing tables module #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've found a problem with ply2.3 related to parsing table reloading. I am
using python2.5.1 (on windows2K :().

When we want to read the parsing tables from a dotted module name like
'pckg.subpckg.parsetab' (by adding 'tabmodule = "pckg.subpckg.parsetab" to
the parser constructor), the lr_read_tables function executes 'import
pckg.subpckg.parsetab as parsetab'. This is fairly ok, but that's not the
problem.

The problem is, when yacc writes the tables, it will write to a file named
'pckg.subpckg.parsetab.py' inside the specified outputdir (using the full
module name, and not only parsetab).
This isn't what we intended, so at reload, yacc will search for
'pckg.subpckg.parsetab' but it won't find a file named 'parsetab.py' inside
a 'pckg/subpckg' directory on python's module search path. 

So, instead of loading the tables from the previously generated file, it
will regenerate the parsing tables every time it gets loaded.

I've fixed the bug on my ply source. The solution is rather ugly (to blend
with the rest of yacc's source :P), but the problem seems to be gone. If
anyone's interested in my solution, please contact me be email (cptbinho at
gmail dot com) and i'll gladly send you my modified version.

Regards

Original issue reported on code.google.com by cptbi...@gmail.com on 8 Apr 2008 at 8:52

GoogleCodeExporter commented 8 years ago
Fixed in Ply-2.4.

Original comment by dbeaz...@gmail.com on 4 May 2008 at 3:05