It should work if you define expressions as follows:
exp: exp '+' exp { .. } exp '-' exp { .. } exp '*' exp { .. } exp '/' exp { .. } | literal_exp { .. } | ID { .. }
Priority only applies when operators are present as terminals in the rule.
See the documentation on How Priority Works :
each rule takes priority from the last mentioned terminal symbol in the components
Your exp rule has no terminals, so priority does not apply.
Peter de Rivaz
source share