> > I've looked at your code, and there's something I don't understand.
> > The _build function creates the tables and is called by setup.py, I
> > see.
> > But if a user imports your module, how does it find the tab files in
> > the path and doesn't regenerate them ?
> > Did you modify PLY for that ?
>
> No.  As I recall now, it works simply because I pulled lex.py and
> yacc.py from ply and included them in the same directory as my code.
> When the code within lex.py and yacc.py tries to import the parsetab
> and lextab modules, it first looks in the same directory where lex.py
> and yacc.py reside.   It finds the modules there. so it doesn't
> regenerate them.
>
> If you don't want to do that, you'll have to do something like what is
> discussed in this email thread, mentioned 
> previously:http://groups.google.com/group/ply-hack/browse_thread/thread/848eeeda...
>
> Sorry for the confusion.

I ended up using the following method:

My package is named pycparser, and in it the parser and lexer get
'pycparser.yacctab' and 'pycparser.lextab' into their parsetab and
lextab parameters. This makes sure that these tables are looked for in
the module's directory, where they're initially placed with the setup
script.

So *users* of the module need not see the table file, and yet they do
enjoy the optimizations.

People who want to modify the package, have the option to pass in to
the parser to disable yacc/lex optimizations, and they will have the
tables regenerated for each new run.

Eli


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to