On Wed, Jul 27, 2011 at 1:51 PM, Simon Cross <[email protected]> wrote: > 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?
Yeah that's what I was going to do, but I was wondering if there was a generic way to handle this case, because I am going to have to add it in many statements. Thanks > > 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. > > -- Tarek Ziadé | http://ziade.org -- 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.
