I haven't really spent much time thinking about this, but the PLY-3.0 release might make it significantly easier to explore such possibilities--namely because I refactored the yacc internals to make different parts of it more self-contained. It might be possible to build this kind of functionality into an intermediate step.
I suppose one could revisit the question of rules that allow repeats (e.g., TOKEN*) as well. Hmmm. Interesting. Cheers, Dave On Mon 09/02/09 1:25 PM , eliben [email protected] sent: > > Hello, > > In complex grammars I find myself writing dozens of productions of the > type: > > def p_XXX_opt(self, p): > """ XXX_opt : empty > | XXX > """ > p[0] = p[1] > > For many different XXXs. > It really gets tiresome, and I was wondering about the alternatives. > > * Has anyone attempted some meta-programming magic to generate such > methods automatically from a list of productions? > * Dave, have you considered adding "optional" as a feature to > PLY? Itwould be really useful, not hard to implement, and the syntax is > really simple: > > """ YYY : XXX?""" > > The question mark can mean "XXX or empty", and in case of empty > therelevant item of the p[] array just gets None. > > Eli > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google Groups > "ply-hack" group.To post to this group, send email to ply > [email protected] unsubscribe from this group, send email to ply-hack+ > [email protected] 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 -~----------~----~----~----~------~----~------~--~---
