The Grammar object created by yacc is actually a relatively new thing in PLY--part of some refactoring that I did in the Ply-3.x series. However, using it for other purposes is currently unexplored. There's no API for getting it or doing anything else with it for that matter. Thus, if you need to use it, you're going to have to hack something to expose. However, I would be open to patches or other enhancements to PLY that make it possible to work with that object.
It's probably about time to put out a new PLY release anyways so maybe that would be something to consider. Cheers, Dave On Jan 29, 2010, at 6:54 AM, eliben wrote: > Hi Dave, > > I want to employ the technique described in > http://eli.thegreenplace.net/2010/01/28/generating-random-sentences-from-a-context-free-grammar/ > to auto-generate test cases for my PLY-based parser. So I need to walk > over the productions created from my grammar definition. > > For that purpose, I need access to the Grammar object created from my > grammar, however there seems to me there's no way accessing it given > PLY's code at it is now. The yacc function creates the grammar object > just to run LR on it, and doesn't save it. And I can't access it > through the parser. > > Am I missing something, or must I hack into PLY to make this possible. > I guess I could create an alternative yacc function that saves the > grammar somewhere, but is there a simpler way? > > Thanks in advance > 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. > -- 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.
