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? It
would 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 the
relevant 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 [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
-~----------~----~----~----~------~----~------~--~---