SELF on the right of a rule in a LeftA level means NEXT
SELF on the right of a rule in a RightA level means the current level (ie really self)
AFAICT that is an exhaustive list of what associativity does. But then why even have it? instead of having SELF always mean the current level, and if you want a left associative rule use NEXT on the right.
Note that SELF does not always mean the current level. If you have SELF SELF... SELF in a rule, the inner SELFs have the top level rather than the current one. And the leftmost one has some kind of dual level (current level for the grammar, but next level for the parser, due to its LL nature). So, in the end, I suppose it is clearer to always write SELF in the rules and let the algorithm decide the correct level of each occurrence, possibly using the annotations LEFTA and RIGHTA.
I maintain Camlp5, and … well, you’re not too wrong there. I’ve tried to use associativity for doing something a little outside the scope of “infix operators” and … well, I shed a lot tears, did a ton of debugging, and concluded that that was a bad idea.
For infix operators, it works great, eh? But get outside that range, and … I think using parser levels directly is going to be much safer. Which is too bad. But the code down there in the grammar-interpreter (for doing associativity) … gotta say, I don’t really understand it msyelf.
A year or so ago, I had a burst of energy for redoing it all using ideas from ANTLR. But I never finished the project. Eventually I think something like that needs to happen though. The OCaml grammar evolves in directions that make it more and more difficult to parse with LL(1), even with hacks-upon-hacks.
Sorry, this doesn’t help you maybe. If you have concrete examples of stuff you’d like to do, I’d be happy to help you make 'em work in Camlp5.