mbdriscoll/ctree — pull request #3 by leonardt (2014-02-20 23:43:51+00:00)
Title: Refactoring precedence logic, moving outside of nodes module.

Moved precedence logic into a separate module. Right now is_left_associative logic is pretty funky. Calls get_precedence, but then has to invert the precedences again to properly do the lookup. Solution is either to lookup precedence from dictionary to find the associativity or invert the associativity dictionary. Passes tests though.

Also right now it's looking up Precedence by the type(node).__name__ . Our naming scheme doesn't match up one to one with the c naming scheme (for Add/Sub). This is due to Add/Sub deciding whether or not is an unary or binary operation and constructing accordingly. Should we keep this? The other option would be to explicitly distinguish between the Add/Plus and Sub/Minus (the way the C naming scheme is) which would mean a separate class and reference for each.