On Tue, Jul 26, 2011 at 11:04 PM, Tarek Ziadé <[email protected]> wrote:
> I used PLY for an experiment, and I was trying to improve my DSL, in
> particular allow trailing commas.
I haven't thought about this particularly hard (I just tested simple
cases) but does:
def p_statements(p):
"""statements : statements COMMA statement
| statements COMMA
| statement
"""
if len(p) == 2:
p[0] = [p[1]]
elif len(p) == 3:
p[0] = p[1]
else:
p[0] = p[1] + [p[3]]
Help?
Schiavo
Simon
--
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.