Function Pointer Declaration Untangling
March 3rd, 2010Last week, on Monday, I started writing my own C compiler with JastAdd, JFlex and Beaver.
To check that the compiler parses various declarations and types correctly, I wrote some attributes to spit out a human-readable representation of how the compiler interprets it’s input. This turned out to be a quite useful tool for reading difficult function pointer declarations. For example
int (*fpfi(int (*)(long), int))(int, ...);
becomes
fpfi has type ‘function of (pointer to function of (long int) returning int, int) returning pointer to function of (int, …) returning int’