[RFC] Consolidates macro code

Refactors macro code, and adds triangular indexing for constraints. Also allows to add conditionals to both when that's a viable option. I didn't update the ``@defConstrRef`` code yet, and honestly I'm not sure how useful it is anymore...
Maybe some comments at the top here on what the format of the input expression is expected to be? Even though this is an internal function, it will be used from extensions also.