Unfortunately, it doesn't just take identifier names. For example
> for i[0] in range(40)
is valid, as is
> for a.b in range(40)
and
> for a("bob")[6]["aflac"].c in range(40)
So a fix isn't that simple. Of course
> for 3 in 4
isn't valid, so I raise a syntax error when the expression on the left of
the "in" isn't an attribute, index, or identifier.
- Pavel Panchekha
On Fri, Apr 17, 2009 at 10:07 AM, Pedro Lopes <[email protected]> wrote:
>
> Hmm, does the left hand side of the IN in the FOR statement really
> take expressions, or does it only take identifier names? I ask
> because "for 3 in 4" sounds like a really strange loop :)
>
> If it only takes identifiers then it will be easy to make the conflict
> go away.
>
> Pedro
>
>
> On Apr 16, 9:41 pm, Pavel Panchekha <[email protected]> wrote:
> > I'm currently having trouble getting the following pair of rules to
> > parse correctly:
> >
> > > expr : expr IN expr
> > > for_s : FOR many_exprs IN many_exprs block else
> >
> > In for_s, I test the first many_exprs to make sure that it is
> > something that can be assigned to.
> >
> > Where many_exprs is defined:
> >
> > > many_exprs : many_exprs ',' expr
> > > | expr
> >
> > The problem is that I have a shift reduce error due to the rules for
> > expr and for_s above, for_s loses. and for statements don't parse. Any
> > good fix for this?
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---