poikilos

Precedence list issues

Aug 27th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. In my parser, what is wrong with this precedence list? precedence = (
  2. ('nonassoc', IF, THEN),
  3. ('left', COLON),
  4. ('nonassoc', ELSE),
  5. # ('right', EQUALS), # right to allow x = a = b
  6. ('nonassoc', EQUALS, LT, GT, LE, GE, NE),
  7. # ^ needs to be nonassoc so = isn't associated with itself...
  8. # since it has a different meaning based on context.
  9. # separate from EQUALS to allow x=a>b?
  10. ('nonassoc', FLUSH),
  11. ('left', CREATE_EXPRS, APPEND_EXPRS),
  12. ('left', PLUS, MINUS),
  13. ('left', MULTIPLY, DIVIDE),
  14. ('left', POWER), # exponent (*not* same as EXP function)
  15. ('nonassoc', UNARY_MINUS),
  16. )
Advertisement
Add Comment
Please, Sign In to add comment