> > 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.

I assume that what is acceptable on the left side of the IN is the
same kind of expression that is acceptable on the left side of an
assignment, right? These kinds of expressions are usually called
lvalues.

Try to have a specialized definition for lvalue instead of relying on
the generic expression. In the simplest case, if there were no member
and array access operators, you would have something like:

lvalue : IDENTIFIER
for_s : FOR lvalue_list IN expr_list block else
lvalue_list : lvalue_list ',' lvalue
            | lvalue
expr_list : expr_list ',' expr
          | expr

In your case the lvalue definition will be more complex, but the key
is that if "expr IN expr" is not a valid lvalue, then the for_s
definition will not have a conflict. (Another benefit of doing it this
way is that you will not have to check by hand if the assignment is
correct, it will be inherent to the grammar.)

I hope this made sense...
Pedro

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to