Introduction (dont read if you dont want, this is just for background)
I am creating an API for C++ so that it has python-similar functionalities, without loosing its essence. I have successfully developed an automatic generic exception handling system (I asked how to do this here, and @MacZamborg told me how it works, so I started dismantling everything from scratch). Like I said, I managed to overload quite a lot of things so that the will automatically throw the according exception (which inherits from std::exception). The only one I had trouble with, was the ZERO_DIVISION exception, because it seems you cant overload operators just for ints, that is, one of the arguments, needs to be an object. So I created the Object Num, which uses an union to store any numeric data available) -> this means, I have to overload each operator 11 times, so I wanted to avoid the need to overload the X= operators. (Also asked something about it here).
Question
Is there a way in any IDE, to make smart macros? what is a smart macro, you may ask, well, lets pretend there is a new language called C+++, which implements smart macros > a smart macro should behave like this >
#define "regEx" "Literal replacement"
In practice:
#define '([^\d ]?\w+\s*)\+=' '$groups[0] = $groups[0] + '
With ([^\d ]?\w+\s*) being the only element in the groups array (The syntax comes from python's regEx, I may have some mistakes, but the idea is the same). That part of the regEx, will match any valid variable name (including reserved keywords [not derirable, but we get rid of them with the \+=]), that is, any word that starts with anything but a space or a digit, contains any character, and ends with spaces (0 or more). After that, it looks for the += operator, and if matched, it repaces the whole match with '$groups[0] = $groups[0] + ', that is, whatever was found on the only group (denoted by parenthesis), 'space' '=' 'space' 'what was found again' 'space' '+'
What all of this is addressed to, is to avoid having to overload the += operator (read intro if you may)