Erez Sh. wrote:
Thanks for the prompt and verbose reply!

It seems to work, but if I understand correctly, it still activates the rule var_list even for things which should be expr_list, but "inside" an expr_list. So in order to act by that rule, I'll have to return it and see if it goes to an assign or an expr_list?
Messy...
Sounds like you've got it!  Yea, you need to leave the python code for the rules open to the dual usage.  You can put special code in the "expr_list: var_list" rule, because if this gets reduced, it's an _expression_.  You could also wrap the var_list in another rule for the assign, like "assign_var_list: var_list" which doesn't add any syntax, but then if you use "assign_var_list" in your assign rules, it will only be reduced there, and so you can put python code with that rule that only applies to assignments.

"var_list appears before expr_list in the grammar"
How can I know that? And how can I affect that? (for any two given rules)
Textually before, i.e., the line numbers in the .py file with your grammar in it.  You had the var_list textually before the expr_list in the example grammar in your post.  This should have produced a reduce/reduce conflict from ply.yacc (may need debug set?).

-bruce


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