I m thinking about best way to write C define processor that would be able to handle macros. Unfortunately nothing intelligent comes to my mind. It should behave exactly like one in C, so it handles expressions like this:
#define max(a, b) (a > b ? a : b)
printf("%d
", max(a, b));
Or this:
#define F 10
#define max(a, b) (a > b ? a : b)
printf("%d
", max(a, F));
I know about install and lookup functions from K&R2, what else do I need for replacing text inside parenthesis? Does anyone have any advice or some pseudo-code maybe? I know it s complex task, but still, what would be best possible way to do it?